#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <iothinx/iothinxio.h>
int main(
int argc,
char **
const argv)
{
int32_t rc;
uint32_t misc_slot = 0;
uint32_t module_slot = 1;
uint32_t module_count = 0;
uint8_t rs_state = 0;
uint8_t pbtn_state = 0;
uint8_t led_state = 0;
char ch;
while (-1 != (rc = getopt(argc, argv, "hs:")))
{
switch (rc)
{
case 's':
module_slot = atoi(optarg);
break;
case 'h':
default:
printf("Miscellaneous sample program.\n\n");
printf("Usage: ./misc [OPTIONS]\n\n");
printf("Options:\n");
printf("\t%-8s Slot of the module. Default slot = %d\n", "-s", module_slot);
printf("\n");
return 0;
}
}
{
printf("ioThinx_IO_Client_Init() = %d\n", rc);
return -1;
}
{
printf("ioThinx_Misc_GetModuleCount() = %d\n", rc);
}
printf("Module count = %lu\n", module_count);
printf("Module slot = %lu\n", module_slot);
{
printf("ioThinx_Misc_GetModuleInfo() = %d\n", rc);
}
else
{
printf("Slot %d Module Information:\n", module_slot);
printf("Model Name: %s, ", module_info.model_name);
printf("Serial Number: %s\n", module_info.serial_number);
}
{
printf("ioThinx_Misc_SetLocateState() = %d\n", rc);
}
else
{
printf("Slot %d: Locating...\n", module_slot);
}
printf("Press enter to stop locate.");
ch = getchar();
{
printf("ioThinx_Misc_SetLocateState() = %d\n", rc);
}
{
printf("ioThinx_Misc_GetRotarySwitchState() = %d\n", rc);
}
else
{
printf("Rotary switch state = %d\n", rs_state);
}
{
printf("ioThinx_Misc_GetPushButtonState() = %d\n", rc);
}
else
{
printf("Push button state = %d\n", pbtn_state);
}
{
printf("ioThinx_Misc_SetUserLedState() = %d\n", rc);
}
else
{
printf("Set LED U1 to GREEN\n");
}
{
printf("ioThinx_Misc_SetUserLedState() = %d\n", rc);
}
else
{
printf("Set LED U2 to RED\n");
}
printf("Press enter to clear.");
ch = getchar();
printf("Press enter to continue.");
ch = getchar();
return 0;
}
51 uint32_t misc_slot = 0;
52 uint32_t module_slot = 1;
53 uint32_t module_count = 0;
56 uint8_t pbtn_state = 0;
57 uint8_t led_state = 0;
60 while (-1 != (rc = getopt(argc, argv,
"hs:")))
65 module_slot = atoi(optarg);
69 printf(
"Miscellaneous sample program.\n\n");
70 printf(
"Usage: ./misc [OPTIONS]\n\n");
72 printf(
"\t%-8s Slot of the module. Default slot = %d\n",
"-s", module_slot);
82 printf(
"ioThinx_IO_Client_Init() = %d\n", rc);
90 printf(
"ioThinx_Misc_GetModuleCount() = %d\n", rc);
92 printf(
"Module count = %lu\n", module_count);
93 printf(
"Module slot = %lu\n", module_slot);
97 printf(
"ioThinx_Misc_GetModuleInfo() = %d\n", rc);
101 printf(
"Slot %d Module Information:\n", module_slot);
102 printf(
"Model Name: %s, ", module_info.model_name);
103 printf(
"Serial Number: %s\n", module_info.serial_number);
110 printf(
"ioThinx_Misc_SetLocateState() = %d\n", rc);
114 printf(
"Slot %d: Locating...\n", module_slot);
116 printf(
"Press enter to stop locate.");
121 printf(
"ioThinx_Misc_SetLocateState() = %d\n", rc);
128 printf(
"ioThinx_Misc_GetRotarySwitchState() = %d\n", rc);
132 printf(
"Rotary switch state = %d\n", rs_state);
139 printf(
"ioThinx_Misc_GetPushButtonState() = %d\n", rc);
143 printf(
"Push button state = %d\n", pbtn_state);
150 printf(
"ioThinx_Misc_SetUserLedState() = %d\n", rc);
154 printf(
"Set LED U1 to GREEN\n");
159 printf(
"ioThinx_Misc_SetUserLedState() = %d\n", rc);
163 printf(
"Set LED U2 to RED\n");
165 printf(
"Press enter to clear.");
169 printf(
"Press enter to continue.");
IOTHINX_ERR ioThinx_Misc_GetRotarySwitchState(uint32_t slot, uint8_t *p_state)
IOTHINX_ERR ioThinx_Misc_GetPushButtonState(uint32_t slot, uint8_t *p_state)
IOTHINX_ERR ioThinx_Misc_GetModuleCount(uint32_t *p_module_count)
IOTHINX_ERR ioThinx_Misc_SetUserLedState(uint32_t slot, uint8_t channel, uint8_t state)
IOTHINX_ERR ioThinx_Misc_GetModuleInfo(uint8_t slot, struct MODULE_INFO *p_module_info)
IOTHINX_ERR ioThinx_IO_Client_Init(void)
IOTHINX_ERR ioThinx_Misc_SetLocateState(uint32_t slot, uint8_t state)