MT_GetDio

■Description

DIO port input / ouput status is acquired.

■Synopsis

MT_GetDio(fd, ucDiPort, ucDoPort)

■Argument

fd
[C/C++] int
[Python] ctypes.c_int
Please specify handle acquired by MT_Open function.
ucDiPort
[C/C++] unsigned char *
[Python] ctypes.POINTER(ctypes.c_ubyte)
You can specify a Pointer to a variable that stores the input state to be acquired.
The acquired values correspond to bit of the below.

[for the CPI-RAS]
    bit0: DI 0 PIN  	0:High(default), 1:Low
    bit1: DI 1 PIN  	0:High(default), 1:Low
    
[for the DX-U1000 / DX-U2000 series]
    bit0: DIO 0 PIN  	0:High(default), 1:Low
    bit1: DIO 1 PIN  	0:High(default), 1:Low
    bit2: DI  0 PIN 	0:High(default), 1:Low
    bit3: DI  1 PIN 	0:High(default), 1:Low
    
ucDoPort
[C/C++] unsigned char *
[Python] ctypes.POINTER(ctypes.c_ubyte)
You can specify a Pointer to a variable that stores the output state to be acquired.
The acquired values correspond to bit of the below.

[for the CPI-RAS]
    bit0: DO	                	0:High(default), 1:Low
    bit1: None
    bit2: 8 - 28V External power	0:Low(default), 1:High
    bit3: 5V External power     	0:Low(default), 1:High
    
[for the DX-U1000 / DX-U2000 series]
    bit0: DIO 0 PIN             	0:High(default), 1:Low
    bit1: DIO 1 PIN             	0:High(default), 1:Low
    

■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;
  unsigned char diport=0, doport=0;

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

  ret = MT_GetDio(fd, &diport, &doport);
  if (ret == 0) {
      printf("Get DIO DI:%02X  DO:%02X\n", diport, doport);
  }
  else {
      printf("MT_GetDio 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()

  diport = ctypes.c_ubyte();
  doport = ctypes.c_ubyte();
  ret = mtdll_arm.MT_GetDio(fd, diport, doport);
  if ret == 0:
      print("Get DIO DI:", '{:02x}'.format(diport.value), "   DO:", '{:02x}'.format(doport.value));
  else:
      print("MT_GetDio Failled", '{:d}'.formart(ret));

  mtdll_arm.MT_Close(fd);

  



Function List