AYAB Arduino Firmware 0.95
The goal of the AYAB project is to provide an alternative way to control the famous Brother KH-9xx range of knitting machines using a computer
SLIP Class Reference

A Serial Line IP (SLIP) Encoder. More...

#include <SLIP.h>

Collaboration diagram for SLIP:
Collaboration graph

Public Types

enum  { END = 0300 , ESC = 0333 , ESC_END = 0334 , ESC_ESC = 0335 }
 Key constants used in the SLIP protocol.
 

Static Public Member Functions

static size_t encode (const uint8_t *buffer, size_t size, uint8_t *encodedBuffer)
 Encode a byte buffer with the SLIP encoder.
 
static size_t decode (const uint8_t *encodedBuffer, size_t size, uint8_t *decodedBuffer)
 Decode a SLIP-encoded buffer.
 
static size_t getEncodedBufferSize (size_t unencodedBufferSize)
 Get the maximum encoded buffer size needed for a given unencoded buffer size.
 

Detailed Description

A Serial Line IP (SLIP) Encoder.

Serial Line IP (SLIP) is a packet framing protocol: SLIP defines a sequence of characters that frame IP packets on a serial line and nothing more. It provides no addressing, packet type identification, error detection, correction or compression mechanisms. Because the protocol does so little its implementation is trivial and fast.

See also
http://tools.ietf.org/html/rfc1055

Member Function Documentation

◆ decode()

static size_t SLIP::decode ( const uint8_t *  encodedBuffer,
size_t  size,
uint8_t *  decodedBuffer 
)
inlinestatic

Decode a SLIP-encoded buffer.

Parameters
encodedBufferA pointer to the encodedBuffer to decode.
sizeThe number of bytes in the encodedBuffer.
decodedBufferThe target buffer for the decoded bytes.
Returns
The number of bytes written to the decodedBuffer.
Warning
decodedBuffer must have a minimum capacity of size.

◆ encode()

static size_t SLIP::encode ( const uint8_t *  buffer,
size_t  size,
uint8_t *  encodedBuffer 
)
inlinestatic

Encode a byte buffer with the SLIP encoder.

Parameters
bufferA pointer to the unencoded buffer to encode.
sizeThe number of bytes in the buffer.
encodedBufferThe buffer for the encoded bytes.
Returns
The number of bytes written to the encodedBuffer.
Warning
The encodedBuffer must have at least getEncodedBufferSize() allocated.

◆ getEncodedBufferSize()

static size_t SLIP::getEncodedBufferSize ( size_t  unencodedBufferSize)
inlinestatic

Get the maximum encoded buffer size needed for a given unencoded buffer size.

SLIP has a start and a end markers (192 and 219). Marker value is replaced by 2 bytes in the encoded buffer. So in the worst case of sending a buffer with only '192' or '219', the encoded buffer length will be 2 * buffer.size() + 2

Parameters
unencodedBufferSizeThe size of the buffer to be encoded.
Returns
the maximum size of the required encoded buffer.

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