Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Simulating delay in modbus-flex-server #460

Open
niranjanshukla opened this issue May 3, 2024 · 3 comments
Open

Simulating delay in modbus-flex-server #460

niranjanshukla opened this issue May 3, 2024 · 3 comments
Assignees
Labels
community could be done by the community contribution server only

Comments

@niranjanshukla
Copy link

Describe the requested feature

This is more of a question for now, on how to simulate a delay i n modbus-flex-server.

I have modified the underlying library @open-p4nr/modbus-serial/servers/servertcp.js and added a delay in sending a response

sock.on("data", function(data) {
 ...
setTimeout(
                        _parseModbusBuffer.bind(this,
                            requestBuffer,
                            vector,
                            serverUnitID,
                            sockWriter,
                            options
                        ),
                    **360**
                    );
}

The issue is, even as I add the above change, and when I connect modbus-flex-getter to modbus-flex-server, modbus flex server ends up sending less number of response objects than it would, if there were no delay set above.

So it looks like the TCP connection is alive only for a certain time. Where may I possibly find the parameter in modbus-flex-server.js / modbus-flex-getter.js or in one of the core modules to increase the connection alive time, so all responses are sent with the above delay?

(On that note, my initial approach was to utilise the responseDelay node param in Flex Server node, but in its implementation, modbus-flex-server.js initialises but never used responseDelay).

Motivation

Simulating a delay in modbus flex server response

@biancode biancode added contribution community could be done by the community server only labels May 4, 2024
@biancode
Copy link
Contributor

biancode commented May 4, 2024

The package has a split for that and we keep you informed. Give us the chance to switch the vm2 to another first.

@niranjanshukla
Copy link
Author

niranjanshukla commented May 5, 2024

Thanks @biancode . On a related issue, I have a question - Are multiple modbus-Flex-Server nodes supported in the same flow (and multiple modbus-flex-getter nodes in another flow, reading from those servers)? In my workspace, when I try the following configuration, I do not receive a response on the second modbus-flex-getter node.

Flow 1:
modbus-flex-connector1 > modbus-flex-getter1 (using modbus client for server 0.0.0.0, port 502)
modbus-flex-connector2> modbus-flex-getter2(using modbus client for server 0.0.0.0, port 503) [no response is received here]

Flow 2:
modbus-flex-connector1 > modbus-flex-witer1 (using modbus client for server 0.0.0.0, port 502) + modbus-flex-server1 (serving on host 0.0.0.0, port 502)
modbus-flex-connector2> modbus-flex-writer2(using modbus client for server 0.0.0.0, port 503) + modbus-flex-server2 (serving on host 0.0.0.0, port 503)

When I see Flow 2, I observe both flex writer nodes writing to addresses. But when I see Flow 1, I do not observe flex-getter2 receiving any response.

@biancode
Copy link
Contributor

multiple servers should not be a problem if the port is different you can run multiple servers of both existing servers in the package - maybe our new book can help you more see https://leanpub.com/p4nr-contribution-modbus

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
community could be done by the community contribution server only
Projects
None yet
Development

No branches or pull requests

3 participants