Firmata firmware for Arduino
Firmata is a protocol for communicating with microcontrollers from software on a host computer
Public Types | Public Member Functions | List of all members
firmata::FirmataParser Class Reference

Public Types

typedef void(* callbackFunction) (void *context, uint8_t command, uint16_t value)
 
typedef void(* dataBufferOverflowCallbackFunction) (void *context)
 
typedef void(* stringCallbackFunction) (void *context, const char *c_str)
 
typedef void(* sysexCallbackFunction) (void *context, uint8_t command, size_t argc, uint8_t *argv)
 
typedef void(* systemCallbackFunction) (void *context)
 
typedef void(* versionCallbackFunction) (void *context, size_t sv_major, size_t sv_minor, const char *firmware)
 

Public Member Functions

 FirmataParser (uint8_t *dataBuffer=(uint8_t *) NULL, size_t dataBufferSize=0)
 
void parse (uint8_t value)
 
bool isParsingMessage (void) const
 
int setDataBufferOfSize (uint8_t *dataBuffer, size_t dataBufferSize)
 
void attach (uint8_t command, callbackFunction newFunction, void *context=NULL)
 
void attach (dataBufferOverflowCallbackFunction newFunction, void *context=NULL)
 
void attach (uint8_t command, stringCallbackFunction newFunction, void *context=NULL)
 
void attach (uint8_t command, sysexCallbackFunction newFunction, void *context=NULL)
 
void attach (uint8_t command, systemCallbackFunction newFunction, void *context=NULL)
 
void attach (uint8_t command, versionCallbackFunction newFunction, void *context=NULL)
 
void detach (uint8_t command)
 
void detach (dataBufferOverflowCallbackFunction)
 

Constructor & Destructor Documentation

◆ FirmataParser()

FirmataParser::FirmataParser ( uint8_t *  dataBuffer = (uint8_t *)NULL,
size_t  dataBufferSize = 0 
)

The FirmataParser class.

Parameters
dataBufferA pointer to an external buffer used to store parsed data
dataBufferSizeThe size of the external buffer

Member Function Documentation

◆ attach() [1/6]

void FirmataParser::attach ( dataBufferOverflowCallbackFunction  newFunction,
void *  context = NULL 
)

Attach a buffer overflow callback

Parameters
newFunctionA reference to the buffer overflow callback function to attach.
contextAn optional context to be provided to the callback function (NULL by default).
Note
The context parameter is provided so you can pass a parameter, by reference, to your callback function.

◆ attach() [2/6]

void FirmataParser::attach ( uint8_t  command,
callbackFunction  newFunction,
void *  context = NULL 
)

Attach a generic sysex callback function to a command (options are: ANALOG_MESSAGE, DIGITAL_MESSAGE, REPORT_ANALOG, REPORT DIGITAL, SET_PIN_MODE and SET_DIGITAL_PIN_VALUE).

Parameters
commandThe ID of the command to attach a callback function to.
newFunctionA reference to the callback function to attach.
contextAn optional context to be provided to the callback function (NULL by default).
Note
The context parameter is provided so you can pass a parameter, by reference, to your callback function.

◆ attach() [3/6]

void FirmataParser::attach ( uint8_t  command,
stringCallbackFunction  newFunction,
void *  context = NULL 
)

Attach a callback function for the STRING_DATA command.

Parameters
commandMust be set to STRING_DATA or it will be ignored.
newFunctionA reference to the string callback function to attach.
contextAn optional context to be provided to the callback function (NULL by default).
Note
The context parameter is provided so you can pass a parameter, by reference, to your callback function.

◆ attach() [4/6]

void FirmataParser::attach ( uint8_t  command,
sysexCallbackFunction  newFunction,
void *  context = NULL 
)

Attach a generic sysex callback function to sysex command.

Parameters
commandThe ID of the command to attach a callback function to.
newFunctionA reference to the sysex callback function to attach.
contextAn optional context to be provided to the callback function (NULL by default).
Note
The context parameter is provided so you can pass a parameter, by reference, to your callback function.

◆ attach() [5/6]

void FirmataParser::attach ( uint8_t  command,
systemCallbackFunction  newFunction,
void *  context = NULL 
)

Attach a system callback function (supported options are: SYSTEM_RESET, REPORT_VERSION).

Parameters
commandThe ID of the command to attach a callback function to.
newFunctionA reference to the callback function to attach.
contextAn optional context to be provided to the callback function (NULL by default).
Note
The context parameter is provided so you can pass a parameter, by reference, to your callback function.

◆ attach() [6/6]

void FirmataParser::attach ( uint8_t  command,
versionCallbackFunction  newFunction,
void *  context = NULL 
)

Attach a version callback function (supported option: REPORT_FIRMWARE).

Parameters
commandThe ID of the command to attach a callback function to.
newFunctionA reference to the callback function to attach.
contextAn optional context to be provided to the callback function (NULL by default).
Note
The context parameter is provided so you can pass a parameter, by reference, to your callback function.

◆ detach() [1/2]

void FirmataParser::detach ( dataBufferOverflowCallbackFunction  )

Detach the buffer overflow callback

Parameters
<unused>Any pointer of type dataBufferOverflowCallbackFunction.

◆ detach() [2/2]

void FirmataParser::detach ( uint8_t  command)

Detach a callback function for a specified command (such as SYSTEM_RESET, STRING_DATA, ANALOG_MESSAGE, DIGITAL_MESSAGE, etc).

Parameters
commandThe ID of the command to detatch the callback function from.

◆ isParsingMessage()

bool FirmataParser::isParsingMessage ( void  ) const
Returns
Returns true if the parser is actively parsing data.

◆ parse()

void FirmataParser::parse ( uint8_t  inputData)

Parse data from the input stream.

Parameters
inputDataA single byte to be added to the parser.

◆ setDataBufferOfSize()

int FirmataParser::setDataBufferOfSize ( uint8_t *  dataBuffer,
size_t  dataBufferSize 
)

Provides a mechanism to either set or update the working buffer of the parser. The method will be enabled when no buffer has been provided, or an overflow condition exists.

Parameters
dataBufferA pointer to an external buffer used to store parsed data
dataBufferSizeThe size of the external buffer

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