MT_SetLEDStatus

■機能

ステータスLEDの制御を行います。

■書式

MT_SetLEDStatus(fd, ucSLED)

■引数

fd
[C/C++] int
[Python] ctypes.c_int
MT_Open関数で取得したハンドルを指定してください。
ucSLED
[C/C++] unsigned char
[Python] ctypes.c_ubyte
ステータスLEDの状態を設定します。
  0x00:  Off
  0x01:  Red On
  0x02:  Red Blink
  0x04:  Green On
  

■戻り値

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

■サンプルプログラム

[C/C++]
  int fd;
  int ret = 0;
  unsigned char ledstatus = 0xff;

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

  ledstatus = 0x01;   /* 0x00: off, 0x01: Red, 0x02: Red Blink, 0x04: Green */
  printf("Set LED State %d \n", ledstatus);

  ret = MT_SetLEDStatus(fd, ledstatus);
  if (ret != 0) {
      printf("MT_SetLEDStatus error");
      MT_Close(fd);
      return ret;
  }

  ret = MT_GetLEDStatus(fd, &ledstatus);
  if (ret == 0) {
      printf("Get LED status : %xh\n", ledstatus);
  }
  else {
      printf("MT_GetLEDStatus 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()

  ledstatus = ctypes.c_ubyte();

  ledstatus = 0x01;   # 0x00: off, 0x01: Red, 0x02: Red Blink, 0x04: Green

  print("Set LED State ", '{:d}'.format(ledstatus));
  ret = mtdll_arm.MT_SetLEDStatus(fd, ledstatus);
  if ret != 0:
      print("MT_SetLEDStatus error [", '{:x}'.format(ret), "]");
      mtdll_arm.MT_Close(fd);
      sys.exit()

  ret = mtdll_arm.MT_GetLEDStatus(fd, ledstatus);
  if ret == 0:
      print("Get LED status : ", '{:x}h'.format(ledstatus.value));
  else :
      print("MT_GetLEDStatus Failled [", '{:d}'.format(ret), "]");

  mtdll_arm.MT_Close(fd);
  



関数一覧