MT_GetVoltage

■Description

Get power supply voltage value.

■Synopsis

MT_GetVoltage(fd, pvol)

■Argument

fd
[C/C++] int
[Python] ctypes.c_int
Please specify handle acquired by MT_Open function.
pvol
[C/C++] float *
[Python] ctypes.POINTER(ctypes.c_float)
Specify a pointer to a variable storing the power supply voltage value.
If the function succeeds, the voltage data [v] is stored in this value.

■RETURN VALUE

[C/C++] int
[Python] ctypes.c_int
If the function succeeds, NO_ERROR is returned.
If the function fails, DRIVER_FAIL is returned.
The other errors : Error code details

■Sample Program Code

[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);
  



Function List