🐞 Bug Report
Affected Services [REQUIRED]
The issue is located in: https://github.com/edgexfoundry/device-modbus-go
Is this a regression?
Not as far as I am aware
Description and Minimal Reproduction [REQUIRED]
Connect multiple devices in same serial port and make high frequency requests (still maintain < 3 requests per second) simultaneously (within 1 ms).
This is due to the mutex not considering the scenario of multiple slaves over the same connection.
For the mutex lock key here unitId should not be part of it:
|
func (info *ConnectionInfo) String() string { |
|
if info.Protocol == ProtocolTCP { |
|
return fmt.Sprintf("%s:%s:%d:%d", info.Protocol, info.Address, info.Port, info.UnitID) |
|
} |
|
return fmt.Sprintf("%s:%s:%d:%d:%d:%d:%d:%s", info.Protocol, info.Address, info.Port, info.UnitID, info.BaudRate, info.DataBits, info.StopBits, info.Parity) |
|
} |
IMO perhaps before each request set the unitId in the RTU connection. Also I don't think you can run via different baude rates in same connection.
🔥 Exception or Error
Serial timeouts occasionally happen.
🌍 Your Environment
Deployment Environment: Device connected via direct serial port in /dev/ttyS1 and against RS485 USB adapter via dev/ttyUSB0
EdgeX Version [REQUIRED]: build code from main branch
Anything else relevant?
Originally posted by @sansmoraxz in #666
🐞 Bug Report
Affected Services [REQUIRED]
The issue is located in: https://github.com/edgexfoundry/device-modbus-go
Is this a regression?
Not as far as I am aware
Description and Minimal Reproduction [REQUIRED]
Connect multiple devices in same serial port and make high frequency requests (still maintain < 3 requests per second) simultaneously (within 1 ms).
This is due to the mutex not considering the scenario of multiple slaves over the same connection.
For the mutex lock key here unitId should not be part of it:
device-modbus-go/internal/driver/config.go
Lines 34 to 39 in 2c8c7f3
IMO perhaps before each request set the unitId in the RTU connection. Also I don't think you can run via different baude rates in same connection.
🔥 Exception or Error
Serial timeouts occasionally happen.
🌍 Your Environment
Deployment Environment: Device connected via direct serial port in
/dev/ttyS1and against RS485 USB adapter viadev/ttyUSB0EdgeX Version [REQUIRED]: build code from main branch
Anything else relevant?
Originally posted by @sansmoraxz in #666