Erriez Serial Terminal library for Arduino  1.1.2
This is a Serial Terminal library for Arduino.
Classes | Public Member Functions | List of all members
SerialTerminal Class Reference

SerialTerminal class. More...

#include <ErriezSerialTerminal.h>

Public Member Functions

 SerialTerminal (char newlineChar='\n', char delimiterChar=' ')
 SerialTerminal constructor. More...
 
void addCommand (const char *command, void(*function)())
 Add command with callback handler. More...
 
void setDefaultHandler (void(*function)(const char *))
 Set default callback handler for unknown commands. More...
 
void readSerial ()
 Read from serial port. More...
 
void clearBuffer ()
 Clear serial receive buffer.
 
char * getNext ()
 Get next argument. More...
 
char * getRemaining ()
 Get all remaining characters from serial buffer. More...
 

Detailed Description

SerialTerminal class.

Definition at line 52 of file ErriezSerialTerminal.h.

Constructor & Destructor Documentation

◆ SerialTerminal()

SerialTerminal::SerialTerminal ( char  newlineChar = '\n',
char  delimiterChar = ' ' 
)
explicit

SerialTerminal constructor.

Parameters
newlineCharNewline character '\r' or '\n'.
Default: '\n'.
delimiterCharDelimiter separator character between commands and arguments.
Default: space.

Definition at line 44 of file ErriezSerialTerminal.cpp.

Member Function Documentation

◆ addCommand()

void SerialTerminal::addCommand ( const char *  command,
void(*)()  function 
)

Add command with callback handler.

Parameters
commandRegister a null-terminated ASCII command.
functionThe function to be called when receiving the command.

Definition at line 66 of file ErriezSerialTerminal.cpp.

◆ getNext()

char * SerialTerminal::getNext ( )

Get next argument.

Returns
Address: Pointer to next argument
NULL: No argument available

Definition at line 154 of file ErriezSerialTerminal.cpp.

◆ getRemaining()

char * SerialTerminal::getRemaining ( )

Get all remaining characters from serial buffer.

Returns
Address: Pointer to remaining characters in serial receive buffer.
NULL: No remaining data available.

Definition at line 165 of file ErriezSerialTerminal.cpp.

◆ readSerial()

void SerialTerminal::readSerial ( )

Read from serial port.

Process command when newline character has been received.

Definition at line 98 of file ErriezSerialTerminal.cpp.

◆ setDefaultHandler()

void SerialTerminal::setDefaultHandler ( void(*)(const char *)  function)

Set default callback handler for unknown commands.

Store default callback handler which will be called when receiving an unknown command.

Parameters
functionAddress of the default handler. This function will be called when the command is not recognized. The parameter contains the first ASCII command.

Definition at line 88 of file ErriezSerialTerminal.cpp.


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