Commit 6f5eebab authored by Ivan Tyagov's avatar Ivan Tyagov

Support up to 8 MOD-IOs.

parent 1efa9bef
...@@ -8,8 +8,8 @@ static char *DEFAULT_I2C_0_ADDR = "0x58"; ...@@ -8,8 +8,8 @@ static char *DEFAULT_I2C_0_ADDR = "0x58";
// the list of attached I2C slaves // the list of attached I2C slaves
const int DEFAULT_I2C_SLAVE_ADDR = 0x58; const int DEFAULT_I2C_SLAVE_ADDR = 0x58;
// XXX:code assumes only 2 I2C slaves but it can be more // XXX:code assumes only 8 I2C slaves but it can be up to 127
int I2C_SLAVE_ADDR_LIST[] = {0, 0}; int I2C_SLAVE_ADDR_LIST[] = {0, 0, 0, 0, 0, 0, 0, 0};
// the block device at host machine // the block device at host machine
static char *DEFAULT_I2C_BLOCK_DEVICE_NAME = "/dev/i2c-1"; static char *DEFAULT_I2C_BLOCK_DEVICE_NAME = "/dev/i2c-1";
......
...@@ -99,6 +99,102 @@ static void addVariable(UA_Server *server) ...@@ -99,6 +99,102 @@ static void addVariable(UA_Server *server)
addUIntegerVariableReadNode(server, "i2c1.ain2", "I2C1 / Analog Input 2"); addUIntegerVariableReadNode(server, "i2c1.ain2", "I2C1 / Analog Input 2");
addUIntegerVariableReadNode(server, "i2c1.ain3", "I2C1 / Analog Input 3"); addUIntegerVariableReadNode(server, "i2c1.ain3", "I2C1 / Analog Input 3");
} }
if (length >= 3)
{
// IC2-2
addIntegerVariableNode(server, "i2c2.relay0", "I2C2 / Relay 0");
addIntegerVariableNode(server, "i2c2.relay1", "I2C2 / Relay 1");
addIntegerVariableNode(server, "i2c2.relay2", "I2C2 / Relay 2");
addIntegerVariableNode(server, "i2c2.relay3", "I2C2 / Relay 3");
addBooleanVariableReadNode(server, "i2c2.in0", "I2C2 / Digital Input 0");
addBooleanVariableReadNode(server, "i2c2.in1", "I2C2 / Digital Input 1");
addBooleanVariableReadNode(server, "i2c2.in2", "I2C2 / Digital Input 2");
addBooleanVariableReadNode(server, "i2c2.in3", "I2C2 / Digital Input 3");
addUIntegerVariableReadNode(server, "i2c2.ain0", "I2C2 / Analog Input 0");
addUIntegerVariableReadNode(server, "i2c2.ain1", "I2C2 / Analog Input 1");
addUIntegerVariableReadNode(server, "i2c2.ain2", "I2C2 / Analog Input 2");
addUIntegerVariableReadNode(server, "i2c2.ain3", "I2C2 / Analog Input 3");
}
if (length >= 4)
{
// IC2-3
addIntegerVariableNode(server, "i2c3.relay0", "I2C3 / Relay 0");
addIntegerVariableNode(server, "i2c3.relay1", "I2C3 / Relay 1");
addIntegerVariableNode(server, "i2c3.relay2", "I2C3 / Relay 2");
addIntegerVariableNode(server, "i2c3.relay3", "I2C3 / Relay 3");
addBooleanVariableReadNode(server, "i2c3.in0", "I2C3 / Digital Input 0");
addBooleanVariableReadNode(server, "i2c3.in1", "I2C3 / Digital Input 1");
addBooleanVariableReadNode(server, "i2c3.in2", "I2C3 / Digital Input 2");
addBooleanVariableReadNode(server, "i2c3.in3", "I2C3 / Digital Input 3");
addUIntegerVariableReadNode(server, "i2c3.ain0", "I2C3 / Analog Input 0");
addUIntegerVariableReadNode(server, "i2c3.ain1", "I2C3 / Analog Input 1");
addUIntegerVariableReadNode(server, "i2c3.ain2", "I2C3 / Analog Input 2");
addUIntegerVariableReadNode(server, "i2c3.ain3", "I2C3 / Analog Input 3");
}
if (length >= 5)
{
// IC2-4
addIntegerVariableNode(server, "i2c4.relay0", "I2C4 / Relay 0");
addIntegerVariableNode(server, "i2c4.relay1", "I2C4 / Relay 1");
addIntegerVariableNode(server, "i2c4.relay2", "I2C4 / Relay 2");
addIntegerVariableNode(server, "i2c4.relay3", "I2C4 / Relay 3");
addBooleanVariableReadNode(server, "i2c4.in0", "I2C4 / Digital Input 0");
addBooleanVariableReadNode(server, "i2c4.in1", "I2C4 / Digital Input 1");
addBooleanVariableReadNode(server, "i2c4.in2", "I2C4 / Digital Input 2");
addBooleanVariableReadNode(server, "i2c4.in3", "I2C4 / Digital Input 3");
addUIntegerVariableReadNode(server, "i2c4.ain0", "I2C4 / Analog Input 0");
addUIntegerVariableReadNode(server, "i2c4.ain1", "I2C4 / Analog Input 1");
addUIntegerVariableReadNode(server, "i2c4.ain2", "I2C4 / Analog Input 2");
addUIntegerVariableReadNode(server, "i2c4.ain3", "I2C4 / Analog Input 3");
}
if (length >= 6)
{
// IC2-5
addIntegerVariableNode(server, "i2c5.relay0", "I2C5 / Relay 0");
addIntegerVariableNode(server, "i2c5.relay1", "I2C5 / Relay 1");
addIntegerVariableNode(server, "i2c5.relay2", "I2C5 / Relay 2");
addIntegerVariableNode(server, "i2c5.relay3", "I2C5 / Relay 3");
addBooleanVariableReadNode(server, "i2c5.in0", "I2C5 / Digital Input 0");
addBooleanVariableReadNode(server, "i2c5.in1", "I2C5 / Digital Input 1");
addBooleanVariableReadNode(server, "i2c5.in2", "I2C5 / Digital Input 2");
addBooleanVariableReadNode(server, "i2c5.in3", "I2C5 / Digital Input 3");
addUIntegerVariableReadNode(server, "i2c5.ain0", "I2C5 / Analog Input 0");
addUIntegerVariableReadNode(server, "i2c5.ain1", "I2C5 / Analog Input 1");
addUIntegerVariableReadNode(server, "i2c5.ain2", "I2C5 / Analog Input 2");
addUIntegerVariableReadNode(server, "i2c5.ain3", "I2C5 / Analog Input 3");
}
if (length >= 7)
{
// IC2-6
addIntegerVariableNode(server, "i2c6.relay0", "I2C6 / Relay 0");
addIntegerVariableNode(server, "i2c6.relay1", "I2C6 / Relay 1");
addIntegerVariableNode(server, "i2c6.relay2", "I2C6 / Relay 2");
addIntegerVariableNode(server, "i2c6.relay3", "I2C6 / Relay 3");
addBooleanVariableReadNode(server, "i2c6.in0", "I2C6 / Digital Input 0");
addBooleanVariableReadNode(server, "i2c6.in1", "I2C6 / Digital Input 1");
addBooleanVariableReadNode(server, "i2c6.in2", "I2C6 / Digital Input 2");
addBooleanVariableReadNode(server, "i2c6.in3", "I2C6 / Digital Input 3");
addUIntegerVariableReadNode(server, "i2c6.ain0", "I2C6 / Analog Input 0");
addUIntegerVariableReadNode(server, "i2c6.ain1", "I2C6 / Analog Input 1");
addUIntegerVariableReadNode(server, "i2c6.ain2", "I2C6 / Analog Input 2");
addUIntegerVariableReadNode(server, "i2c6.ain3", "I2C6 / Analog Input 3");
}
if (length >= 8)
{
// IC2-7
addIntegerVariableNode(server, "i2c7.relay0", "I2C7 / Relay 0");
addIntegerVariableNode(server, "i2c7.relay1", "I2C7 / Relay 1");
addIntegerVariableNode(server, "i2c7.relay2", "I2C7 / Relay 2");
addIntegerVariableNode(server, "i2c7.relay3", "I2C7 / Relay 3");
addBooleanVariableReadNode(server, "i2c7.in0", "I2C7 / Digital Input 0");
addBooleanVariableReadNode(server, "i2c7.in1", "I2C7 / Digital Input 1");
addBooleanVariableReadNode(server, "i2c7.in2", "I2C7 / Digital Input 2");
addBooleanVariableReadNode(server, "i2c7.in3", "I2C7 / Digital Input 3");
addUIntegerVariableReadNode(server, "i2c7.ain0", "I2C7 / Analog Input 0");
addUIntegerVariableReadNode(server, "i2c7.ain1", "I2C7 / Analog Input 1");
addUIntegerVariableReadNode(server, "i2c7.ain2", "I2C7 / Analog Input 2");
addUIntegerVariableReadNode(server, "i2c7.ain3", "I2C7 / Analog Input 3");
}
} }
/* Connect to variables to physical relays /* Connect to variables to physical relays
......
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