Open FFBoard
Open source force feedback firmware
CmdParser Class Reference

#include <CmdParser.h>

Public Member Functions

 CmdParser (const uint32_t bufferMaxCapacity=512)
 
virtual ~CmdParser ()
 
void clear ()
 
bool add (char *Buf, uint32_t *Len)
 
bool parse (std::vector< ParsedCommand > &commands)
 
int32_t bufferCapacity ()
 
void setClearBufferTimeout (uint32_t timeout)
 

Private Attributes

const uint32_t bufferMaxCapacity
 
uint32_t clearBufferTimeout = 0
 
uint32_t lastAddTime = 0
 
RingBufferWrapper ringbuffer
 

Detailed Description

Definition at line 25 of file CmdParser.h.

Constructor & Destructor Documentation

◆ CmdParser()

CmdParser::CmdParser ( const uint32_t  bufferMaxCapacity = 512)

Constructs a string command parser

Parameters
[in]bufferMaxCapacitycapacity of the ringbuffer. Must be divisible by 2 and smaller than CMDPARSER_MAX_VALID_CAPACITY

Definition at line 18 of file CmdParser.cpp.

◆ ~CmdParser()

CmdParser::~CmdParser ( )
virtual

Definition at line 25 of file CmdParser.cpp.

Member Function Documentation

◆ add()

bool CmdParser::add ( char *  Buf,
uint32_t *  Len 
)

Adds one or more characters to the parser buffer Returns true if an end marker was detected and a command is ready to be parsed

Definition at line 37 of file CmdParser.cpp.

◆ bufferCapacity()

int32_t CmdParser::bufferCapacity ( )

Definition at line 75 of file CmdParser.cpp.

◆ clear()

void CmdParser::clear ( )

Definition at line 28 of file CmdParser.cpp.

◆ parse()

bool CmdParser::parse ( std::vector< ParsedCommand > &  commands)

Definition at line 85 of file CmdParser.cpp.

◆ setClearBufferTimeout()

void CmdParser::setClearBufferTimeout ( uint32_t  timeout)

If the last command was earlier than the timeout force clear the buffer before appending. Gets rid of unparsable parts in the buffer. Set 0 to never force clear the buffer automatically and only clear parsed portions (default).

Definition at line 71 of file CmdParser.cpp.

Member Data Documentation

◆ bufferMaxCapacity

const uint32_t CmdParser::bufferMaxCapacity
private

Definition at line 40 of file CmdParser.h.

◆ clearBufferTimeout

uint32_t CmdParser::clearBufferTimeout = 0
private

Definition at line 42 of file CmdParser.h.

◆ lastAddTime

uint32_t CmdParser::lastAddTime = 0
private

Definition at line 43 of file CmdParser.h.

◆ ringbuffer

RingBufferWrapper CmdParser::ringbuffer
private

Definition at line 45 of file CmdParser.h.


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