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

(Modbus TCP)device-modbus-go using multi connections, but real devices support one connection only. #356

Open
zhurichard opened this issue Jun 21, 2022 · 3 comments
Labels
bug Something isn't working help wanted Extra attention is needed

Comments

@zhurichard
Copy link

🐞 Bug Report

Affected Services [REQUIRED]

The issue is located in:

[device-modbus-go](Modbus TCP)

Is this a regression?

No, all versions have the same issue.

Description and Minimal Reproduction [REQUIRED]

Device-modbus-go connects modbus during HandleReadCommands、HandleWriteCommands in driver.go, This will client muti DeviceClient instances.

So that the "connect()" function in tcpclient.go(github.com/goburrow/modbus) be invoked multi times before the previours connection closed.

It is ok for some of the devices which have ability of muti tcp connections, but lot of others only support one tcp connection. that will get error showing in Exception section.

Hope this can be solved. At least to give one setting to config to use one tcp connection or muti tcp connections. May be it has the functionality already, but I don't know?

🔥 Exception or Error




code: 500 , message: request failed, status code: 500, err: {"apiVersion":"v2","message":"error reading DeviceResourece TemperatureTop for TCP-Temperature-Humidity -\u003e dial tcp 192.168.1.17:502: connect: connection refused","statusCode":500}

🌍 Your Environment

Deployment Environment:
raspiberry pi 4

EdgeX Version [REQUIRED]:
all versions

Anything else relevant?

@zhurichard zhurichard added the bug Something isn't working label Jun 21, 2022
@weichou1229
Copy link
Member

weichou1229 commented Jun 21, 2022

The device-modbus-go already implemented that by using the lock, please check whether the device is connectable, or the device does not accept the high-frequency requests.

err = d.lockAddress(d.lockableAddress(connectionInfo))

@zhurichard
Copy link
Author

The device-modbus-go already implemented that by using the lock, please check whether the device is connectable, or the device does not accept the high-frequency requests.

err = d.lockAddress(d.lockableAddress(connectionInfo))

Test Device 1: (192.168.1.17 - Support one tcp connection)

  • Open first Modbus Poll, and reading data properly.
    1
  • Open the second Modbus Poll, and cannot connect.
    2
  • Use device-modbus-go to test this device. If the second reading after the first connection idle timeout, then the second connection is ok. If the second reading before the first connection idle timeout, then the second connection refused. See the logs below:
    3
    From above testing, I assume Device 1 is working. And can read frequency. And only support one tcp connection.

Test Device 2: (192.168.1.7 - Support multi tcp connections)

  • Open 3 modbus Polls, and reading data properly.
    4
  • Use device-modbus-go to test Device 2. I submit 3 reading command in very shot time, and reading data properly, and close 3 connections after idle timeout.
    5
    From above testing, I assume Device 2 is working. And support multi tcp connections. And device-modbus-go open multi tcp connections to read data.

What I need is to set the connection count - 1 or mutiple to connect devices with different tcp capibility.
I saw that address lock source code, but it seems not able to lock the tcp connections.

@cloudxxx8 cloudxxx8 added the help wanted Extra attention is needed label Jun 22, 2022
@jiekechoo
Copy link

You could add a secondary ip address in modbus slave. In my test, there are 200 ip address in slave.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working help wanted Extra attention is needed
Projects
Status: Icebox
Development

No branches or pull requests

4 participants