Basic interface

The framing methods are exposed through the PacketPrint and PacketStream interfaces.

class packetio::PacketPrint : public Print

Augments arduino’s Print to add knowledge of packets.

Acts like a new Print for each packet. To stop printing to the current packet, and send new prints to the next one, call :func:end

This only concerns itself with the read parts of stream, and should not be used for writing.

Subclassed by packetio::COBSPrint, packetio::EscapedPrint< EscapeCodes >

Public Functions

virtual bool end() = 0

End the current packet.

Return
true if successful

virtual void abort() = 0

Abort the current packet, preferably invalidating it if possible.

class packetio::PacketStream : public Stream

Augments arduino’s Stream to add knowledge of packets.

Acts like a new stream for each packet, but instead of returning EOF when the packet is over, it returns EOP. EOF is returned when there is nothing to read, but the packet is not complete.

This only concerns itself with the read parts of stream, and should not be used for writing.

Subclassed by packetio::COBSStream, packetio::EscapedStream< EscapeCodes >

Public Functions

virtual int read() = 0

Read a single byte from the current packet.

Return
The byte if available EOF if we have reached the end of the stream EOP if the current packet is complete

virtual int peek() = 0

Peek the next byte from the current packet.

Return
The byte if available EOF if we have reached the end of the stream EOP if the current packet is complete

virtual int available() = 0

Return
A lower bound on the number of bytes available. This count includes the EOP return value.

virtual void next() = 0

Advance to the next packet. If the current packet is not complete, then read() will return EOF until it is.

Public Static Attributes

const int EOF = -1

End Of File. This is already the value used by arduino.

const int EOP = -2

End Of Packet.