Class TerminalSerial

Nested Relationships

Nested Types

Class Documentation

class TerminalSerial

Handles incoming requests from the “terminal”. The “terminal” is either a uart line connected to a computer with a serial connection open or when running on the simulator, stdin/stdout.

To add a handler to the terminal, extend the TerminalSerialCallbackInterface and add it to an instance of the TerminalSerial class via addHeader. Whenever the header is received on the terminal line, the contents of the message (minus the header and any flags specified for the TerminalSerial) will be passed on to the registered callback via terminalSerialCallback.

Note

If the “-S” flag is specified directly after the header, the terminal enters streaming mode. In this mode, so long as terminalSerialCallback returns true when streaming mode is initially enabled, the TerminalSerialCallbackInterface’s terminalSerialStreamCallback function will be called repeatedly until the user enters any new key presses. If you design an TerminalSerialCallbackInterface that does not need/handle streaming, simply check the argument in terminalSerialCallback called streamingEnabled return false and write to the outputStream to notify the user that streaming is not enabled. An example of where you would use streaming mode is if you would like to have a mode that prints out motor information constantly without having to retype a command into the terminal.

Public Functions

explicit TerminalSerial(Drivers *drivers)
DISALLOW_COPY_AND_ASSIGN(TerminalSerial)
virtual ~TerminalSerial() = default
void initialize()
void update()
void addHeader(const char *header, TerminalSerialCallbackInterface *callback)

Public Static Attributes

static char DELIMITERS[] = " \t"
static int MAX_LINE_LENGTH = 256
static int STREAMING_PERIOD = 500