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

Multiple connected clients #96

Open
salasidis opened this issue Jul 13, 2022 · 6 comments
Open

Multiple connected clients #96

salasidis opened this issue Jul 13, 2022 · 6 comments
Labels
topic: documentation Related to documentation for the project type: enhancement Proposed improvement

Comments

@salasidis
Copy link

salasidis commented Jul 13, 2022

The usual code for servicing a clients only works with one connected client at a time.

while (1) {
    
    ethClient = ethServer.available();
    
    if (ethClient) {

        modbusTCPServer.accept(ethClient);

        while (ethClient.connected()) {
          modbusTCPServer.poll();

Is there a correct way (or an example) for how to connect multiple clients to the server at one time.

Thanks

@per1234 per1234 added type: enhancement Proposed improvement topic: documentation Related to documentation for the project labels Jul 18, 2022
@khoih-prog
Copy link

Hi @salasidis

You can try this Async eModbus library I just found out. It's designed for ESP32, but IMO, it's easy to port to other platforms, such as mbed_portenta, ESP8266, arduino-pico, , STM32, etc.

From https://emodbus.github.io/

This is a library to provide Modbus client (formerly known as master), server (formerly slave) and bridge/gateway functionalities for Modbus RTU, ASCII and TCP protocols.

Modbus communication is done in separate tasks, so Modbus requests and responses are non-blocking. Callbacks are provided to prepare or receive the responses asynchronously.

There is a synchronous interface available as well where requests are waiting for their responses to arrive.

I don't have any Modbus experience or equipment, If you'd like to try and are still interested, I can port it to multiple platforms. But you have to do all the tests.

@salasidis
Copy link
Author

I do have a license to modbus Poll, and could buy a license for modbus server if required (from www.modbustools.com).

this is what I use to test my current project's modbus server connection. It would be willing to rewrite my code to add the use of this library to see if I can have multiple poll clients from different sites accessing the software.

I don't have any prewritten software to test the client interface, but presumably we could use the examples o test for that.

@codev123
Copy link

hi @khoih-prog , can you please port emodbus library to rp2040 arduino pico core. i will try to run tests. thank you sir

@codev123

This comment was marked as duplicate.

@codev123
Copy link

hi @salasidis , how did you connect multiple clients to connect to tcp server, please help if if were able to do that.

@salasidis
Copy link
Author

I never did, I limited it to a single client.

@arduino-libraries arduino-libraries locked as too heated and limited conversation to collaborators Oct 13, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
topic: documentation Related to documentation for the project type: enhancement Proposed improvement
Projects
None yet
Development

No branches or pull requests

4 participants