Open Model Railroad Network (OpenMRN)
Loading...
Searching...
No Matches
GcStreamParser Class Reference

Parses a sequence of characters; finds GridConnect protocol packet boundaries in the sequence of packets. More...

#include <GcStreamParser.hxx>

Public Member Functions

bool consume_byte (char c)
 Adds the next character from the source stream.
 
bool parse_frame_to_output (struct can_frame *output_frame)
 Parses the current contents of the frame buffer to a can_frame struct.
 
void frame_buffer (std::string *payload)
 

Private Attributes

char cbuf_ [32]
 Collects data from a partial GC packet.
 
int offset_
 offset of next byte in cbuf to write.
 

Detailed Description

Parses a sequence of characters; finds GridConnect protocol packet boundaries in the sequence of packets.

Contains an internal buffer holding the partial (or last found) gridconnect packet.

This class is not thread-safe, but thread-compatible.

Definition at line 47 of file GcStreamParser.hxx.

Constructor & Destructor Documentation

◆ GcStreamParser()

GcStreamParser::GcStreamParser ( )
inline

Definition at line 50 of file GcStreamParser.hxx.

Member Function Documentation

◆ consume_byte()

bool GcStreamParser::consume_byte ( char  c)

Adds the next character from the source stream.

Returns
true if the internal buffer contains a complete frame.
Parameters
cnext character.

Definition at line 40 of file GcStreamParser.cxx.

◆ frame_buffer()

void GcStreamParser::frame_buffer ( std::string *  payload)
Parameters
payloadfills with the current contents of the frame buffer.

Definition at line 78 of file GcStreamParser.cxx.

◆ parse_frame_to_output()

bool GcStreamParser::parse_frame_to_output ( struct can_frame *  output_frame)

Parses the current contents of the frame buffer to a can_frame struct.

Should be called if and inly if the previous consume_char call returned true.

Parameters
output_frameis an output argument, non-NULL, into this we will be writing the binary frame.
Returns
true on success, false if there was a parse error. In this case the frame is set to an error frame.

Definition at line 86 of file GcStreamParser.cxx.

Member Data Documentation

◆ cbuf_

char GcStreamParser::cbuf_[32]
private

Collects data from a partial GC packet.

Definition at line 74 of file GcStreamParser.hxx.

◆ offset_

int GcStreamParser::offset_
private

offset of next byte in cbuf to write.

Definition at line 76 of file GcStreamParser.hxx.


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