-
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?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -183,6 +183,22 @@ def _open_serial() -> serial.Serial: | |
| self._executor = None | ||
| raise e | ||
|
|
||
| assert self._ser is not None | ||
|
|
||
| # --- FIX: Prevent FTDI reset on open/close (critical for Inheco on Raspberry Pi) --- | ||
| try: | ||
| # 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) | ||
|
Comment on lines
+190
to
+196
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. do you know which versions these are?
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Unfortunately I do not - this is all very new to me
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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? |
||
|
|
||
| logger.info(f"[{candidate_port}] Disabled FTDI DTR/RTS (prevent USB disconnect).") | ||
| except Exception as e: | ||
| logger.warning(f"[{candidate_port}] Could not disable DTR/RTS: {e}") | ||
|
|
||
| self._port = candidate_port | ||
|
|
||
| async def stop(self): | ||
|
|
||
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 😅