47 #include <iothinx/iothinxio.h> 50 int main(
int argc,
char **
const argv)
53 uint32_t relay_slot = 3;
54 uint8_t relay_channel = 0;
55 uint32_t relay_values = 0;
56 uint32_t relay_count = 0;
59 while (-1 != (rc = getopt(argc, argv,
"c:hs:")))
64 relay_slot = atoi(optarg);
67 relay_channel = atoi(optarg);
71 printf(
"Relay sample program.\n\n");
72 printf(
"Usage: ./relay [OPTIONS]\n\n");
74 printf(
"\t%-8s Slot of relay module. Default slot = %d\n",
"-s", relay_slot);
75 printf(
"\t%-8s Relay channel. Default channel = %d\n",
"-c", relay_channel);
81 printf(
"Relay slot = %lu\n", relay_slot);
82 printf(
"Relay channel = %u\n", relay_channel);
88 printf(
"ioThinx_IO_Client_Init() = %d\n", rc);
95 printf(
"ioThinx_Relay_GetValues() = %d\n", rc);
102 if (relay_values & (0x1 << relay_channel))
104 relay_values &= ~(0x1 << relay_channel);
108 relay_values |= 0x1 << relay_channel;
114 printf(
"ioThinx_DO_GetValues() = %d\n", rc);
116 printf(
"[%lu:%u] relay value = %x\n", relay_slot, relay_channel, (relay_values >> relay_channel) & 0x1);
121 printf(
"ioThinx_Relay_GetCurrentCounts() = %d\n", rc);
123 printf(
"[%lu:%u] relay count = %lu\n", relay_slot, relay_channel, relay_count);
IOTHINX_ERR ioThinx_Relay_GetCurrentCounts(uint32_t slot, uint8_t start, uint8_t count, uint32_t buf[])
IOTHINX_ERR ioThinx_Relay_GetValues(uint32_t slot, uint32_t *p_values)
IOTHINX_ERR ioThinx_Relay_SetValues(uint32_t slot, uint32_t values)
int main(int argc, char **const argv)
IOTHINX_ERR ioThinx_IO_Client_Init(void)