SF(1)

NAME
sf - serial framing

SYNOPSIS
sf [-i | -o] [device]

DESCRIPTION
sf provides a simple scheme for framing a message over a byte stream. This is useful in cases such as sockets, pipe, and serial devices where a real end of file condition would require terminating the link, but it is important to transmit multiple messages and keeping the link open for an arbitrary amount of time.

sf uses a simple framing scheme with a start of message byte sequence (0xF7 0xFF), most bytes represent themselves, an escape byte sequence (0xF7 0xFD), and an end of messsage byte sequence (0xF7 0xFE). UTF-8 encoded text will never need to be escaped. Data can be recursively framed.

Exactly one of the -i and -o options must be set to control whether the program is in input or output mode.

Input mode works by reading one byte at a time from stdin (or the device if given). It discards all read bytes until it finds a valid start of message byte sequence. It then decodes the body and writes the decoded bytes to stdout. Finally it finds an end of message byte sequence and exits.

Output mode works by reading bytes from stdin until an end of file condition. It emits a start of message byte sequence to stdout (or to the device if given). It emits an encoded body with the contents of stdin. Finally it emits an end of message byte sequence.

The device argument can be a device or the path of an existing unix socket.

The options are as follows:

-i  Decode payload.

-o  Encode payload.

EXIT STATUS
sf will exit 0 on success and non-zero otherwise.

SEE ALSO
sfnc(1), sfncd(1), serial-transfer(7)