Class PacketFinderBase

Inheritance Relationships

Derived Type

Class Documentation

class PacketFinderBase

Provides simple packet finder which may be consist of stx, etx, payload, …

Usage:

@code

Todo:

(1) getting buffer from this class

(2) simple construction of this class

(3) device abstraction

(4) extend-able packet structures

(5) like ros, auto-generation of code from scripts

(6) packetFinder to ros converter

(7) evaluate it (valgrind)

Note

Subclassed by kobuki::PacketFinder

Public Types

enum packetFinderState

Values:

enumerator clearBuffer
enumerator waitingForStx
enumerator waitingForPayloadSize
enumerator waitingForPayloadToEtx
enumerator waitingForEtx
typedef ecl::PushAndPop<unsigned char> BufferType

Public Functions

PacketFinderBase()

Default constructor. Use with configure().

inline virtual ~PacketFinderBase()
void configure(const std::string &sigslots_namespace, const BufferType &putStx, const BufferType &putEtx, unsigned int sizeLengthField, unsigned int sizeMaxPayload, unsigned int sizeChecksumField, bool variableSizePayload)
void clear()
void enableVerbose()
virtual bool update(const unsigned char *incoming, unsigned int numberOfIncoming)
virtual bool checkSum()
unsigned int numberOfDataToRead()
void getBuffer(BufferType &bufferRef)
void getPayload(BufferType &bufferRef)

Public Members

enum packetFinderState state

Protected Functions

bool WaitForStx(const unsigned char datum)
bool waitForPayloadSize(const unsigned char *incoming, unsigned int numberOfIncoming)
bool waitForEtx(const unsigned char incoming, bool &foundPacket)
bool waitForPayloadAndEtx(const unsigned char *incoming, unsigned int numberOfIncoming, bool &foundPacket)

Protected Attributes

unsigned int size_stx
unsigned int size_etx
unsigned int size_length_field
bool variable_size_payload
unsigned int size_max_payload
unsigned int size_payload
unsigned int size_checksum_field
BufferType STX
BufferType ETX
BufferType buffer
bool verbose
ecl::Signal<const std::string&> sig_warn
ecl::Signal<const std::string&> sig_error