Arduino KVComm  master
Key-Value pair communication library for Arduino
Public Types | Public Member Functions | Private Attributes | List of all members
SLIPParserCRC< CRC > Class Template Reference

Class for parsing SLIP packets with a CRC checksum to check the integrity of the packets. More...

#include <SLIPStream/SLIPParser.hpp>

Collaboration diagram for SLIPParserCRC< CRC >:

Public Types

using checksum_t = typename boost::uint_t< CRC::bit_count >::least
 The integer type of the checksum. More...
 

Public Member Functions

 SLIPParserCRC (const SLIPParser &parser)
 
 SLIPParserCRC (const SLIPParser &parser, CRC &&crc)
 
size_t parse (uint8_t c)
 Parse the given byte. More...
 
bool wasTruncated () const
 Check if the previous packet was truncated. More...
 
size_t numTruncated () const
 Get the number of bytes that were truncated due to the previous packet being too large for the buffer. More...
 
checksum_t checksum () const
 Get the checksum of the previous packet. More...
 

Private Attributes

SLIPParser parser
 
CRC crc
 

Detailed Description

template<class CRC>
class SLIPParserCRC< CRC >

Class for parsing SLIP packets with a CRC checksum to check the integrity of the packets.

Template Parameters
CRCThe CRC type to use.

Definition at line 138 of file SLIPParser.hpp.

Member Typedef Documentation

◆ checksum_t

using checksum_t = typename boost::uint_t<CRC::bit_count>::least

The integer type of the checksum.

Definition at line 145 of file SLIPParser.hpp.

Constructor & Destructor Documentation

◆ SLIPParserCRC() [1/2]

SLIPParserCRC ( const SLIPParser parser)
inline

Definition at line 140 of file SLIPParser.hpp.

◆ SLIPParserCRC() [2/2]

SLIPParserCRC ( const SLIPParser parser,
CRC &&  crc 
)
inline

Definition at line 141 of file SLIPParser.hpp.

Member Function Documentation

◆ parse()

size_t parse ( uint8_t  c)
inline

Parse the given byte.

Parameters
cThe byte to parse.
Return values
0The packet is not finished yet.
>0The packet was received in its entirety, and the return value is the size of the packet in the buffer.
If the packet is not larger than the buffer, this will be the same as the size of the packet. If the packet was larger than the buffer, the return value will be the size of the buffer, and wasTruncated will return true.

Definition at line 163 of file SLIPParser.hpp.

◆ wasTruncated()

bool wasTruncated ( ) const
inline

Check if the previous packet was truncated.

Return values
trueThe previous packet didn't fit the buffer. The size returned by SLIPParser::parse was smaller than the actual size of the packet.
falseThe buffer was large enough to store the previous packet.

Definition at line 192 of file SLIPParser.hpp.

◆ numTruncated()

size_t numTruncated ( ) const
inline

Get the number of bytes that were truncated due to the previous packet being too large for the buffer.

Definition at line 198 of file SLIPParser.hpp.

◆ checksum()

checksum_t checksum ( ) const
inline

Get the checksum of the previous packet.

A checksum of zero indicates that the packet was received correctly.

Definition at line 207 of file SLIPParser.hpp.

Member Data Documentation

◆ parser

SLIPParser parser
private

Definition at line 210 of file SLIPParser.hpp.

◆ crc

CRC crc
private

Definition at line 211 of file SLIPParser.hpp.


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