Commit 08344b2e authored by Ivan Tyagov's avatar Ivan Tyagov

Plc measurement

See merge request nexedi/osie!28
parents be47fac3 d8a5d668
......@@ -199,7 +199,7 @@ void handleCLI(int argc, char **argv) {
// update current measurement mode
const char* s = getenv("CURRENT_GPIO_MODE");
if (s != NULL) CURRENT_GPIO_MODE = 1;
if (s != NULL) CURRENT_GPIO_MODE = atoi(s);
printf("GPIO measurement mode = %d\n", CURRENT_GPIO_MODE);
}
......
......@@ -20,7 +20,12 @@ static unsigned int SAFE_MODE_STATE_COUNTER = 0;
// the current GPI state (used for debuging)
static unsigned int CURRENT_GPIO_STATE = 0;
// variable representing the measurement over GPIO
/*
* variable representing the measurement mode over GPIO
* 0: disabled
* 1: enabled for keep-alive subsystem
* 2: enabled for first i2c0.relay0
*/
static unsigned int CURRENT_GPIO_MODE = 0;
// the heart beat interval (in ms)
......
......@@ -61,10 +61,6 @@ static int setGPIO() {
if(ioctl(led.fd, GPIOHANDLE_SET_LINE_VALUES_IOCTL, &data) < 0)
perror("Error setting GPIO to 1");
// debug
//UA_LOG_INFO(UA_Log_Stdout, UA_LOGCATEGORY_USERLAND, \
// "GPIO = %d", CURRENT_GPIO_STATE);
close(fd);
close(led.fd);
return 0;
......@@ -100,7 +96,7 @@ static void dataChangeNotificationCallback(UA_Server *server, UA_UInt32 monitore
// set GPIO so we can monitor using logical analyzer the work of
// keep-alive network system
if (CURRENT_GPIO_MODE) setGPIO();
if (CURRENT_GPIO_MODE == 1) setGPIO();
}
}
......
......@@ -470,6 +470,9 @@ static void afterWriteTimeI2C0_0(UA_Server *server,
if (data->value.type == &UA_TYPES[UA_TYPES_INT32])
{
UA_Int32 hrValue = *(UA_Int32 *)data->value.data;
// used only for debuging with logical analyzer
if (CURRENT_GPIO_MODE == 2) setGPIO();
int addr = I2C_SLAVE_ADDR_LIST[0];
if (hrValue > 0)
{
......
......@@ -20,7 +20,6 @@
#include <string.h>
#include "common.h"
#include "mod_io_i2c.h"
#include "mod_io_opc_ua.h"
#include <time.h>
#include <open62541/plugin/log_stdout.h>
#include <open62541/server.h>
......@@ -57,6 +56,7 @@ char *X509_CERTIFICATE_FILENAME;
#include "keep_alive_publisher.h"
#include "keep_alive_subscriber.h"
#include "cli.h"
#include "mod_io_opc_ua.h"
static volatile UA_Boolean running = true;
......
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