goburrow/modbus

Feature request: ability to set unit id on a request by request basis

wz2b opened this issue · 3 comments

wz2b commented

I have a gateway with multiple "slave" (we should rename that "unit") devices attache. Need to be able to specify slave addr per call, rather than changing the per connection SlaveID which works but raises potential concurrency problems.

Just thinking out loud, would setting handler.rtuPackager.SlaveId / handler.SlaveId just before the operation help? https://github.com/grid-x/modbus/blob/master/rtuclient.go has SetSlave function.

pxnky commented

Just thinking out loud, would setting handler.rtuPackager.SlaveId / handler.SlaveId just before the operation help? https://github.com/grid-x/modbus/blob/master/rtuclient.go has SetSlave function.

Then you have to keep the handler around through all the rest of the code. This seems like a very basic feature, I don't understand why the assumption (seems to be) that you only set it once.