Skip to main content

Module capture

Module capture 

Source
Expand description

A serial console’s capture holding binary records as base64: what a flight computer prints when asked, over its USB serial shell, to dump its memory, as a terminal program saves it.

The capture is the terminal’s text: the commands typed at the shell, then each dump as a block of base64 lines between two marker lines that name it:

uart:~$ log dump
----++++//[[( data start )]]\\++++----
6AMAAJqZykLyAwAAe5TKQvwDAABcj8pCBgQAAD2KykI=
…
----++++//[[( data end )]]\\++++----
uart:~$

The markers are the firmware’s own, a team’s flight computer’s, and its blocks hold binary records whose layout the capture doesn’t state. So blocks decodes each block’s base64 to its bytes, and read reads a block’s records by the layout the caller states, as records::read does. crate::import::read recognizes a capture and refuses it by name, as it has no layout to read it by.

Recognition. A start marker, ----++++//[[( then the block’s name then start )]]\\++++----, on a line of its own within the file’s first HEAD_LINES lines. A name is 1 to MAX_NAME_CHARS ASCII letters, digits, _ or -.

Blocks. Each line between a block’s markers is base64, RFC 4648’s standard alphabet, its spaces at the ends taken off; blank lines are skipped. The lines are joined and decoded as one, its length a multiple of 4, its = padding only at the end and the bits the padding leaves over zero (RFC 4648 §3.5). A character outside the alphabet is refused, naming its line, as is a block that never ends, a marker inside a block, an end marker with no block open, or two blocks of one name. Lines outside the blocks, the shell’s, are skipped.

How far to trust it: the base64 is decoded exactly; the records are as far as their layout is (records). The project’s three sample captures, each held to the table the team decoded from the same records, are read in cargo xtask logs (ADR-271).

Structs§

Block
One block of a capture, decoded.

Constants§

HEAD_LINES
How many of the file’s first lines are searched for a start marker.
MAX_NAME_CHARS
The most characters in a block’s name.

Functions§

blocks
Each block of a capture, decoded, in the file’s order (module docs, Blocks).
read
Reads the block block of a capture by the layout the caller states, as records::read reads a file of records, as LogFormat::ConsoleCapture.
recognizes
Whether the text is a console capture of base64 blocks (module docs, Recognition).