Small utilities for moving text files between a host computer and a Sharp PC‑G850 series pocket computer using SIO mode over a serial port.
sendfile— send a text file to the Sharprecvfile— receive a text file from the Sharpxfer.c/xfer.h— serial port setup helpers (open and configure the TTY)terminal— TBD
These tools aim to be simple and predictable: they do not do protocol handshakes or “smart” conversions, and they do not insert or strip BASIC line numbers unless specifically noted below.
A BSD-make–compatible Makefile is provided. If you are using the version that allows choosing the receiver source, you can build like this:
# Clean build
make clean
makeThis compiles:
xfer.c→xfer.osendfile.c→sendfilerecvfile.c(orrecvfile-fixed2.c) →recvfileterminal.c→terminal(links-pthread -lncurses -lform)
Alternatively, build the two main tools manually:
cc -Wall -Wextra -O2 -c xfer.c -o xfer.o
cc -Wall -Wextra -O2 -c sendfile.c -o sendfile.o
cc -Wall -Wextra -O2 -o sendfile sendfile.o xfer.o
cc -Wall -Wextra -O2 -c recvfile.c -o recvfile.o
cc -Wall -Wextra -O2 -o recvfile recvfile.o xfer.oDependencies:
terminalrequiresncursesandform(already part of base on FreeBSD).
Purpose: Open the serial port and stream a text file to the PC‑G850 in SIO mode.
Line endings: Each line is sent with CRLF.
EOF: Appends CP/M style EOF byte 0x1A at the end (expected by some Sharp tools).
Line numbers: No numbering is inserted.
Command line:
sendfile <serial-port> <filename>
Examples:
./sendfile /dev/cuaU0 program.bas
./sendfile /dev/ttyu0 mynotes.txtBehavior details:
- Reads the input file line-by-line with a modest buffer (multiple reads handle long lines).
- Strips trailing
\r/\nand then transmits the line followed by\r\n. - After all data is sent, writes a single
0x1Abyte. - Uses
init_fd()fromxferfor port setup.
Purpose: Read bytes from the serial port and write a normalized text file on the host.
Line endings: Any of CRLF, CR, or LF are normalized to \n.
EOF: Stops if it encounters CP/M style EOF (0x1A).
Line numbers: If a line begins with digits (optionally preceded by spaces), a single space is inserted immediately after the digit sequence. The digits themselves are preserved. No stripping is performed.
Command line:
recvfile <serial-port> <output-filename>
Examples:
./recvfile /dev/cuaU0 program.bas
./recvfile /dev/ttyu0 capture.txtBehavior details:
- Streams safely; handles partial reads and mixed line endings.
- Converts
CRLF/CR/LFto\nin the output file. - If a line starts with spaces + digits, the program ensures there is one space after the digits before any non‑digit character (useful for BASIC listings).
- Does not otherwise modify content.
Purpose: Provide a tiny API to open and configure the serial port for the PC‑G850 SIO link.
Exported functions (declared in xfer.h):
int set_interface_attribs(int fd, int speed, int parity);
int set_blocking(int fd, int should_block);
int init_fd(char *port);Typical defaults:
- 1200 baud, 8N1, blocking I/O.
- You can edit
init_fd()inxfer.cif you need different speeds/parity.
How to use:
#include "xfer.h"in your program.- Link with
xfer.o(do not#include "xfer.c"in sources).
TBD
- Serial device names: On FreeBSD, USB serial adapters are often
/dev/cuaU0(callout) or/dev/ttyU0(call‑in). The non‑modem callout device is usually what you want. - Flow control: The helpers currently disable special processing and set raw-ish mode. If you need hardware flow control (RTS/CTS) or XON/XOFF, adjust
set_interface_attribs(). - Baud rate: The default is
B1200to match common PC‑G850 SIO settings; change inxfer.cif necessary. - CP/M EOF (0x1A): Commonly used by vintage systems to mark end-of-file.
recvfilewill stop when it sees it;sendfileappends one after transmit. - Line numbers:
sendfiledoes not insert them.recvfileonly ensures a space after a leading numeric line label if present.
MIT