palm-client: a reconnect in steps is lighter on the app: reads that can't wait check what's buffered first (SrmReceiveCheck), steps 4 times a second instead of 10, its DEVICE_QUERY send waits 100 ms instead of 250

This commit is contained in:
rich committed 2026-11-04 09:45:55 -05:00
1 parent b5ce1098b3
commit 453559cd5c
3 files changed
+14 -3

No files matched your search

+1 -1
View File
@@ -122,7 +122,7 @@ static Boolean gWantConnection = false; /* we were connected when the Visor sl
* later (8.5 min in all).
*/
#define VM_RETRIES 8
#define VM_STEP_TICKS (SysTicksPerSecond() / 10)
#define VM_STEP_TICKS (SysTicksPerSecond() / 4)
static UInt32 gRetryAt = 0; /* ticks; 0: no retry due */
static UInt16 gRetries = 0;
+1 -1
View File
@@ -45,7 +45,7 @@ void SessionDisconnect(void);
/*
* A connect in steps, so the app keeps running while it finds the radio
* (reconnects after a wake or a lost link). Start opens the link; then call
* Step every tenth of a second or so until it returns something other than
* Step a few times a second until it returns something other than
* vmErrPending: errNone once connected and synced, or the error (link
* closed). SessionConnect or SessionDisconnect abandons it.
*/
+12 -1
View File
@@ -4,6 +4,7 @@
#define VM_BAUD 115200
#define VM_SEND_TRIES 8 /* SrmSend attempts for one buffer (USB re-attach) */
#define VM_SEND_WAIT (SysTicksPerSecond() / 4) /* each: 2 s in all */
#define VM_ONCE_WAIT (SysTicksPerSecond() / 10) /* TransportSendOnce */
static UInt16 gPortId;
static Boolean gPortOpen = false;
@@ -81,13 +82,20 @@ Err TransportSend(const UInt8 *buf, UInt16 len)
Err TransportSendOnce(const UInt8 *buf, UInt16 len)
{
Int32 wait = VM_ONCE_WAIT;
UInt16 size = sizeof(wait);
UInt32 sent;
Err err = errNone;
if (gPort == VM_PORT_SBLORA)
return SbTransportSend(buf, len);
if (!gPortOpen)
return serErrNotOpen;
if (SrmSend(gPortId, (void *)buf, len, &err) == len)
SrmControl(gPortId, srmCtlSetCtsTimeout, &wait, &size);
sent = SrmSend(gPortId, (void *)buf, len, &err);
wait = VM_SEND_WAIT;
SrmControl(gPortId, srmCtlSetCtsTimeout, &wait, &size);
if (sent == len)
return errNone;
SrmClearErr(gPortId);
return err != errNone ? err : serErrTimeOut;
@@ -106,6 +114,9 @@ UInt16 TransportRecv(UInt8 *buf, UInt16 max, Int32 timeoutTicks, Err *errP)
return 0;
}
/* without waiting: only if something's there (a read that can't wait still costs the USB driver time) */
if (timeoutTicks == 0 && (SrmReceiveCheck(gPortId, &avail) != errNone || avail == 0))
return 0;
/* Block for the first byte, then take whatever else is already buffered. */
n = SrmReceive(gPortId, buf, 1, timeoutTicks, errP);
if (n == 0) {