#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 tc_slot = 6;
uint8_t tc_channel = 0;
float tc_value;
float tc_calibration_temperature = 0.0f;
char ch;
while (-1 != (rc = getopt(argc, argv, "c:e:hs:t:")))
{
switch (rc)
{
case 'c':
tc_channel = atoi(optarg);
break;
case 'e':
tc_calibration_temperature = atof(optarg);
break;
case 's':
tc_slot = atoi(optarg);
break;
case 't':
tc_type = atoi(optarg);
break;
case 'h':
default:
printf("TC calibration sample program.\n\n");
printf("Usage: ./tc_calibration [OPTIONS]\n\n");
printf("Options:\n");
printf("\t%-8s Slot of TC module. Default slot = %d\n", "-s", tc_slot);
printf("\t%-8s TC channel. Default channel = %d\n", "-c", tc_channel);
printf("\t%-8s TC type. Default type = %d\n", "-t", tc_type);
printf("\t%-8s Setting temperature. Default temperature = %.3f\n", "-e", tc_calibration_temperature);
printf("\n");
return 0;
}
}
printf("TC slot = %lu\n", tc_slot);
printf("TC channel = %u\n", tc_channel);
printf("TC type = %d\n", tc_type);
printf("calibration temperature = %.3f\n", tc_calibration_temperature);
{
printf("ioThinx_IO_Client_Init() = %d\n", rc);
return -1;
}
{
printf("ioThinx_TC_Config_SetSensorTypes() = %d\n", rc);
return -1;
}
{
printf("ioThinx_IO_Config_Reload() = %d\n", rc);
}
printf("\nAfter executing this program, a non-volatile offset will be set for the selected channel.\n");
printf("1. Ensure the sensor is connected.\n");
printf("2. Ensure the channel and its sensor type is correctly selected.\n");
printf("3. Put the sensor into a glass that contains a mixture of ice and water.\n");
printf("4. Do not remove the sensor from the ice water during calibration...\n");
printf("Continue ? (y/n): ");
ch = getchar();
if (ch == 'y')
{
{
printf("ioThinx_TC_GetValues() = %d\n", rc);
}
else
{
printf("TC value before calibration: %.3f\n", tc_value);
}
{
printf("ioThinx_TC_SetCalibrations() = %d\n", rc);
}
printf("Calibrating...\n");
sleep(3);
{
printf("ioThinx_TC_GetValues() = %d\n", rc);
}
else
{
printf("TC value after calibration: %.3f\n", tc_value);
}
printf("Finish.\n");
}
else
{
printf("Abort.\n");
}
return 0;
}
58 uint8_t tc_channel = 0;
61 float tc_calibration_temperature = 0.0f;
64 while (-1 != (rc = getopt(argc, argv,
"c:e:hs:t:")))
69 tc_channel = atoi(optarg);
72 tc_calibration_temperature = atof(optarg);
75 tc_slot = atoi(optarg);
78 tc_type = atoi(optarg);
82 printf(
"TC calibration sample program.\n\n");
83 printf(
"Usage: ./tc_calibration [OPTIONS]\n\n");
85 printf(
"\t%-8s Slot of TC module. Default slot = %d\n",
"-s", tc_slot);
86 printf(
"\t%-8s TC channel. Default channel = %d\n",
"-c", tc_channel);
87 printf(
"\t%-8s TC type. Default type = %d\n",
"-t", tc_type);
88 printf(
"\t%-8s Setting temperature. Default temperature = %.3f\n",
"-e", tc_calibration_temperature);
94 printf(
"TC slot = %lu\n", tc_slot);
95 printf(
"TC channel = %u\n", tc_channel);
96 printf(
"TC type = %d\n", tc_type);
97 printf(
"calibration temperature = %.3f\n", tc_calibration_temperature);
103 printf(
"ioThinx_IO_Client_Init() = %d\n", rc);
111 printf(
"ioThinx_TC_Config_SetSensorTypes() = %d\n", rc);
119 printf(
"ioThinx_IO_Config_Reload() = %d\n", rc);
122 printf(
"\nAfter executing this program, a non-volatile offset will be set for the selected channel.\n");
123 printf(
"1. Ensure the sensor is connected.\n");
124 printf(
"2. Ensure the channel and its sensor type is correctly selected.\n");
125 printf(
"3. Put the sensor into a glass that contains a mixture of ice and water.\n");
126 printf(
"4. Do not remove the sensor from the ice water during calibration...\n");
127 printf(
"Continue ? (y/n): ");
135 printf(
"ioThinx_TC_GetValues() = %d\n", rc);
139 printf(
"TC value before calibration: %.3f\n", tc_value);
146 printf(
"ioThinx_TC_SetCalibrations() = %d\n", rc);
150 printf(
"Calibrating...\n");
157 printf(
"ioThinx_TC_GetValues() = %d\n", rc);
161 printf(
"TC value after calibration: %.3f\n", tc_value);
IOTHINX_ERR ioThinx_TC_GetValues(uint32_t slot, uint8_t start, uint8_t count, float buf[])
IOTHINX_ERR ioThinx_TC_Config_SetSensorTypes(uint32_t slot, uint8_t start, uint8_t count, uint8_t buf[])
IOTHINX_ERR ioThinx_TC_SetCalibrations(uint32_t slot, uint8_t start, uint8_t count, float buf[])
IOTHINX_ERR ioThinx_IO_Config_Reload(void)
IOTHINX_ERR ioThinx_IO_Client_Init(void)