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

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

#include <SLIPStream/SLIPSender.hpp>

Collaboration diagram for SLIPSenderCRC< Sender, CRC >:

Public Types

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

Public Member Functions

 SLIPSenderCRC ()=default
 Default constructor. More...
 
 SLIPSenderCRC (Sender &&sender)
 Constructor with sender initialization. More...
 
 SLIPSenderCRC (CRC &&crc)
 Constructor with CRC initialization. More...
 
 SLIPSenderCRC (Sender &&sender, CRC &&crc)
 Constructor with sender and CRC initialization. More...
 
size_t beginPacket ()
 Start a packet. More...
 
size_t endPacket ()
 Finish the packet. More...
 
size_t write (const uint8_t *data, size_t len)
 Write some data as the body of a packet. More...
 

Private Attributes

SLIPSender< Sender > sender
 
CRC crc
 

Detailed Description

template<class Sender, class CRC>
class SLIPSenderCRC< Sender, CRC >

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

Template Parameters
SenderThe functor that actually sends a byte over the transmission channel. Takes a single byte as an argument and returns the number of bytes written (similar to Serial.write(uint8_t)):
size_t sender(uint8_t byte)
CRCThe CRC type to use.

Definition at line 94 of file SLIPSender.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 128 of file SLIPSender.hpp.

Constructor & Destructor Documentation

◆ SLIPSenderCRC() [1/4]

SLIPSenderCRC ( )
default

Default constructor.

◆ SLIPSenderCRC() [2/4]

SLIPSenderCRC ( Sender &&  sender)
inline

Constructor with sender initialization.

Parameters
senderInitialization for the sender. Perfect forwarding is used.
The CRC is default-initialized.

Definition at line 107 of file SLIPSender.hpp.

◆ SLIPSenderCRC() [3/4]

SLIPSenderCRC ( CRC &&  crc)
inline

Constructor with CRC initialization.

Parameters
crcInitialization for the CRC. Perfect forwarding is used.
The sender is default-initialized.

Definition at line 115 of file SLIPSender.hpp.

◆ SLIPSenderCRC() [4/4]

SLIPSenderCRC ( Sender &&  sender,
CRC &&  crc 
)
inline

Constructor with sender and CRC initialization.

Parameters
senderInitialization for the sender. Perfect forwarding is used.
crcInitialization for the CRC. Perfect forwarding is used.

Definition at line 124 of file SLIPSender.hpp.

Member Function Documentation

◆ beginPacket()

size_t beginPacket ( )
inline

Start a packet.

Sends a SLIP END character to flush the buffer of the receiver.

Returns
The number of bytes sent by the Sender.

Definition at line 131 of file SLIPSender.hpp.

◆ endPacket()

size_t endPacket ( )
inline

Finish the packet.

Encodes and sends the checksum of all data sent using the write function, followed by a SLIP END character.

Returns
The number of bytes sent by the Sender.

Definition at line 144 of file SLIPSender.hpp.

◆ write()

size_t write ( const uint8_t *  data,
size_t  len 
)

Write some data as the body of a packet.

The data is encoded by SLIP before sending, so arbitrary binary data can be sent.

Parameters
dataA pointer to the data to send.
lenThe number of bytes to send.
Returns
The number of bytes sent by the Sender.

Definition at line 47 of file SLIPSender.ipp.

Member Data Documentation

◆ sender

SLIPSender<Sender> sender
private

Definition at line 157 of file SLIPSender.hpp.

◆ crc

CRC crc
private

Definition at line 158 of file SLIPSender.hpp.


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