1
0
Fork 0
mirror of https://gitlab.com/sortix/sortix.git synced 2023-02-13 20:55:38 -05:00
sortix--sortix/sf/sf.1

68 lines
1.7 KiB
Groff
Raw Normal View History

2015-09-19 21:33:04 -04:00
.Dd $Mdocdate: January 7 2015 $
.Dt SF 1
.Os
.Sh NAME
.Nm sf
.Nd serial framing
.Sh SYNOPSIS
.Nm sf
.Op Fl i "|" Fl o
.Op Ar device
.Sh DESCRIPTION
.Nm
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
2015-09-19 21:33:04 -04:00
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.
.Pp
.Nm
uses a simple framing scheme with a start of message byte sequence
.Li ( 0xF7 0xFF ) ,
most bytes represent themselves, an escape byte sequence
.Li ( 0xF7 0xFD ) ,
and an end of messsage byte sequence
.Li ( 0xF7 0xFE ) .
UTF-8 encoded text will never need to be escaped.
Data can be recursively framed.
2015-09-19 21:33:04 -04:00
.Pp
Exactly one of the
.Fl i
and
.Fl o
options must be set to control whether the program is in input or output mode.
.Pp
Input mode works by reading one byte at a time from stdin (or the
.Ar 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.
2015-09-19 21:33:04 -04:00
Finally it finds an end of message byte sequence and exits.
.Pp
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
.Ar device
if given).
It emits an encoded body with the contents of stdin.
Finally it emits an end of message byte sequence.
2015-09-19 21:33:04 -04:00
.Pp
The
.Ar device
argument can be a device or the path of an existing unix socket.
.Pp
The options are as follows:
.Bl -tag -width "12345678"
.It Fl i
Decode payload.
.It Fl o
Encode payload.
.El
.Sh EXIT STATUS
.Nm
will exit 0 on success and non-zero otherwise.
.Sh SEE ALSO
.Xr sfnc 1 ,
.Xr sfncd 1 ,
.Xr serial-transfer 7