-
Notifications
You must be signed in to change notification settings - Fork 122
Prevent FTDI Reset on Serial Open/Close (Raspberry Pi OS) #779
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
base: main
Are you sure you want to change the base?
Prevent FTDI Reset on Serial Open/Close (Raspberry Pi OS) #779
Conversation
rickwierenga
left a comment
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.
very interesting find!
|
|
||
| # --- FIX: Prevent FTDI reset on open/close (critical for Inheco on Raspberry Pi) --- |
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.
we should avoid machine specific comments in the io layer
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.
I agree - but the io layer is where these commands have to be set in the right chronological order it seems?
One way we could get around this is by having an attribute for this in the io layer, default to None, i.e. leaving out this new code section, and have the backend provide the attribute if needed?
But in this scenario, I was wondering whether this is a truly unique IIS+Raspian combo or whether other machines might erroneously disconnect to the control PC too;
if others are doing the same, and this change provides no down-sides, it should be permanently added to the io I believe - just a couple of big ifs 😅
| # Some pyserial versions require direct attribute access: | ||
| self._ser.dtr = False | ||
| self._ser.rts = False | ||
|
|
||
| # Others only respect the explicit setter: | ||
| self._ser.setDTR(False) | ||
| self._ser.setRTS(False) |
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.
do you know which versions these are?
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.
Unfortunately I do not - this is all very new to me
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.
ok but where did you notice you have to use one or the other? is one even supported on platforms where the other isn't?
|
I would prefer to have explicit Do you actually need to set rts to false? The serial object is already initialized with it disabled. We don't yet pass the |
|
I do not know why it is needed at exactly this location - I can test on Monday all permutations: [dtr/rts] x [true/false] x [ attribute/setter] to see which ones do and which ones do not trigger this error. It seemed to me that self._ser = await loop.run_in_executor(self._executor, _open_serial)...might be resetting any previous states? and hence we need to set dtr and rts right afterwards? Really not sure about this though - but can be figured out with step by step testing :) |
The Problem
When using the Inheco Incubator Shaker (IIS) on a Raspberry Pi I noticed the following issue:
When I use a Jupyter notebook with the IIS it works very well, but when restarting the kernel not only is the IIS not found but the actual port has disappeared completely!
Chat thinks:
This is confirmed by my system logs:
-> even though the cable never moved!
Note: I never saw this behaviour when using the IIS on a Mac - this might be specific to RPi Linux (Raspian)...
PR Content
This patch changes the behavior of PyLabRobot's Serial class so that after the serial port is opened, the following commands are applied:
This ensures that the FTDI driver does not toggle the DTR or RTS lines when opening or closing the serial port.
By doing this:
/dev/ttyUSB1Please let me know whether you can see any issue that this might cause for other machines or other OSs.