-
Notifications
You must be signed in to change notification settings - Fork 977
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update use pyserial RS485 #2205
Conversation
I think this is a fix of the tests?
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? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems your fix breaks quite a number of tests, please fix.
Open to suggestions - I can't seem to fix it! |
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. |
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 I hope this is an acceptable fix |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Minor details, the only bigger thing is your use (or not use) of comm_params.
We are in the process of preparing v3.7.0 so if you hurry this PR can be part of 3.7.0
It is easiest to run locally "pytest --cov" |
@@ -15,6 +15,7 @@ | |||
|
|||
try: | |||
import serial | |||
from serial.rs485 import RS485Settings |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is already imported in the line above, do not import twice.
@@ -8,25 +8,36 @@ | |||
|
|||
with contextlib.suppress(ImportError): | |||
import serial | |||
import serial.rs485 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is already imported in the line above.
@@ -58,6 +58,8 @@ | |||
from functools import partial | |||
from typing import Any | |||
|
|||
from serial.rs485 import RS485Settings |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What happens if serial is not installed ?? Please import as serial is imported in other places.
@@ -7,6 +7,7 @@ | |||
|
|||
import pytest | |||
import serial | |||
from serial.rs485 import RS485Settings |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Already imported in the line above, please do not import twice.
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. |
Still working on this ? |
I have a personal project where I write a new software for already existing hardware with RS485 transceiver, but it is based on an AllWinner H3 SBC, where hardware flow control doesn't work very well, but I need to control RTS pin to control the transceiver's direction. So I really would like to have this feature merged, but (with all due respect to @samskiter) I don't think this is implemented properly. SerialTransport adapts a non-asyncio Also there's no guarantee that the async writer is going to call the callback only once per That's why the optional software RTS control should be implemented directly in the |
In general I agree with your arguments, we have over time had many problems with serial, a lot because it is no longer actively maintained. We have been thinking of changing serial to another library, but never got time to actually do it. I would however like to see a good RS485 integration! and e.g. enhac3 the transport layer to control RTS would also be welcomed. So in short, and since this PR looks abandoned, I hope you will submit your ideas as a PR. |
I think RTS control can be implemented in the current serial transport, with an extra parameter to turn it on. The best way would be to make a PR that implement it in serial transport with test, and a second that add the parameter to comm_params and the client/server api. |
Sorry for my delays, I will try and get this pr over the line!
…On Thu, 25 Jul 2024, 16:43 jan iversen, ***@***.***> wrote:
I think RTS control can be implemented in the current serial transport,
with an extra parameter to turn it on.
The best way would be to make a PR that implement it in serial transport
with test, and a second that add the parameter to comm_params and the
client/server api.
—
Reply to this email directly, view it on GitHub
<#2205 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAJWOWZUT4AGRFLDJ7K6FO3ZOEML3AVCNFSM6AAAAABILVM376VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDENJQG4ZTINBYGY>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
@samskiter good luck, please resolve the conflicts first and then have a close look at the comments from @yawor which I think have a lot of merit. Ohh and do not forget the review comments I made. |
This PR is stale because it has been open 45 days with no activity. Remove stale label or comment or this will be closed in 10 days. |
This PR was closed because it has been stalled for 10 days with no activity. |
So it appears pyserial also has some native rs485 support that AFAIU would avoid these issues, reworked this a bit to use that instead in #2460. |
Fixes: #2204