This PR exposes packers and transporters. It does not modify existing api:
make packager/transporter fields public members of client handlers
add New*Transporter methods
Notes on implementation:
Use of public fields in the exposed client requires exposing the package/transporter types. With private members, the types returned by the New*Transporter methods would be "annoying" for the linter.
There is one open inconsistency with the current approach: while serial transports hide the serial port as implementation detail, the *TCP transports expose the underlying TCP transport. That can be changed, if desired consistently for both cases.
exposing TCPTransporter (which is an implementation detail) as part of the ASCII/RTUOverTCP transporters is unfortunate but required to keep the public fields visible.
serial transporters Printf() method was removed- it seems unused (will split into separete PR)
TODO
[ ] pointer receiver for serial transport is necessary to avoid copying of lock in serial port
[ ] consistently make all transports pointer receivers
[ ] decide if same is desired for packagers
[ ] decide future of rtu/ascii Printf() public api. With making serialTransport public, the transport's logger should be used instead. Proposal: remove Printf() (potential though minor BC break).
Fix https://github.com/grid-x/modbus/issues/56
This PR exposes packers and transporters. It does not modify existing api:
New*Transporter
methodsNotes on implementation:
New*Transporter
methods would be "annoying" for the linter.TCPTransporter
(which is an implementation detail) as part of theASCII/RTUOverTCP
transporters is unfortunate but required to keep the public fields visible.Printf()
method was removed- it seems unused (will split into separete PR)TODO
Printf()
public api. With makingserialTransport
public, the transport's logger should be used instead. Proposal: removePrintf()
(potential though minor BC break).Alternatives:
Add a
Clone()
method that clones the entire client handler, sharing the underlying transport https://github.com/grid-x/modbus/pull/70.Maybe think about something like: