Commit 5a8d2ce6 authored by Ivan Tyagov's avatar Ivan Tyagov

In case of read / set error of I2C device always exit OPCUA server.

This way the PLC program can handle the exception accordingly
rather that simply hide it as till now.
parent 8a91ceb2
......@@ -113,6 +113,7 @@ static int setRelayState(int command, int i2c_addr)
{
/* ERROR HANDLING: i2c transaction failed */
printf("Error writing to i2c slave (0x%x).\n", i2c_addr);
exit(1);
}
close(file);
return 0;
......@@ -156,11 +157,13 @@ static int getDigitalInputState(int i2c_addr, char **digital_input)
{
/* ERROR HANDLING: i2c transaction failed */
printf("Error writing to i2c slave (0x%x).\n", i2c_addr);
exit(1);
}
if (read(file, read_buf, 1) != 1)
{
/* ERROR HANDLING: i2c transaction failed */
printf("Error reading digital input from i2c slave (0x%x).\n", i2c_addr);
exit(1);
}
else
{
......@@ -208,11 +211,13 @@ static int getAnalogInputStateAIN(int i2c_addr, int **analog_input, uint8_t read
{
/* ERROR HANDLING: i2c transaction failed */
printf("Error writing to i2c slave (0x%x).\n", i2c_addr);
exit(1);
}
if (read(file, read_buf, 2) != 2)
{
/* ERROR HANDLING: i2c transaction failed */
printf("Error reading analog input from i2c slave (0x%x).\n", i2c_addr);
exit(1);
}
else
{
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment