pymodbus-dev / pymodbus

A full modbus protocol written in python
Other
2.16k stars 889 forks source link

Update use pyserial RS485 #2205

Open samskiter opened 1 month ago

samskiter commented 1 month ago

Fixes: https://github.com/pymodbus-dev/pymodbus/issues/2204

samskiter commented 1 month ago

Can't get this passing - it seems that serial_for_url is used by this library, but there's no way to use that to produce instances of pyserial's RS485 class. Perhaps the solution is to implement some kind of custom URL scheme for this purpose?

samskiter commented 1 month ago

Open to suggestions - I can't seem to fix it!

janiversen commented 1 month ago

I have no suggestions, the serial library is only used in serial transport and there are no other libraries being used.

serial_for_url is essential for pymodbus since it allows simulating serial communication on a socket, but it's strange if the rs485 do not supply it.

samskiter commented 1 month ago

OK, I think this is actually a bit of an awkward solution, but ultimately the correct thing to do.

The purpose of using the RS485 class is to be able to configure RS485Settings, and without injecting those, I'll have to reach inside pymodbus and grab things I shouldn't to set rs485_mode on the sync_serial client. So I opted to allow these settings to be injected along with us in the commparams - there is precedent for params in there to be unused for some transports (e.g. the port parameter is not used if you have a serial commtype)

I hope this is an acceptable fix

janiversen commented 3 weeks ago

It is easiest to run locally "pytest --cov"

janiversen commented 2 weeks ago

We have for other reasons decided to make a v3.6.9 that will be done this weekend, so I need an updated PR from you if you want it included.