Fang-Robotics-MCB
Fang Robotics Team Codebase
Loading...
Searching...
No Matches
tap::communication::serial::TerminalSerial Class Reference

#include <terminal_serial.hpp>

Public Member Functions

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

Static Public Attributes

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

Detailed Description

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.

Constructor & Destructor Documentation

◆ TerminalSerial()

tap::communication::serial::TerminalSerial::TerminalSerial ( Drivers drivers)
explicit

◆ ~TerminalSerial()

virtual tap::communication::serial::TerminalSerial::~TerminalSerial ( )
virtualdefault

Member Function Documentation

◆ addHeader()

void tap::communication::serial::TerminalSerial::addHeader ( const char *  header,
TerminalSerialCallbackInterface callback 
)

◆ DISALLOW_COPY_AND_ASSIGN()

tap::communication::serial::TerminalSerial::DISALLOW_COPY_AND_ASSIGN ( TerminalSerial  )

◆ initialize()

void tap::communication::serial::TerminalSerial::initialize ( )

◆ update()

void tap::communication::serial::TerminalSerial::update ( )

Member Data Documentation

◆ DELIMITERS

constexpr char tap::communication::serial::TerminalSerial::DELIMITERS = " \t"
staticconstexpr

◆ MAX_LINE_LENGTH

constexpr int tap::communication::serial::TerminalSerial::MAX_LINE_LENGTH = 256
staticconstexpr

◆ STREAMING_PERIOD

constexpr int tap::communication::serial::TerminalSerial::STREAMING_PERIOD = 500
staticconstexpr

The documentation for this class was generated from the following files: