Arduino

Serial ManagerAPI DOCUMENTATION

A simple interface for serial communication.

See Example  Public Methods  Release Notes
Overview

The Arduino Serial object provides a great general purpose interface for sending and receiving serial commands. This library takes care of the details and allows you to quickly define and consume an event-based serial protocol.

This is an alpha release, which means this library is functional but likely to change. Please post feedback, questions, and issues to this GitHub issues page.

Note: this library will look for a \n newline character at the end of each command. You must configure the Arduino Serial Monitor to include a \n newline character (next to baud rate), or call setFlag() to change the default value.

Example Wiring

This library communicates over the Arduino USB port set at 115200 baud:

A USB cord plugged into an Arduino Micro.

Example Setup
Example SketchArduinoC++
Public Methods

RBD::SerialManager constructor()

Create a new Serial Manager instance.

EXAMPLE SKETCH
serial_manager
.start()

Begin serial communication over the Arduino USB cable at 115200 baud. This method must be called in setup() in order to use this library.

EXAMPLE SKETCH
serial_manager
.setFlag(value)

Provide a char to change the identifier that denotes the end of each serial command. This library defaults to having a terminating flag of \n newline character. You must configure the Arduino Serial Monitor to include a newline (next to baud rate) for this library to work by default.

EXAMPLE SKETCH
serial_manager
.setDelimiter(value)

Provide a char to change the identifier between parameters in serial commands. This library defaults to having a delimiter of , comma.

EXAMPLE SKETCH
serial_manager
.onReceive()UpdateEvent

Returns true when a setFlag() has been identified in the serial communication input stream and the parsed data is available from getValue().

In order for this library to behave correctly; you must wrap all real-time methods in a conditional with this method (as shown below).

EXAMPLE SKETCH
serial_manager
.getValue()Real-Time

Returns a String of data parsed in chunks between setFlag() from the serial communication input stream. This method must be used with onReceive() for this library to behave correctly (as shown below).

EXAMPLE SKETCH
serial_manager
.getCmd()Real-Time

Returns a String of data that is the first (or only) parameter parsed from getValue(). This enables a serial command structure that follows a cmd,param template. This method must be used with onReceive() for this library to behave correctly (as shown below).

EXAMPLE SKETCH
serial_manager
.getParam()Real-Time

Returns a String of data that is the second parameter parsed from getValue(). This enables a serial command structure that follows a cmd,param template. This method must be used with onReceive() for this library to behave correctly (as shown below).

EXAMPLE SKETCH
serial_manager
.isCmd(value)Real-Time

Provide a String to see if it matches the current getCmd(). This method must be used with onReceive() for this library to behave correctly (as shown below).

EXAMPLE SKETCH
serial_manager
.isParam(value)Real-Time

Provide a String to see if it matches the current getParam(). This method must be used with onReceive() for this library to behave correctly (as shown below).

EXAMPLE SKETCH
serial_manager
.print(value)

Provide any value to print to serial output. This is identical to the documented Arduino Serial.print() function.

EXAMPLE SKETCH
serial_manager
.println(value)

Provide any value to print to serial output, then a carriage return and newline character will be appended. This is identical to the documented Arduino Serial.println() function.

EXAMPLE SKETCH