Inclusion of MOD IO Analog inputs

Test: Program is tested locally with laptop.

        modified:   server.c
parent 455e5a1c
......@@ -216,6 +216,258 @@ static int getDigitalInputState(int i2c_addr, char **digital_input)
close(file);
}
static int getAnalogInputStateAIN0(int i2c_addr, int **analog_input)
{
/*
* get digital input state over I2C
*/
int file;
char filename[20];
if (I2C_VIRTUAL_MODE)
{
// we're in a virtual mode, likely on x86 platform or without I2C support
// simply do nothing
return 0;
}
// step 1: open device
file = open(I2C_BLOCK_DEVICE_NAME, O_RDWR);
if (file < 0)
{
/* ERROR HANDLING; you can check errno to see what went wrong */
printf("Error opening i2c device (0x%x).\n", i2c_addr);
exit(1);
}
// step 2: address the slave by its address
if (ioctl(file, I2C_SLAVE, i2c_addr) < 0)
{
/* ERROR HANDLING; you can check errno to see what went wrong */
printf("Error addressing i2c slave (0x%x).\n", i2c_addr);
exit(1);
}
// step 3: write command over I2c
__u8 read_reg = 0x30; /* Device register to access */
char read_buf[10];
read_buf[0] = read_reg;
if (write(file, read_buf, 1) != 1)
{
/* ERROR HANDLING: i2c transaction failed */
printf("Error writing to i2c slave (0x%x).\n", i2c_addr);
}
if (read(file, read_buf, 1) != 1)
{
/* ERROR HANDLING: i2c transaction failed */
printf("Error reading analog input from i2c slave (0x%x).\n", i2c_addr);
}
else
{
/* Since read_buf[0] is (LSB:MSB) we need to convert it to (MSB:LSB). To swap bits one by one do
the following */
int analog_data = 0;
for (int index = 0; index < 8; index++)
{
analog_data |= ((read_buf[0] & 0x80) ? 1 : 0) << index;
read_buf[0] <<= 1;
}
/* Now add the high 2 bit to the value */
analog_data |= ((read_buf[1] & 0x02) ? 1 : 0) << 8;
analog_data |= ((read_buf[1] & 0x01) ? 1 : 0) << 9;
*analog_input = &analog_data;
}
close(file);
}
static int getAnalogInputStateAIN1(int i2c_addr, int **analog_input)
{
/*
* get digital input state over I2C
*/
int file;
char filename[20];
if (I2C_VIRTUAL_MODE)
{
// we're in a virtual mode, likely on x86 platform or without I2C support
// simply do nothing
return 0;
}
// step 1: open device
file = open(I2C_BLOCK_DEVICE_NAME, O_RDWR);
if (file < 0)
{
/* ERROR HANDLING; you can check errno to see what went wrong */
printf("Error opening i2c device (0x%x).\n", i2c_addr);
exit(1);
}
// step 2: address the slave by its address
if (ioctl(file, I2C_SLAVE, i2c_addr) < 0)
{
/* ERROR HANDLING; you can check errno to see what went wrong */
printf("Error addressing i2c slave (0x%x).\n", i2c_addr);
exit(1);
}
// step 3: write command over I2c
__u8 read_reg = 0x31; /* Device register to access */
char read_buf[10];
read_buf[0] = read_reg;
if (write(file, read_buf, 1) != 1)
{
/* ERROR HANDLING: i2c transaction failed */
printf("Error writing to i2c slave (0x%x).\n", i2c_addr);
}
if (read(file, read_buf, 1) != 1)
{
/* ERROR HANDLING: i2c transaction failed */
printf("Error reading Analog input from i2c slave (0x%x).\n", i2c_addr);
}
else
{
/* Since read_buf[0] is (LSB:MSB) we need to convert it to (MSB:LSB). To swap bits one by one do
the following */
int analog_data = 0;
for (int index = 0; index < 8; index++)
{
analog_data |= ((read_buf[0] & 0x80) ? 1 : 0) << index;
read_buf[0] <<= 1;
}
/* Now add the high 2 bit to the value */
analog_data |= ((read_buf[1] & 0x02) ? 1 : 0) << 8;
analog_data |= ((read_buf[1] & 0x01) ? 1 : 0) << 9;
*analog_input = &analog_data;
}
close(file);
}
static int getAnalogInputStateAIN2(int i2c_addr, int **analog_input)
{
/*
* get digital input state over I2C
*/
int file;
char filename[20];
if (I2C_VIRTUAL_MODE)
{
// we're in a virtual mode, likely on x86 platform or without I2C support
// simply do nothing
return 0;
}
// step 1: open device
file = open(I2C_BLOCK_DEVICE_NAME, O_RDWR);
if (file < 0)
{
/* ERROR HANDLING; you can check errno to see what went wrong */
printf("Error opening i2c device (0x%x).\n", i2c_addr);
exit(1);
}
// step 2: address the slave by its address
if (ioctl(file, I2C_SLAVE, i2c_addr) < 0)
{
/* ERROR HANDLING; you can check errno to see what went wrong */
printf("Error addressing i2c slave (0x%x).\n", i2c_addr);
exit(1);
}
// step 3: write command over I2c
__u8 read_reg = 0x32; /* Device register to access */
char read_buf[10];
read_buf[0] = read_reg;
if (write(file, read_buf, 1) != 1)
{
/* ERROR HANDLING: i2c transaction failed */
printf("Error writing to i2c slave (0x%x).\n", i2c_addr);
}
if (read(file, read_buf, 1) != 1)
{
/* ERROR HANDLING: i2c transaction failed */
printf("Error reading Analog input from i2c slave (0x%x).\n", i2c_addr);
}
else
{
/* Since read_buf[0] is (LSB:MSB) we need to convert it to (MSB:LSB). To swap bits one by one do
the following */
int analog_data = 0;
for (int index = 0; index < 8; index++)
{
analog_data |= ((read_buf[0] & 0x80) ? 1 : 0) << index;
read_buf[0] <<= 1;
}
/* Now add the high 2 bit to the value */
analog_data |= ((read_buf[1] & 0x02) ? 1 : 0) << 8;
analog_data |= ((read_buf[1] & 0x01) ? 1 : 0) << 9;
*analog_input = &analog_data;
}
close(file);
}
static int getAnalogInputStateAIN3(int i2c_addr, int **analog_input)
{
/*
* get digital input state over I2C
*/
int file;
char filename[20];
if (I2C_VIRTUAL_MODE)
{
// we're in a virtual mode, likely on x86 platform or without I2C support
// simply do nothing
return 0;
}
// step 1: open device
file = open(I2C_BLOCK_DEVICE_NAME, O_RDWR);
if (file < 0)
{
/* ERROR HANDLING; you can check errno to see what went wrong */
printf("Error opening i2c device (0x%x).\n", i2c_addr);
exit(1);
}
// step 2: address the slave by its address
if (ioctl(file, I2C_SLAVE, i2c_addr) < 0)
{
/* ERROR HANDLING; you can check errno to see what went wrong */
printf("Error addressing i2c slave (0x%x).\n", i2c_addr);
exit(1);
}
// step 3: write command over I2c
__u8 read_reg = 0x33; /* Device register to access */
char read_buf[10];
read_buf[0] = read_reg;
if (write(file, read_buf, 1) != 1)
{
/* ERROR HANDLING: i2c transaction failed */
printf("Error writing to i2c slave (0x%x).\n", i2c_addr);
}
if (read(file, read_buf, 1) != 1)
{
/* ERROR HANDLING: i2c transaction failed */
printf("Error reading Analog input from i2c slave (0x%x).\n", i2c_addr);
}
else
{
/* Since read_buf[0] is (LSB:MSB) we need to convert it to (MSB:LSB). To swap bits one by one do
the following */
int analog_data = 0;
for (int index = 0; index < 8; index++)
{
analog_data |= ((read_buf[0] & 0x80) ? 1 : 0) << index;
read_buf[0] <<= 1;
}
/* Now add the high 2 bit to the value */
analog_data |= ((read_buf[1] & 0x02) ? 1 : 0) << 8;
analog_data |= ((read_buf[1] & 0x01) ? 1 : 0) << 9;
*analog_input = &analog_data;
}
close(file);
}
void addIntegerVariableNode(UA_Server *server, char *node_id, char *node_description)
{
UA_Int32 myInteger = 0;
......@@ -235,6 +487,25 @@ void addIntegerVariableNode(UA_Server *server, char *node_id, char *node_descrip
UA_NODEID_NUMERIC(0, UA_NS0ID_BASEDATAVARIABLETYPE), attr0, NULL, NULL);
}
void addUIntegerVariableReadNode(UA_Server *server, char *node_id, char *node_description)
{
UA_UInt32 myInteger = 0;
UA_NodeId parentNodeId = UA_NODEID_NUMERIC(0, UA_NS0ID_OBJECTSFOLDER);
UA_NodeId parentReferenceNodeId = UA_NODEID_NUMERIC(0, UA_NS0ID_ORGANIZES);
UA_VariableAttributes attr0 = UA_VariableAttributes_default;
UA_Variant_setScalar(&attr0.value, &myInteger, &UA_TYPES[UA_TYPES_UINT32]);
attr0.description = UA_LOCALIZEDTEXT("en-US", node_description);
attr0.displayName = UA_LOCALIZEDTEXT("en-US", node_description);
attr0.dataType = UA_TYPES[UA_TYPES_UINT32].typeId;
attr0.accessLevel = UA_ACCESSLEVELMASK_READ;
UA_NodeId myIntegerNodeId0 = UA_NODEID_STRING(1, node_id);
UA_QualifiedName myIntegerName0 = UA_QUALIFIEDNAME(1, node_description);
UA_Server_addVariableNode(server, myIntegerNodeId0, parentNodeId,
parentReferenceNodeId, myIntegerName0,
UA_NODEID_NUMERIC(0, UA_NS0ID_BASEDATAVARIABLETYPE), attr0, NULL, NULL);
}
void addBooleanVariableReadNode(UA_Server *server, char *node_id, char *node_description)
{
UA_Boolean myBoolean = false;
......@@ -271,6 +542,10 @@ static void addVariable(UA_Server *server)
addBooleanVariableReadNode(server, "i2c0.in1", "I2C0 / Digital Input 1");
addBooleanVariableReadNode(server, "i2c0.in2", "I2C0 / Digital Input 2");
addBooleanVariableReadNode(server, "i2c0.in3", "I2C0 / Digital Input 3");
addUIntegerVariableReadNode(server, "i2c0.ain0", "I2C0 / Analog Input 0");
addUIntegerVariableReadNode(server, "i2c0.ain1", "I2C0 / Analog Input 1");
addUIntegerVariableReadNode(server, "i2c0.ain2", "I2C0 / Analog Input 2");
addUIntegerVariableReadNode(server, "i2c0.ain3", "I2C0 / Analog Input 3");
}
if (length >= 2)
{
......@@ -283,6 +558,10 @@ static void addVariable(UA_Server *server)
addBooleanVariableReadNode(server, "i2c1.in1", "I2C1 / Digital Input 1");
addBooleanVariableReadNode(server, "i2c1.in2", "I2C1 / Digital Input 2");
addBooleanVariableReadNode(server, "i2c1.in3", "I2C1 / Digital Input 3");
addUIntegerVariableReadNode(server, "i2c1.ain0", "I2C1 / Analog Input 0");
addUIntegerVariableReadNode(server, "i2c1.ain1", "I2C1 / Analog Input 1");
addUIntegerVariableReadNode(server, "i2c1.ain2", "I2C1 / Analog Input 2");
addUIntegerVariableReadNode(server, "i2c1.ain3", "I2C1 / Analog Input 3");
}
}
......@@ -295,6 +574,116 @@ static void beforeReadTime(UA_Server *server,
const UA_NumericRange *range, const UA_DataValue *data)
{
}
static void beforeReadTimeI2C0Ain0(UA_Server *server,
const UA_NodeId *sessionId, void *sessionContext,
const UA_NodeId *nodeid, void *nodeContext,
const UA_NumericRange *range, const UA_DataValue *data)
{
int addr = I2C_SLAVE_ADDR_LIST[0];
int *data_input = 0;
getAnalogInputStateAIN0(addr, &data_input);
if (data->value.type == &UA_TYPES[UA_TYPES_UINT32])
{
*(UA_UInt32 *)data->value.data = *data_input;
}
}
static void beforeReadTimeI2C0Ain1(UA_Server *server,
const UA_NodeId *sessionId, void *sessionContext,
const UA_NodeId *nodeid, void *nodeContext,
const UA_NumericRange *range, const UA_DataValue *data)
{
int addr = I2C_SLAVE_ADDR_LIST[0];
int *data_input = 0;
getAnalogInputStateAIN1(addr, &data_input);
if (data->value.type == &UA_TYPES[UA_TYPES_UINT32])
{
*(UA_UInt32 *)data->value.data = *data_input;
}
}
static void beforeReadTimeI2C0Ain2(UA_Server *server,
const UA_NodeId *sessionId, void *sessionContext,
const UA_NodeId *nodeid, void *nodeContext,
const UA_NumericRange *range, const UA_DataValue *data)
{
int addr = I2C_SLAVE_ADDR_LIST[0];
int *data_input = 0;
getAnalogInputStateAIN2(addr, &data_input);
if (data->value.type == &UA_TYPES[UA_TYPES_UINT32])
{
*(UA_UInt32 *)data->value.data = *data_input;
}
}
static void beforeReadTimeI2C0Ain3(UA_Server *server,
const UA_NodeId *sessionId, void *sessionContext,
const UA_NodeId *nodeid, void *nodeContext,
const UA_NumericRange *range, const UA_DataValue *data)
{
int addr = I2C_SLAVE_ADDR_LIST[0];
int *data_input = 0;
getAnalogInputStateAIN3(addr, &data_input);
if (data->value.type == &UA_TYPES[UA_TYPES_UINT32])
{
*(UA_UInt32 *)data->value.data = *data_input;
}
}
static void beforeReadTimeI2C1Ain0(UA_Server *server,
const UA_NodeId *sessionId, void *sessionContext,
const UA_NodeId *nodeid, void *nodeContext,
const UA_NumericRange *range, const UA_DataValue *data)
{
int addr = I2C_SLAVE_ADDR_LIST[1];
int *data_input = 0;
getAnalogInputStateAIN0(addr, &data_input);
if (data->value.type == &UA_TYPES[UA_TYPES_UINT32])
{
*(UA_UInt32 *)data->value.data = *data_input;
}
}
static void beforeReadTimeI2C1Ain1(UA_Server *server,
const UA_NodeId *sessionId, void *sessionContext,
const UA_NodeId *nodeid, void *nodeContext,
const UA_NumericRange *range, const UA_DataValue *data)
{
int addr = I2C_SLAVE_ADDR_LIST[1];
int *data_input = 0;
getAnalogInputStateAIN1(addr, &data_input);
if (data->value.type == &UA_TYPES[UA_TYPES_UINT32])
{
*(UA_UInt32 *)data->value.data = *data_input;
}
}
static void beforeReadTimeI2C1Ain2(UA_Server *server,
const UA_NodeId *sessionId, void *sessionContext,
const UA_NodeId *nodeid, void *nodeContext,
const UA_NumericRange *range, const UA_DataValue *data)
{
int addr = I2C_SLAVE_ADDR_LIST[1];
int *data_input = 0;
getAnalogInputStateAIN2(addr, &data_input);
if (data->value.type == &UA_TYPES[UA_TYPES_UINT32])
{
*(UA_UInt32 *)data->value.data = *data_input;
}
}
static void beforeReadTimeI2C1Ain3(UA_Server *server,
const UA_NodeId *sessionId, void *sessionContext,
const UA_NodeId *nodeid, void *nodeContext,
const UA_NumericRange *range, const UA_DataValue *data)
{
int addr = I2C_SLAVE_ADDR_LIST[1];
int *data_input = 0;
getAnalogInputStateAIN3(addr, &data_input);
if (data->value.type == &UA_TYPES[UA_TYPES_UINT32])
{
*(UA_UInt32 *)data->value.data = *data_input;
}
}
static void beforeReadTimeI2C0In0(UA_Server *server,
const UA_NodeId *sessionId, void *sessionContext,
const UA_NodeId *nodeid, void *nodeContext,
......@@ -395,7 +784,7 @@ static void beforeReadTimeI2C1In0(UA_Server *server,
const UA_NodeId *nodeid, void *nodeContext,
const UA_NumericRange *range, const UA_DataValue *data)
{
int addr = I2C_SLAVE_ADDR_LIST[0];
int addr = I2C_SLAVE_ADDR_LIST[1];
char *data_input = 0;
getDigitalInputState(addr, &data_input);
if ((*data_input) & (1UL << 0))
......@@ -419,7 +808,7 @@ static void beforeReadTimeI2C1In1(UA_Server *server,
const UA_NodeId *nodeid, void *nodeContext,
const UA_NumericRange *range, const UA_DataValue *data)
{
int addr = I2C_SLAVE_ADDR_LIST[0];
int addr = I2C_SLAVE_ADDR_LIST[1];
char *data_input = 0;
getDigitalInputState(addr, &data_input);
if ((*data_input) & (1UL << 1))
......@@ -443,7 +832,7 @@ static void beforeReadTimeI2C1In2(UA_Server *server,
const UA_NodeId *nodeid, void *nodeContext,
const UA_NumericRange *range, const UA_DataValue *data)
{
int addr = I2C_SLAVE_ADDR_LIST[0];
int addr = I2C_SLAVE_ADDR_LIST[1];
char *data_input = 0;
getDigitalInputState(addr, &data_input);
if ((*data_input) & (1UL << 2))
......@@ -467,7 +856,7 @@ static void beforeReadTimeI2C1In3(UA_Server *server,
const UA_NodeId *nodeid, void *nodeContext,
const UA_NumericRange *range, const UA_DataValue *data)
{
int addr = I2C_SLAVE_ADDR_LIST[0];
int addr = I2C_SLAVE_ADDR_LIST[1];
char *data_input = 0;
getDigitalInputState(addr, &data_input);
if ((*data_input) & (1UL << 3))
......@@ -733,64 +1122,120 @@ static void addValueCallbackToCurrentTimeVariable(UA_Server *server)
callback7.onWrite = afterWriteTime;
UA_Server_setVariableNode_valueCallback(server, currentNodeId7, callback7);
// Analog input 0
UA_NodeId currentNodeId8 = UA_NODEID_STRING(1, "i2c0.ain0");
UA_ValueCallback callback8;
callback8.onRead = beforeReadTimeI2C0Ain0;
callback8.onWrite = afterWriteTime;
UA_Server_setVariableNode_valueCallback(server, currentNodeId8, callback8);
// Analog input 1
UA_NodeId currentNodeId9 = UA_NODEID_STRING(1, "i2c0.ain1");
UA_ValueCallback callback9;
callback9.onRead = beforeReadTimeI2C0Ain1;
callback9.onWrite = afterWriteTime;
UA_Server_setVariableNode_valueCallback(server, currentNodeId9, callback9);
// Analog input 2
UA_NodeId currentNodeId10 = UA_NODEID_STRING(1, "i2c0.ain2");
UA_ValueCallback callback10;
callback10.onRead = beforeReadTimeI2C0Ain2;
callback10.onWrite = afterWriteTime;
UA_Server_setVariableNode_valueCallback(server, currentNodeId10, callback10);
// Analog input 3
UA_NodeId currentNodeId11 = UA_NODEID_STRING(1, "i2c0.ain3");
UA_ValueCallback callback11;
callback11.onRead = beforeReadTimeI2C0Ain3;
callback11.onWrite = afterWriteTime;
UA_Server_setVariableNode_valueCallback(server, currentNodeId11, callback11);
if (length > 1)
{
// I2C1
// relay 0
UA_NodeId currentNodeId8 = UA_NODEID_STRING(1, "i2c1.relay0");
UA_ValueCallback callback8;
callback8.onRead = beforeReadTime;
callback8.onWrite = afterWriteTimeI2C1_0;
UA_Server_setVariableNode_valueCallback(server, currentNodeId8, callback8);
UA_NodeId currentNodeId12 = UA_NODEID_STRING(1, "i2c1.relay0");
UA_ValueCallback callback12;
callback12.onRead = beforeReadTime;
callback12.onWrite = afterWriteTimeI2C1_0;
UA_Server_setVariableNode_valueCallback(server, currentNodeId12, callback12);
// relay 1
UA_NodeId currentNodeId9 = UA_NODEID_STRING(1, "i2c1.relay1");
UA_ValueCallback callback9;
callback9.onRead = beforeReadTime;
callback9.onWrite = afterWriteTimeI2C1_1;
UA_Server_setVariableNode_valueCallback(server, currentNodeId9, callback9);
UA_NodeId currentNodeId13 = UA_NODEID_STRING(1, "i2c1.relay1");
UA_ValueCallback callback13;
callback13.onRead = beforeReadTime;
callback13.onWrite = afterWriteTimeI2C1_1;
UA_Server_setVariableNode_valueCallback(server, currentNodeId13, callback13);
// relay 2
UA_NodeId currentNodeId10 = UA_NODEID_STRING(1, "i2c1.relay2");
UA_ValueCallback callback10;
callback10.onRead = beforeReadTime;
callback10.onWrite = afterWriteTimeI2C1_2;
UA_Server_setVariableNode_valueCallback(server, currentNodeId6, callback10);
UA_NodeId currentNodeId14 = UA_NODEID_STRING(1, "i2c1.relay2");
UA_ValueCallback callback14;
callback14.onRead = beforeReadTime;
callback14.onWrite = afterWriteTimeI2C1_2;
UA_Server_setVariableNode_valueCallback(server, currentNodeId14, callback14);
// relay 2
UA_NodeId currentNodeId11 = UA_NODEID_STRING(1, "i2c1.relay3");
UA_ValueCallback callback11;
callback11.onRead = beforeReadTime;
callback11.onWrite = afterWriteTimeI2C1_3;
UA_Server_setVariableNode_valueCallback(server, currentNodeId11, callback11);
UA_NodeId currentNodeId15 = UA_NODEID_STRING(1, "i2c1.relay3");
UA_ValueCallback callback15;
callback15.onRead = beforeReadTime;
callback15.onWrite = afterWriteTimeI2C1_3;
UA_Server_setVariableNode_valueCallback(server, currentNodeId15, callback15);
// Digital input 0
UA_NodeId currentNodeId12 = UA_NODEID_STRING(1, "i2c1.in0");
UA_ValueCallback callback12;
callback12.onRead = beforeReadTimeI2C1In0;
callback12.onWrite = afterWriteTime;
UA_Server_setVariableNode_valueCallback(server, currentNodeId12, callback12);
UA_NodeId currentNodeId16 = UA_NODEID_STRING(1, "i2c1.in0");
UA_ValueCallback callback16;
callback16.onRead = beforeReadTimeI2C1In0;
callback16.onWrite = afterWriteTime;
UA_Server_setVariableNode_valueCallback(server, currentNodeId16, callback16);
// Digital input 1
UA_NodeId currentNodeId13 = UA_NODEID_STRING(1, "i2c1.in1");
UA_ValueCallback callback13;
callback13.onRead = beforeReadTimeI2C1In1;
callback13.onWrite = afterWriteTime;
UA_Server_setVariableNode_valueCallback(server, currentNodeId13, callback13);
UA_NodeId currentNodeId17 = UA_NODEID_STRING(1, "i2c1.in1");
UA_ValueCallback callback17;
callback17.onRead = beforeReadTimeI2C1In1;
callback17.onWrite = afterWriteTime;
UA_Server_setVariableNode_valueCallback(server, currentNodeId17, callback17);
// Digital input 2
UA_NodeId currentNodeId14 = UA_NODEID_STRING(1, "i2c1.in2");
UA_ValueCallback callback14;
callback14.onRead = beforeReadTimeI2C1In2;
callback14.onWrite = afterWriteTime;
UA_Server_setVariableNode_valueCallback(server, currentNodeId14, callback14);
UA_NodeId currentNodeId18 = UA_NODEID_STRING(1, "i2c1.in2");
UA_ValueCallback callback18;
callback18.onRead = beforeReadTimeI2C1In2;
callback18.onWrite = afterWriteTime;
UA_Server_setVariableNode_valueCallback(server, currentNodeId18, callback18);
// Digital input 3
UA_NodeId currentNodeId15 = UA_NODEID_STRING(1, "i2c1.in3");
UA_ValueCallback callback15;
callback15.onRead = beforeReadTimeI2C1In3;
callback15.onWrite = afterWriteTime;
UA_Server_setVariableNode_valueCallback(server, currentNodeId15, callback15);
UA_NodeId currentNodeId19 = UA_NODEID_STRING(1, "i2c1.in3");
UA_ValueCallback callback19;
callback19.onRead = beforeReadTimeI2C1In3;
callback19.onWrite = afterWriteTime;
UA_Server_setVariableNode_valueCallback(server, currentNodeId19, callback19);
// Analog input 0
UA_NodeId currentNodeId20 = UA_NODEID_STRING(1, "i2c1.ain0");
UA_ValueCallback callback20;
callback20.onRead = beforeReadTimeI2C1Ain0;
callback20.onWrite = afterWriteTime;
UA_Server_setVariableNode_valueCallback(server, currentNodeId20, callback20);
// Analog input 1
UA_NodeId currentNodeId21 = UA_NODEID_STRING(1, "i2c1.ain1");
UA_ValueCallback callback21;
callback21.onRead = beforeReadTimeI2C1Ain1;
callback21.onWrite = afterWriteTime;
UA_Server_setVariableNode_valueCallback(server, currentNodeId21, callback21);
// Analog input 2
UA_NodeId currentNodeId22 = UA_NODEID_STRING(1, "i2c1.ain2");
UA_ValueCallback callback22;
callback22.onRead = beforeReadTimeI2C1Ain2;
callback22.onWrite = afterWriteTime;
UA_Server_setVariableNode_valueCallback(server, currentNodeId22, callback22);
// Analog input 3
UA_NodeId currentNodeId23 = UA_NODEID_STRING(1, "i2c1.ain3");
UA_ValueCallback callback23;
callback23.onRead = beforeReadTimeI2C1Ain3;
callback23.onWrite = afterWriteTime;
UA_Server_setVariableNode_valueCallback(server, currentNodeId23, callback23);
}
}
......
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