Closed schotime closed 2 years ago
Thanks for your PR, this is a good improvement! I had to change your PR a little bit because in the Connect
method you were closing the old port depending on if the current port is internal or not. There will be an old port if you call connect multiple times. That is why I moved the field to the ModbusRtuSerialPort
class. I have also added some more doc strings.
I will merge the PR right now and make more changes in other parts of the library and then release the final v4 version so that is gets out of the preview status.
Yeh, awesome. Thanks. It might be good to have this for TCP (pass in the TcpClient) as well. Maybe less important if a modbus server accepts multiple tcp clients but still maybe worth having that option?
I thought it was already possible but I confused it with the Modbus TCP Server. I will add that option tomorrow :-)
There are situations where having the serial port be managed externally is really beneficial, such as sharing of said serial port on a bus.
This PR allows you to pass in an external ModbusRtuSerialPort such that the underlying SerialPort can be managed.
Let me know if you need changes, or I've missed something. Great library!