Comments (6)
wrt concurrent access, I'm in the process of adding mutex in the client transporter and fix #16 (expected to be done this week :) )
The client api doesn't have SlaveId in the parameter as using slaveId for TPC is rare. My idea originally is the ability to share the transporter layer among clients, which is like:
h := NewRTUClientHandler()
// Default client
c := NewClient(h)
// Create new Client for different SlaveId
h2 := NewRTUClientHandler()
h2.SlaveId = 2
c2 := NewClient2(h2, h)
May be I can add a helper
func NewClientWithSlaveId(c Client, slaveId int) Client {
// Clone internal packager, set new slaveId and return a new Client with that packager
}
Please let me know if that will resolve your case. (Again, that requires #16 to be fixed)
from modbus.
I think from my point of view, NewClientWithSlaveId(c Client, slaveId int)
does what I need and has the advantage that if I need to defer the creation of clients for other slaves, that I can do so without carrying the handler around.
from modbus.
Prototyping this, I realised that there may be a need to add a Close()
method to the Client interface and also a reference counter in the implementation to allow a Close()
on the underlying handler to be deferred until there are no more references (otherwise this will have to be tracked separately).
update: actually whether there is a need or not, I guess is to some degree a matter of preference. I guess my preference would for applications not having to worry about the lifecycle of handlers, but I can see the alternative argument that if applications have to allocate handlers they should have to deallocate them too.
from modbus.
I don't think Close is needed (like http client). Will send a PR for #16 this weekend so you can see what I mean.
Cheers
from modbus.
I had the same issue - which I solved by setting the Slave
of the RTUClient before sending anything:
https://github.com/gonium/gosdm630/blob/master/src/github.com/gonium/gosdm630/modbus.go#L114
There is no need to Close()
anything. I understand (and appreciate!) @nqv's view to provide a unified API independent of the transport, but for practical applications of the RTU transport, one needs to have a way to set the slave id.
HTH,
-Mathias
from modbus.
Hi,
Thanks for the great library. I don't see any development branch and was wondering if there's any support for concurrent Modbus client or any work done for supporting it ?
Thanks once again,
Aditya
from modbus.
Related Issues (20)
- Error: response transaction id does not match request HOT 2
- Use of the library with Raspberry Pi 3 and a MAX13487E that has AutoDirection Control HOT 1
- reading of holding register limited to 125 bytes HOT 3
- illegal function HOT 1
- Is there something like keep alive flag?
- golang >v.1.16.3 couldn't find package serial
- Write registers in parallel over tcp HOT 1
- write negative value. HOT 1
- Error "too many open files" on ReadHoldingRegisters for RTUClient HOT 1
- SYS_IOCTL (RS485): inappropriate ioctl for device HOT 1
- Why serial: timeout HOT 1
- WriteSingleRegister time out, though Python code works HOT 2
- About the functionFail
- How to tell if server closes the connection?
- Interface{} to modbus-compatible slice conversion
- panic due to concurrent closeIdle and Send()
- Modbus read velocity
- protocol error' on CentOS7 Ubantu20.04
- parity bit not working
- The ReadCoils method returned a value that was not expected
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from modbus.