nRF5 SDK v12.1.0
Modules | Data Structures | Enumerations | Functions
SLIP encoding decoding

This module encodes and decodes slip packages (RFC1055). More...

Modules

 SLIP encoding decoding configuration
 

Data Structures

struct  buffer_t
 

Enumerations

enum  slip_state_t {
  SLIP_DECODING,
  SLIP_END_RECEIVED,
  SLIP_ESC_RECEIVED,
  SLIP_CLEARING_INVALID_PACKET
}
 

Functions

uint32_t slip_encode (uint8_t *p_output, uint8_t *p_input, uint32_t input_length, uint32_t output_buffer_length)
 Encodes a slip packet. More...
 
uint32_t slip_decoding_add_char (uint8_t c, buffer_t *p_buf, slip_state_t *current_state)
 Decodes a slip packet. More...
 

Detailed Description

This module encodes and decodes slip packages (RFC1055).

The standard is described in https://tools.ietf.org/html/rfc1055

Function Documentation

uint32_t slip_decoding_add_char ( uint8_t  c,
buffer_t p_buf,
slip_state_t *  current_state 
)

Decodes a slip packet.

When decoding a slip packet, a state must be preserved. Initial state must be set to SLIP_DECODING.

Return values
NRF_SUCCESSwhen a packet is parsed. The length of the packet can be read out from p_buf->current_index
NRF_ERROR_BUSYwhen packet is not finished parsing
NRF_ERROR_INVALID_DATAwhen packet is encoded wrong. This moves the decoding to SLIP_CLEARING_INVALID_PACKET, and will stay in this state until SLIP_END is encountered.
uint32_t slip_encode ( uint8_t *  p_output,
uint8_t *  p_input,
uint32_t  input_length,
uint32_t  output_buffer_length 
)

Encodes a slip packet.

Note that the encoded output data will be longer than the input data.

Return values
Thelength of the encoded packet. If it is smaller than the input length, an error has occurred.

Documentation feedback | Developer Zone | Subscribe | Updated