From f9aa7a1e93c03be8605c056236d21c2c8e3bb1ee Mon Sep 17 00:00:00 2001 From: "Rich O." Date: Wed, 4 Nov 2026 09:31:52 -0500 Subject: [PATCH] palm-client: serial sends wait 250 ms at a time (8 tries, 2 s) instead of the 5 s CTS default, so a connect with nothing reading at the other end (bridge stopped) can't freeze the app for over a minute --- palm-client/src/transport_srm.c | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/palm-client/src/transport_srm.c b/palm-client/src/transport_srm.c index e524d6e..85f97ca 100644 --- a/palm-client/src/transport_srm.c +++ b/palm-client/src/transport_srm.c @@ -2,7 +2,8 @@ #include "transport.h" #define VM_BAUD 115200 -#define VM_SEND_TRIES 5 /* SrmSend attempts for one buffer (USB re-attach) */ +#define VM_SEND_TRIES 8 /* SrmSend attempts for one buffer (USB re-attach) */ +#define VM_SEND_WAIT (SysTicksPerSecond() / 4) /* each: 2 s in all */ static UInt16 gPortId; static Boolean gPortOpen = false; @@ -20,16 +21,26 @@ UInt32 TransportGetPort(void) Err TransportOpen(void) { + Int32 wait = VM_SEND_WAIT; + UInt16 size = sizeof(wait); Err err; if (gPort == VM_PORT_SBLORA) return SbTransportOpen(); if (gPortOpen) return errNone; + err = SrmOpen(gPort, VM_BAUD, &gPortId); - if (err == errNone) - gPortOpen = true; - return err; + if (err != errNone) + return err; + gPortOpen = true; + /* + * With nothing reading at the other end (the bridge stopped), each SrmSend + * waits out the CTS timeout, 5 s by default: a connect froze for over a + * minute. Short waits let the session look for the user between tries. + */ + SrmControl(gPortId, srmCtlSetCtsTimeout, &wait, &size); + return errNone; } void TransportClose(void)