Skip to content

Instantly share code, notes, and snippets.

@jpkotta
Created July 28, 2015 16:59
Show Gist options
  • Save jpkotta/80efdb0471a0194bb514 to your computer and use it in GitHub Desktop.
Save jpkotta/80efdb0471a0194bb514 to your computer and use it in GitHub Desktop.
from collections import namedtuple
_d = {
'NACK_RESPONSE': 0x01,
'DEBUG_MESSAGE': 0x02,
'GET_SW_VERSION_CMD': 0x03,
'WATCHDOG_PING_MESSAGE': 0x04,
'CAN_SET_CHANNEL_STATE_CMD': 0x10,
'CAN_SET_BITRATE_CMD': 0x11,
'CAN_MESSAGE': 0x12,
'CAN_GET_BUS_STATE_CMD': 0x13,
'CAN_BUS_STATE_UPDATE': 0x14,
'ADC_CONFIG_CHANNEL_CMD': 0x20,
'ADC_UPDATE': 0x21,
'CCD_SET_CHANNEL_STATE_CMD': 0x30,
'CCD_MESSAGE': 0x31,
'CCD_GET_BUS_STATE_CMD': 0x32,
'CCD_BUS_STATE_UPDATE': 0x33,
'GPIO_SET_CMD': 0x48,
'GPIO_GET_UPDATE': 0x49,
'GPIO_UPDATE': 0x4A,
'RADAR_CONFIG_CMD': 0x50,
'RADAR_GET_UPDATE': 0x51,
'RADAR_UPDATE': 0x52,
'MONITOR_CONFIG_CMD': 0x60,
'MONITOR_CONNECTED_UPDATE': 0x61,
'MONITOR_DISCONNECTED_UPDATE': 0x62,
'MONITOR_SET_AUDIO': 0x64,
'MONITOR_SET_BRIGHTNESS': 0x65,
'MONITOR_FLASH_READ': 0x6A,
'MONITOR_FLASH_WRITE': 0x6B,
'MONITOR_FLASH_ERASE': 0x6C,
'MONITOR_FLASH_STATUS': 0x6D,
'TOUCHSCREEN_EVENT': 0x71,
'GET_WAKE_AND_RESET_REASON': 0xB0,
'WAKE_AND_RESET_REASON_UPDATE':0xB1,
'PREPARE_FOR_REPROGRAM': 0xC0,
'LOOPBACK_TEST': 0xE0,
'LOOPBACK_TEST2': 0xE1,
'PROJECT_SPECIFIC_CMD': 0xF0,
}
ApiCommandID = namedtuple("ApiCommandID", _d)
API_COMMAND_ID = ApiCommandID(**_d)
API_COMMAND_ID.LOOPBACK_TEST # access value
API_COMMAND_ID._fields # tuple of keys
API_COMMAND_ID._asdict() # dict of key:value pairs
API_COMMAND_ID # does everything a tuple can
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment