MT_GetVoltage

■機能

電源電圧値を取得します。

■書式

MT_GetVoltage(fd, pvol)

■引数

fd
[C/C++] int
[Python] ctypes.c_int
MT_Open関数で取得したハンドルを指定してください。

pvol
[C/C++] float *
[Python] ctypes.POINTER(ctypes.c_float)
電圧値を格納する変数へのPointerを指定します。

■戻り値

[C/C++] int
[Python] ctypes.c_int
関数が成功した場合、NO_ERRORが返されます。
関数が失敗した場合、NO_ERROR以外のコードが返されます。
その他のエラー:(参照:エラーコード詳細)

■サンプルプログラム

[C/C++]
  int fd;
  int ret = 0;
  float fvol;

  if ( (fd = MT_Open(NULL) ) < 0) {
      printf("Faild to open i2c port\n");
      return 1;
  }

  fvol = 0;
  ret = MT_GetVoltage(fd, &fvol);
  if (ret == 0) {
      printf("voltage : %f\n", fvol);
  }
  else {
      printf("MT_GetVoltage Failled %d\n", ret);
  }

  MT_Close(fd);
  
[Python]
  import ctypes
  import sys
  import mtdll_arm

  fd = mtdll_arm.MT_Open(None);
  if fd < 0:
      print("Faild to open i2c port");
      sys.exit()

  fvol = ctypes.c_float();
  ret = mtdll_arm.MT_GetVoltage(fd, fvol);
  if ret == 0:
      print("voltage : ", '{:f}'.format(fvol.value));
  else:
      print("MT_GetVoltage Failled ", '{:d}'.format(ret));

  mtdll_arm.MT_Close(fd);
  



関数一覧