Cube67 doesn't send UDP packet after forward open
tpcorrea opened this issue · 1 comments
Hi, everyone,
first of all, thank you for sharing this library and sorry for putting this issue as a bug, it is question (or a cry for help). ;-)
I am trying to use the library to communicate via implicit messages with a MUR Cube67 device. My starting point was the implicit message example. The first issue I head was to proper set the parameters, but then I found in one issue how to use 8 bits path and it worked well. So the forward open command was successful, but I don't get any UDP messages from the device. What could be the reason?
I understand that the last ENIP message is to close the connection, but I am not sure if this is really the case. This is the console output:
Here is my main.cpp file:
#include <sstream>
#include <cip/connectionManager/NetworkConnectionParams.h>
#include "SessionInfo.h"
#include "ConnectionManager.h"
#include "utils/Logger.h"
#include "utils/Buffer.h"
using namespace eipScanner::cip;
using eipScanner::SessionInfo;
using eipScanner::MessageRouter;
using eipScanner::ConnectionManager;
using eipScanner::cip::connectionManager::ConnectionParameters;
using eipScanner::cip::connectionManager::NetworkConnectionParams;
using eipScanner::utils::Buffer;
using eipScanner::utils::Logger;
using eipScanner::utils::LogLevel;
const uint16_t t2oSize = 52;
const uint16_t o2tSize = 10;
int main() {
Logger::setLogLevel(LogLevel::DEBUG);
auto si = std::make_shared<SessionInfo>("10.254.0.31", 0xAF12);
// Implicit messaging
ConnectionManager connectionManager;
ConnectionParameters parameters;
parameters.priorityTimeTick = 3;
parameters.timeoutTicks = 250;
parameters.connectionTimeoutMultiplier = 1;
parameters.connectionPath = {0x20, 0x04, 0x24, 0x80, 0x2C, 0x70, 0x2C, 0x64}; //
parameters.o2tRealTimeFormat = true;
parameters.originatorVendorId = 505;
parameters.originatorSerialNumber = 0x1234;
// parameters.t2oNetworkConnectionParams = NetworkConnectionParams::REDUNDANT;
parameters.t2oNetworkConnectionParams |= NetworkConnectionParams::P2P;
parameters.t2oNetworkConnectionParams |= NetworkConnectionParams::SCHEDULED_PRIORITY;
parameters.t2oNetworkConnectionParams |= t2oSize; //size of Assm100 =32
parameters.o2tRPI = 10000; //us
// parameters.o2tNetworkConnectionParams = NetworkConnectionParams::REDUNDANT;
parameters.o2tNetworkConnectionParams |= NetworkConnectionParams::P2P;
parameters.o2tNetworkConnectionParams |= NetworkConnectionParams::SCHEDULED_PRIORITY;
parameters.o2tNetworkConnectionParams |= o2tSize; //size of Assm150 = 32
parameters.t2oRPI = 10000; //us
parameters.transportTypeTrigger |= NetworkConnectionParams::CLASS1;
parameters.transportTypeTrigger |= NetworkConnectionParams::TRIG_CYCLIC;
auto io = connectionManager.forwardOpen(si, parameters);
if (auto ptr = io.lock()) {
ptr->setDataToSend(std::vector<uint8_t>(o2tSize));
ptr->setReceiveDataListener([](auto realTimeHeader, auto sequence, auto data) {
std::ostringstream ss;
ss << "secNum=" << sequence << " data=";
for (auto &byte : data) {
ss << "[" << std::hex << (int) byte << "]";
}
Logger(LogLevel::INFO) << "Received: " << ss.str();
});
ptr->setCloseListener([]() {
Logger(LogLevel::INFO) << "Closed";
});
}
int count = 200;
while (connectionManager.hasOpenConnections() && count-- > 0) {
connectionManager.handleConnections(std::chrono::milliseconds(5000));
}
connectionManager.forwardClose(si, io);
return EXIT_SUCCESS;
}
´´´
Can someone give me an insight how to solve this?
Thanks a lot and BR,
Tomas
Hi, everyone. Well, I figured out the problem. I was testing the library using Windows/WSL2 and it turns out that the virtual WSL2 Ethernet adapter doesn't receive UDP packets. Running in a native linux solved the issue and now it is working like a charm.