puzzlebox
|
Classes | |
struct | cmd_t |
Command definition struct. More... | |
Typedefs | |
typedef void | cmd_handle_t(char *line) |
Command handler function. | |
typedef char ** | cmd_complete_t(const char *text, int start, int end) |
Command completion function. | |
Variables | |
cmd_complete_t | cmd_dump_complete |
dump completion function | |
static const cmd_t | cmds [] |
Commands. | |
static const size_t | cmds_length = sizeof(cmds) / sizeof(cmds[0]) |
Number of commands defined in cmds . | |
Command usage | |
cmd_handle_t | cmd_exit |
exit command | |
cmd_handle_t | cmd_test |
test command | |
cmd_handle_t | cmd_help |
help command | |
cmd_handle_t | cmd_reset |
reset command | |
cmd_handle_t | cmd_send |
send command | |
cmd_handle_t | cmd_skip |
skip command | |
cmd_handle_t | cmd_dump |
dump command | |
typedef char ** cmd_complete_t(const char *text, int start, int end) |
text | Current word to complete |
start | Index in rl_line_buffer of cursor position |
end | End index of text in rl_line_buffer |
char*
with suggestions. The array is terminated by a NULL pointer. typedef void cmd_handle_t(char *line) |
line | Remaining text after command name on command line |
cmd_handle_t cmd_dump |
pbc
compiled with the DEBUG
flagShow raw I²C messages being sent to/from the main controller.
cmd_handle_t cmd_exit |
Disconnect from the puzzle box and exit pbc
. This command takes no arguments.
cmd_handle_t cmd_help |
Print a list of available commands with descriptions. This command takes no arguments.
cmd_handle_t cmd_reset |
Set a specific puzzle module's global state to idle. mod is the I²C address of the puzzle module to reset. This parameter may be specified in hexadecimal using a 0x prefix or decimal.
cmd_handle_t cmd_send |
pbc
compiled with the DEBUG
flagSend arbitrary data specified by data to the I²C address specified by addr. data may consist of multiple arguments separated by IFS, in which case the arguments are concatenated.
The main controller will initiate an I²C write command if the address specified in addr does not match that of the main controller. If the addresses do match, the main controller interprets the message as if it were being addressed by another I²C controller.
NUMBER
Numbers can be specified as decimal or hexadecimal using a "0x" prefix. All numbers are unsigned. Decimal literals are always cast to 8-bit integers, while hexadecimal literals are cast to the smallest type that will fit the specified number. Numbers are always sent as little endian.
Examples: 0
123
255
0x10
0x1245
0xdeadBEEF
HEXSTR
Hexadecimal string literals are specified by hexadecimal bytes separated by colons. Each byte must be exactly 2 hexadecimal characters long and followed by a colon (except for the last byte). The minimum length of a hexstr is 2 bytes, as it must include at least a single colon.
Examples: de:ad:be:ef
00:00
STRING
A string literal starts and ends with a single quote. All characters within this literal are sent as-is, and no escaping is possible.
Examples: 'Hello world!'
'string'
' hello '
When double quotes are used instead of single quotes, the following escape sequences are recognised and replaced with special characters:
input | replacement | meaning |
---|---|---|
\0 | 0x00 | null |
\t | 0x09 | tab |
\n | 0x0a | newline |
\r | 0x0d | carriage return |
\\ | 0x5c | backslash |
\" | 0x22 | double quote |
\' | 0x27 | single quote |
Examples: "Hello world!\\0"
"foo\\nbar"
cmd_handle_t cmd_skip |
Set a specific puzzle module's global state to solved. mod is the I²C address of the puzzle module to skip. This parameter may be specified in hexadecimal using a 0x prefix or decimal.
cmd_handle_t cmd_test |
pbc
compiled with the DEBUG
flagSend a test command containing the ASCII string "Hello world!" to I²C address 0x39. This command takes no arguments.