MT_SetDio

■Description

Controls the output state of DO port.

■Synopsis

MT_SetDio(fd, ucDioPort)

■Argument

fd
[C/C++] int
[Python] ctypes.c_int
Please specify handle acquired by MT_Open function.
ucDioPort
[C/C++] unsigned char
[Python] ctypes.c_ubyte
Set the output value.
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;
  }

  do_port = 0x01;

  printf("Set DIO DO:%02X\n", doport);
  ret = MT_SetDio(fd, doport);
  if (ret != 0) {
      printf("MT_SetDio error");
  }

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

  doport = 1;

  print("Set DIO DO:", '{:02x}'.format(doport));

  ret = MT_SetDio(fd, doport);
  if ret != 0:
      print("MT_SetDio error");

  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