AdvancedClimateSystems / uModbus

Python implementation of the Modbus protocol.
Mozilla Public License 2.0
211 stars 81 forks source link

Use non privileged tcp port in examples #109

Closed tiagocoutinho closed 3 years ago

tiagocoutinho commented 3 years ago

It would be nice if the examples work out of the box without the user needing access to tcp port 502.

I propose using 15020 in this PR but I could change to something else if you prefer

coveralls commented 3 years ago

Coverage Status

Coverage increased (+0.5%) to 96.267% when pulling 88ea7629a25eacdbc399368404d14d8aa6760c74 on tiagocoutinho:examples-non-privileged-port into 4fd98bab9fe320260b9bc0b0eb5357f043aa6ec3 on AdvancedClimateSystems:master.

OrangeTux commented 3 years ago

Thanks for you suggestion!

I don't like to change to default port of the client, as Modbus server are usually listening to port 502. Changing only the port of the server would make the example server incompatible with the example client. Therefore I also don't want to change the port of the example server.

But I realize it's not very friendly to just let the server crash. Therefore I suggest 2 thinks to make the server more user friendly, but keeping default port at 502.

1) Catch the exception PermissionError, print a user friendly message to the user and exit. 2) Add am option to modify the used port from the command line.

tiagocoutinho commented 3 years ago

Sounds good! Should the README examples be changed as well? Or, for the sake of readability, you prefer to keep them as is?

OrangeTux commented 3 years ago

Please update the README.md as well. I expect that a significant amount of users just copy the code from the README.md. Although I don't have proof to back it up

tiagocoutinho commented 3 years ago

I think it should be ready to review now