Files
visormesh/palm-client/src/ports.c
T
rich 8a118e4cac palm-client: USB link to the radio via the Visor's HsUd port and a Mac bridge
The Ports screen showed the Neo's Serial Manager drivers, including
'HsUd' (USB, the GENERIC port). The app gets a Serial/USB link switch
(USB default); Query radio retries since the bridge needs a moment to
attach, and SrmSendWait is gone (it can block over USB with no host).
tools/visor_bridge.py (stdlib + libusb via ctypes) finds the GENERIC
port from the Visor's connection info and forwards bytes to the radio's
serial port, logging each companion frame. Ports shows one line per
driver so all of them fit.
2026-11-01 11:32:22 -05:00

70 lines
1.5 KiB
C

/*
* Diagnostics: lists the Serial Manager drivers on this device (creator,
* feature flags, description), to find which one reaches the USB cradle.
*/
#include <PalmOS.h>
#include "resources.h"
#include "ports.h"
#define LINE_H 11
#define FIRST_Y 18
#define MAX_LINES 11 /* header + 10 devices */
static void DrawLine(UInt16 line, const Char *text)
{
WinDrawChars(text, StrLen(text), 2, FIRST_Y + line * LINE_H);
}
static void DrawPorts(void)
{
DeviceInfoType info;
UInt16 count = 0, i, line = 0;
Char buf[48];
Char crid[5];
Err err;
err = SrmGetDeviceCount(&count);
if (err != errNone) {
StrPrintF(buf, "SrmGetDeviceCount err 0x%x", err);
DrawLine(line, buf);
return;
}
StrPrintF(buf, "%u serial device(s):", count);
DrawLine(line++, buf);
for (i = 0; i < count && line < MAX_LINES; i++) {
MemSet(&info, sizeof(info), 0);
err = SrmGetDeviceInfo(i, &info);
if (err != errNone) {
StrPrintF(buf, "%u: err 0x%x", i, err);
DrawLine(line++, buf);
continue;
}
MemMove(crid, &info.serDevCreator, 4);
crid[4] = 0;
StrPrintF(buf, "%u %s %lx ", i, crid, info.serDevFtrInfo);
if (info.serDevPortInfoStr)
StrNCat(buf, info.serDevPortInfoStr, sizeof(buf));
DrawLine(line++, buf);
}
}
Boolean PortsFormHandleEvent(EventType *event)
{
switch (event->eType) {
case frmOpenEvent:
FrmDrawForm(FrmGetActiveForm());
DrawPorts();
return true;
case ctlSelectEvent:
if (event->data.ctlSelect.controlID == PortsDoneButton) {
FrmGotoForm(MainForm);
return true;
}
break;
default:
break;
}
return false;
}