Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions pylabrobot/io/serial.py
Original file line number Diff line number Diff line change
Expand Up @@ -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) ---
Comment on lines +187 to +188
Copy link
Member

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

Copy link
Collaborator Author

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 😅

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
Copy link
Member

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?

Copy link
Collaborator Author

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

Copy link
Member

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?


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):
Expand Down