Commit 88bfe839 authored by Ivan Tyagov's avatar Ivan Tyagov

Fix error

See merge request !61
parents e2f98090 5a8d2ce6
......@@ -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
{
......
......@@ -48,8 +48,6 @@
#include <signal.h>
#include <argp.h>
#include <string.h>
#include "common.h"
#include "mod_io_i2c.h"
#include <time.h>
#include <open62541/plugin/log_stdout.h>
#include <open62541/server.h>
......@@ -57,6 +55,10 @@
#include <open62541/plugin/accesscontrol_default.h>
#include <open62541/plugin/pubsub_ethernet.h>
#include <open62541/plugin/pubsub_udp.h>
#include "common.h"
// variable indicating if OPC UA server is running or not
static volatile UA_Boolean running = true;
// global ID of coupler
static int COUPLER_ID = 0;
......@@ -92,6 +94,7 @@ char *PASSWORD;
char *X509_KEY_FILENAME;
char *X509_CERTIFICATE_FILENAME;
#include "mod_io_i2c.h"
#include "gpio.h"
#include "keep_alive.h"
#include "keep_alive_publisher.h"
......@@ -99,8 +102,6 @@ char *X509_CERTIFICATE_FILENAME;
#include "cli.h"
#include "mod_io_opc_ua.h"
static volatile UA_Boolean running = true;
static void stopHandler(int sign)
{
UA_LOG_INFO(UA_Log_Stdout, UA_LOGCATEGORY_SERVER, "received ctrl-c");
......
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