Description
I have 2 EthernetIP devices (both TURCK models) with 2 distinct IP addresses. I am able to talk to each of them separately and set bits. But when I try to talk to both of them in the same program, it does not work.
Here is the Connection1 details from the EDS file:
$
[Connection Manager]
Connection1 =
0x04010002, $ 0-15 = supported transport classes
$ --------------------------------------
$ @16 = trigger: cyclic
$ 17 = trigger: change of state
$ 18 = trigger: application
$ 19 = trigger: reserved
$ --------------------------------------
$ 20-23 = trigger: reserved
$ --------------------------------------
$ 24 = transport type: listen-only
$ 25 = transport type: input-only
$ @26 = transport type: exclusive-owner
$ 27 = transport type: redundant-owner
$ --------------------------------------
$ 28-30 = reserved
$ 31 = Client = 0 / Server = 1
$ --------------------------------------
0x44640405, $ @0 = O->T fixed size supported
$ 1 = O->T variable size supported
$ @2 = T->O fixed size supported
$ 3 = T->O variable size supported
$ ---------------------------------------
$ 4-5 = O->T number of bytes per slot (obsolete)
$ 6-7 = T->O number of bytes per slot (obsolete)
$ ---------------------------------------
$ 8-10 = O->T Real time transfer format
$ 11 = reserved
$ --------------------------------------
$ 12-14 = T->O Real time transfer format
$ 15 = reserved
$ --------------------------------------
$ 16 = O->T connection type: NULL
$ 17 = O->T connection type: MULTICAST
$ @18 = O->T connection type: POINT2POINT
$ 19 = O->T connection type: reserved
$ --------------------------------------
$ 20 = T->O connection type: NULL
$ @21 = T->O connection type: MULTICAST
$ @22 = T->O connection type: POINT2POINT
$ 23 = T->O connection type: reserved
$ --------------------------------------
$ 24 = O->T priority: LOW
$ 25 = O->T priority: HIGH
$ @26 = O->T priority: SCHEDULED
$ 27 = O->T priority: reserved
$ --------------------------------------
$ 28 = T->O priority: LOW
$ 29 = T->O priority: HIGH
$ @30 = T->O priority: SCHEDULED
$ 31 = T->O priority: reserved
$ --------------------------------------
,,Assem104, $ O->T RPI, size in bytes, format
,,Assem103, $ T->O RPI, size in bytes, format
,, $ config #1 size in bytes, format
,Assem106, $ config #2 size in bytes, format
"Exclusive Owner", $ Connection Name
"", $ Fixed data size, input inst. 103, output inst. 104
"20 04 24 6A 2C 68 2C 67"; $ Path
Here are the settings that I modified within ImplicitMessagingExample.cpp:
parameters.connectionPath = {0x20, 0x04, 0x24, 0x6A, 0x2C, 0x68, 0x2C, 0x67};
parameters.o2tRealTimeFormat = true;
parameters.originatorVendorId = 501; // VendCode from VIPA EDS.
parameters.originatorSerialNumber = 5038;
parameters.t2oNetworkConnectionParams |= NetworkConnectionParams::P2P;
parameters.t2oNetworkConnectionParams |= NetworkConnectionParams::SCHEDULED_PRIORITY;
parameters.t2oNetworkConnectionParams |= 10;
parameters.o2tNetworkConnectionParams |= NetworkConnectionParams::P2P;
parameters.o2tNetworkConnectionParams |= NetworkConnectionParams::SCHEDULED_PRIORITY;
parameters.o2tNetworkConnectionParams |= 10;
parameters.o2tRPI = 1000000;
parameters.t2oRPI = 1000000;
parameters.transportTypeTrigger |= NetworkConnectionParams::CLASS1;
I modified the ImplictMessagingExample.cpp by wrapping the initialization, open, close, set and get bits into a class and associated functions.
Example:
eipWrapper::EIPWrapper wrapper1("192.168.1.111");
wrapper1.open();
std::this_thread::sleep_for (std::chrono::seconds(3));
eipWrapper::EIPWrapper wrapper2("192.168.1.112");
wrapper2.open();
This does not throw any errors. Output:
[INFO] Registered session 102
[INFO] Send request: service=0x54 epath=[classId=6 objectId=1]
[INFO] Connection state: 0
[INFO] Open IO connection O2T_ID=3494509568 T2O_ID=224198657 SerialNumber 1
[INFO] Open UDP socket to send data to 192.168.1.111:2222
*****
[INFO] Registered session 102
[INFO] Send request: service=0x54 epath=[classId=6 objectId=1]
[INFO] Connection state: 0
[INFO] Open IO connection O2T_ID=3495502080 T2O_ID=224198658 SerialNumber 2
[INFO] Open UDP socket to send data to 192.168.1.112:2222
*****
[INFO] Close connection connection T2O_ID=224198657
[INFO] Send request: service=0x4e epath=[classId=6 objectId=1]
[INFO] Close connection connection T2O_ID=224198658
[INFO] Send request: service=0x4e epath=[classId=6 objectId=1]
[INFO] Unregistered session 102
[INFO] Unregistered session 102
However, when I try to set the 0th bit for one of the devices.
[INFO] Registered session 102
[INFO] Send request: service=0x54 epath=[classId=6 objectId=1]
[INFO] Connection state: 0
[INFO] Open IO connection O2T_ID=3530795776 T2O_ID=779026433 SerialNumber 1
[INFO] Open UDP socket to send data to 192.168.1.111:2222
*****
[INFO] Registered session 102
[INFO] Send request: service=0x54 epath=[classId=6 objectId=1]
[INFO] Connection state: 0
[INFO] Open IO connection O2T_ID=3531788800 T2O_ID=779026434 SerialNumber 2
[INFO] Open UDP socket to send data to 192.168.1.112:2222
*****
[INFO] Received: secNum=2 data=[0][0][0][0][0][0][0][0][0][0]
[INFO] Received: secNum=3 data=[0][0][0][0][0][0][0][0][0][0]
[INFO] Received: secNum=4 data=[0][0][0][0][0][0][0][0][0][0]
[ERROR] Received data from unknown connection T2O_ID=779026434
[WARNING] Connection O2T_ID=3530795776 has fixed size 10 bytes but 0 bytes are to send. Don't send this data.
[INFO] Current bytes before: [0][0][0][0][0][0][0][0][0][0]
[INFO] Current bytes after: [0][0][1][0][0][0][0][0][0][0]
[INFO] data size: 10
[WARNING] Connection SeriaNumber=1 is closed by timeout4100000:4000000
[INFO] Closed
[WARNING] Attempt to close an already closed connection
[INFO] Close connection connection T2O_ID=779026434
[INFO] Send request: service=0x4e epath=[classId=6 objectId=1]
[INFO] Unregistered session 102
[INFO] Unregistered session 102
I tried to launch each device in its own process. I had a bit toggle every second for a second. The moment the second device received the bit, I see this on the first one's log:
[DEBUG] Received data from connection T2O_ID=1703018497
[INFO] Received: secNum=1 data=[0][0][0][0][0][0][0][0][0][0]
[WARNING] Connection SeriaNumber=1 is closed by timeout4099000:4000000
[INFO] Closed
[DEBUG] Close socket fd=4
And the first one stops responding.
Expected behavior
I expect the library to be able to set the bits on each of the devices independently.
Environment (please complete the following information):
- OS: Ubuntu 16.04
- Compiler: GNU Make
- Version 4.1