4 #include "../hubolib.h"
5 #include "../hubocfg.h"
20 int main(
int argc,
char* argv[])
27 printf (
"Usage: \n SetDigitalOutput <digital output to activate>\n example: SetDigitalOutput 7 0 // this will set channel 7 to 0\n");
32 if (sscanf (argv[1],
"%d", &channel) != 1)
34 printf (
"Digital output could not be determined!\n");
39 if (sscanf (argv[2],
"%d", &outValue) != 1)
41 printf (
"Value for digital output could not be determined!\n");
45 if (outValue<0 || outValue>1)
47 printf (
"Value for digital output must be 0 or 1!\n");
51 printf (
"Setting digital output %d to %d.\n", channel, outValue);
61 printf (
"Error: Initialize\n");
71 unsigned char read_out_value, channel_values;
74 printf (
"Old channel values x%02X\n", channel_values);
77 channel_values |= (1 << channel);
79 channel_values &= ~(1 << channel);
81 printf (
"New channel values x%02X\n", channel_values);
88 for (
int retry=0; retry<10; retry++)
92 if (read_out_value == channel_values)
102 return bResult ? 1 : 0;
113 pthread_t threadHandle = pthread_self();
116 ret = pthread_getschedparam (threadHandle, &policy, ¶m);
121 param.sched_priority = sched_get_priority_max(policy);
122 ret = pthread_setschedparam(threadHandle, policy, ¶m);
const char * m_sI2CDevice
bool Initialize()
Initializes the library.
bool Set_DO_Channels(unsigned char value)
Requests the background thread to update all 8 bits of the digital output to the value specified...
void BoostThreadPriority()
bool Set_Cycle_Time(long cycleTime)
Sets the backgrounds threads polling interval in ms.
void Uninitialize()
Releases any resources bound to the library.
bool Wait_For_MCP23017_Buffered_Values()
Waits until input and output buffers of the MCP23017 master are initialized from the hardware...
bool Readback_DO_Channels(unsigned char &value)
Reads back the digital output latchs of the IO expander.
int main(int argc, char *argv[])