saturnus docs
Open the app

Kermit and XModem

The HP calculators move files over their serial port with Kermit, a protocol from Columbia University. The 48G series, the 49G and the 39G and 40G also speak XModem. Both sides need the same speed and the same transfer mode; most failed transfers come from a mismatch there.

Which calculator speaks which

ModelKermitXModemWho starts a transfer
HP 48S, 48SXyes, with a servernothe computer, with the calculator in SERVER
HP 48G, 48G+, 48GXyes, with a serverXSEND and XRECV: 128-byte blocks, checksum, binary onlyeither
HP 49Gyes, with a server128-byte and 1 KB blocks, checksum or CRCeither
HP 38Gas a client onlynothe calculator, SEND and RECV
HP 39G, 40Gas a client onlyfor binary apletsthe calculator
HP 42S, 27S, 17B, 17BII, 19BII, 28Sno serial port

Kermit

Bill Catchings and Frank da Cruz designed Kermit at Columbia University in 1981. A packet is short and made of printable characters, apart from its start mark:

FieldWhat it holds
MARKCtrl-A, the start of a packet
LENthe length of the rest, as a character
SEQthe packet's number, 0 to 63
TYPEone letter: S to start, F for a file name, D for data, Z for end of file, B for end of the batch, Y and N for yes and no, E for an error
DATAthe bytes, with control characters written as # and a letter
CHECKa check over the packet: one character (type 1), two (type 2) or a 16-bit CRC in three (type 3)

Every packet is answered with Y (received) or N (send again) before the next one goes. The two sides agree on the packet length, the timeout and the check type in the first exchange.

Kermit on the HP calculators

Server and client

A Kermit server waits for commands and does what the other side asks: send a file, take a file, list a directory, run a command. The client gives the commands.

The 48 and 49G are best run as servers, with the computer as the client. The Kermit Project's hints for the HP 48 say the 48's own client commands, such as REMOTE DIRECTORY, are not reliable. To start the server:

ModelKeys
HP 48S, 48SXtype SERVER and press ENTER
HP 48G seriesright-shift, then → (the right arrow)
HP 49Gright-shift and → quickly, without a pause; with a pause they start the XModem server

The display then says "Awaiting Server Cmd.". The server also runs a command sent from the computer and returns the stack.

The 38G, 39G and 40G work the other way round. They have no server: the calculator is the client, and the computer plays the "disk drive" it expects, keeping aplets in one folder. You choose SEND or RECV in the Aplet Library on the calculator, then "Disk drive…". Files in the app can be that disk drive.

Binary and ASCII

The calculator sends a variable in one of two forms. System flag −35 chooses which: set for binary, clear for ASCII. On the 48G series, FMT in the TRANSFER form sets the same thing.

Binary is the object as it sits in memory, after a header of 8 characters: HPHP48- and the ROM's letter on a 48, HPHP49- and a letter on a 49G. It is exact and faster. Both sides must treat the file as binary. A computer that converts line ends in a binary file damages it; the calculator then receives a string that starts with HPHP48- instead of the object. The FAQ lists small programs that repair such strings.

ASCII is the object as text, as the calculator shows it in the editor. On sending, the calculator turns the object into text and adds a header such as %%HP: T(3)A(D)F(.);. On receiving, it turns the text back into an object, packet by packet, so a syntax error stops the transfer at once. That also means an arbitrary text file cannot be received in ASCII mode.

The header records three settings, so that the text reads back the same:

LetterSettingValues
Tthe translation mode0 to 3, below
Athe angle modeD degrees, R radians, G grads
Fthe fraction mark. or ,

A file with a fraction mark other than the calculator's gives "Invalid Syntax".

Translation modes

The translation mode says what happens to line ends and to the calculator's own characters, such as →, « » and Σ:

ModeCalculator to computerComputer to calculator
0nothing translatednothing translated
1a line end becomes CR LFCR LF becomes a line end
2as 1, and characters 128 to 159 become codes like \->as 1, and the codes become characters
3as 1, and all characters 128 to 255 become codesas 1, and all codes become characters

Mode 1 is the default, mode 3 the safest for editing on a computer. A binary transfer is never translated.

The settings: IOPAR

The calculator keeps its I/O settings in a list in the variable IOPAR in HOME, created the first time they are used. Deleting it brings back the defaults.

EntrySettingValuesDefault
1speed1200, 2400, 4800, 96009600
2parity0 none, 1 odd, 2 even, 3 mark, 4 space; negative to send it but not check it0
3receive pacingXON/XOFF when its buffer fills; not used by Kermit0
4transmit pacingstop on XOFF; not used by Kermit0
5check type1, 2 or 3, when the calculator starts a send3
6translation mode0 to 31

Other settings are system flags: −33 chooses the wire or infrared, −35 binary or ASCII, and −36 whether a received object replaces a variable of the same name. With −36 clear, the calculator adds an extension like .1 instead.

XModem

XModem goes back to Ward Christensen's MODEM program of 1977. It sends a file in blocks: a start byte (SOH for 128 bytes, STX for 1 KB), the block number and its complement, the data and a check: a one-byte sum, or a 16-bit CRC. The receiver starts the transfer: NAK asks for checksums, C for the CRC. Each block is answered with ACK or NAK, and EOT ends the file. The last block is padded to its full size.

On the HP calculators:

For XModem, start the sender first and then the receiver, with only a short gap. For Kermit it is the other way round: start the receiving side first.

A Kermit program on the computer

Any Kermit program works with the calculator as server. The Kermit Project's settings for C-Kermit and Kermit 95, with the serial port's name in place of COM1:

SET MODEM TYPE DIRECT
SET PORT COM1
SET SPEED 9600
SET CARRIER-WATCH OFF
SET FLOW NONE
SET PARITY NONE
SET CONTROL PREFIX ALL
SET BLOCK 3

Set the program's file type to binary or text to match the calculator's flag −35. Then REMOTE DIRECTORY, GET and SEND talk to the calculator's server, and FINISH ends it. The project's own tool does all of this for you: see satx.

HPComm and HPGComm

HPComm is a Windows program by Jean-Pierre "James" Bergamin, the author of saturnus, for moving files between a PC and an HP 48 or 49G. It shows the calculator's directories beside the PC's folders, as Windows Explorer does, and files move between them by drag and drop, over Kermit. Version 2.4 came out as open source in February 1999.

HP then approached the project. HPComm 3.0, written by James Bergamin and Mitch Davis of HP, became the software of HP's Graphing Calculator PC Connectivity Kit (F1897A) in 1999, for the 48 series and the new 49G, and HP agreed to release it under the GNU GPL. The last version, 3.0r4, came out in June 2000.

For the 38G, HPComm38 split off at the end of 1999 and shipped in HP's HP38G PC Connectivity Kit. Reworked for the 39G and 40G, it became HPGComm: version 2.0 in June 2001, 2.01 in July. It serves a folder as the calculator's "disk drive", shows the calculator's screen on the PC, and sends binary aplets to the 39G and 40G by XModem.

The dog on the splash screen and the program icon is Spot, drawn by ishadyn (@ishadyn_comic on Instagram).

The source code, the help and the hpcomm.org website are archived on GitHub. HPComm 3.0r4, the kit's version, as well as HPComm 2.4 and HPGComm 2.0 are still on hpcalc.org.

Sources