puzzlebox
Loading...
Searching...
No Matches
Commands

Commands within pbc. More...

Detailed Description

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 Documentation

◆ cmd_complete_t

typedef char ** cmd_complete_t(const char *text, int start, int end)
Parameters
textCurrent word to complete
startIndex in rl_line_buffer of cursor position
endEnd index of text in rl_line_buffer
Returns
Array of char* with suggestions. The array is terminated by a NULL pointer.

◆ cmd_handle_t

typedef void cmd_handle_t(char *line)
Parameters
lineRemaining text after command name on command line

Variable Documentation

◆ cmd_dump

cmd_handle_t cmd_dump
Note
This command is only available in builds of pbc compiled with the DEBUG flag
(pbc) dump <none|send|recv|both>

Show raw I²C messages being sent to/from the main controller.

◆ cmd_exit

cmd_handle_t cmd_exit
(pbc) exit

Disconnect from the puzzle box and exit pbc. This command takes no arguments.

◆ cmd_help

cmd_handle_t cmd_help
(pbc) help

Print a list of available commands with descriptions. This command takes no arguments.

◆ cmd_reset

cmd_handle_t cmd_reset
(pbc) reset <mod>

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_send

cmd_handle_t cmd_send
Note
This command is only available in builds of pbc compiled with the DEBUG flag
(pbc) send <addr> <data>

Send 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.

Example
ADDRESS DATA
v~~~ v~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
(pbc) send 0x39 68:65:6c:6c:6f 44 0x20 'world' 33
^~~~~~~~~~~~~~ ^~ ^~~~ ^~~~~~~ ^~
HEXSTR NUMBER NUMBER STRING NUMBER
(binary) (dec) (hex) (literal) (dec)
Datatypes
  • 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_skip

cmd_handle_t cmd_skip
(pbc) skip <mod>

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_test

cmd_handle_t cmd_test
Note
This command is only available in builds of pbc compiled with the DEBUG flag
(pbc) test

Send a test command containing the ASCII string "Hello world!" to I²C address 0x39. This command takes no arguments.