Chapter 10: Communications: Infrared Beaming, Serial Ports, and HotSync

This is an LLM ass-isted document, as are all in the ass/ subdirectory.
Of these, here in the dump/ subdirectory I keep the sloppy & doubtful ones.
I keep these as learning materials for myself, yet to be went thru.

Return to index

1. Physical Connectivity on the Palm Platform

A signature strength of Palm handhelds was their ability to communicate seamlessly across diverse physical channels:

  1. Infrared Beaming (IrDA): Instant point-to-point wireless sharing between handhelds.
  2. RS-232 / UART Serial: Direct hardware connectivity to modems, GPS receivers, and external microcontrollers.
  3. HotSync: Fast synchronization between the desktop computer and the device's storage databases.

2. 1. The Exchange Manager & Infrared Beaming (IrDA)

Starting with Palm OS 3.0, the Exchange Manager (ExgMgr) unified all data transmission mechanisms into a high-level URL-like protocol. Whether data is sent over Infrared (_beam), Bluetooth (_bt), or SMS, applications use the identical exchange API.

2.1. Beaming a Record via C++

To beam a record or memo to another Palm device:

using UInt16 = unsigned short;
using UInt32 = unsigned long;
using Err = short;

struct ExgSocketType {
    UInt16 libraryRef;
    UInt32 socket;
    UInt32 target;
    UInt32 count;
    UInt32 length;
    UInt32 time;
    UInt32 appData;
    const char* description;
    const char* type;
    const char* name;
    // ...
};

extern "C" {
    Err ExgPut(ExgSocketType* socketP);
    UInt32 ExgSend(ExgSocketType* socketP, const void* bufP, UInt32 bufLen, Err* errP);
    Err ExgDisconnect(ExgSocketType* socketP, Err error);
}

bool BeamTextMemo(const char* title, const char* body, UInt32 bodyLen) {
    ExgSocketType socket = {};
    socket.description = title;
    socket.name = "memo.txt";
    socket.length = bodyLen;
    socket.target = 'memo'; // Memo Pad creator ID

    // Initiate the connection (system shows "Preparing to Beam..." dialog)
    Err err = ExgPut(&socket);
    if (err != 0) return false;

    // Stream the data chunks
    Err sendErr = 0;
    ExgSend(&socket, body, bodyLen, &sendErr);

    // Close the connection
    ExgDisconnect(&socket, sendErr);
    return sendErr == 0;
}

2.2. Receiving Beamed Data

When another device beams data with your application's Creator ID or MIME type:

  1. The Palm OS launcher intercepts the beam and starts your application with launch code sysAppLaunchCmdExgReceiveData.
  2. In PilotMain, you call ExgAccept(&socket) and stream the incoming bytes using ExgReceive(&socket, buf, maxLen, &err).

3. 2. The Serial Manager: Hardware Interfacing & BLE Bridges

Classic Palm devices feature an RS-232 UART interface routed through the bottom dock connector. The Serial Manager (SrmOpen, SrmSend, SrmReceive) controls the UART hardware directly.

3.1. Opening the Serial Port (e.g. for ESP32 BLE bridges)

extern "C" {
    Err SrmOpen(UInt32 port, UInt32 baudRate, UInt16* portIdP);
    Err SrmClose(UInt16 portId);
    UInt32 SrmSend(UInt16 portId, const void* bufP, UInt32 count, Err* errP);
    UInt32 SrmReceive(UInt16 portId, void* bufP, UInt32 count, Int32 timeout, Err* errP);
}

class SerialConnection {
    UInt16 portId_ = 0;
    bool isOpen_ = false;

public:
    bool Connect(UInt32 baudRate = 9600) {
        // sysFileCUart328 = 4-character creator for DragonBall UART
        UInt32 uartPort = 'u328';
        Err err = SrmOpen(uartPort, baudRate, &portId_);
        isOpen_ = (err == 0);
        return isOpen_;
    }

    void Send(const char* msg, UInt32 len) {
        if (!isOpen_) return;
        Err err = 0;
        SrmSend(portId_, msg, len, &err);
    }

    UInt32 Read(char* buffer, UInt32 maxLen, Int32 timeoutTicks) {
        if (!isOpen_) return 0;
        Err err = 0;
        return SrmReceive(portId_, buffer, maxLen, timeoutTicks, &err);
    }

    ~SerialConnection() {
        if (isOpen_) {
            SrmClose(portId_);
        }
    }
};

This class provides instant serial connectivity to Arduino, ESP32, Raspberry Pi, or GPS units directly from your Palm C++ app!

4. 3. HotSync Conduits and Inter-Application Communication

4.1. HotSync Conduits

HotSync connects the handheld to a desktop host via USB or Serial:

  • Desktop Conduits: DLLs or shared libraries running on the desktop host that query the handheld's database using the Desktop Link Protocol (DLP).
  • Today, open-source tools like Pilot-Link (pilot-xfer, install-user, read-todos) provide full CLI conduits on modern Linux:

    # Backup all databases from physical Palm to Linux host over USB/serial
    pilot-xfer -p /dev/ttyUSB0 -b ~/palm-backup/
    # Install a PRC
    pilot-xfer -p /dev/ttyUSB0 -i Gpp14Modern.prc
    

4.2. Inter-Application Calls: SysAppLaunch

On Palm OS, one application can invoke another application or query its data directly:

extern "C" {
    Err SysAppLaunch(UInt16 cardNo, UInt32 dbID, UInt16 launchFlags,
                     UInt16 cmd, void* cmdPBP, UInt32* resultP);
}

// Example: Ask the system Calculator to launch or compute a result
void LaunchCalculator() {
    // Find Calculator database in storage heap
    UInt32 calcCreator = 'calc';
    // Invoke with normal launch flags
    // ...
}

5. Further Reading & Reference Resources