nRF5 SDK v17.0.2
Modules | Data Structures | Enumerations | Functions
SLIP encoding and decoding

This module encodes and decodes SLIP packages. More...

Modules

 SLIP encoding and decoding configuration
 

Data Structures

struct  slip_t
 Representation of a SLIP packet. More...
 

Enumerations

enum  slip_read_state_t {
  SLIP_STATE_DECODING,
  SLIP_STATE_ESC_RECEIVED,
  SLIP_STATE_CLEARING_INVALID_PACKET
}
 Status information that is used while receiving and decoding a packet. More...
 

Functions

ret_code_t slip_encode (uint8_t *p_output, uint8_t *p_input, uint32_t input_length, uint32_t *p_output_buffer_length)
 Function for encoding a SLIP packet. More...
 
ret_code_t slip_decode_add_byte (slip_t *p_slip, uint8_t c)
 Function for decoding a SLIP packet. More...
 

Detailed Description

This module encodes and decodes SLIP packages.

The SLIP protocol is described in RFC1055.

Enumeration Type Documentation

Status information that is used while receiving and decoding a packet.

Enumerator
SLIP_STATE_DECODING 

Ready to receive the next byte.

SLIP_STATE_ESC_RECEIVED 

An ESC byte has been received and the next byte must be decoded differently.

SLIP_STATE_CLEARING_INVALID_PACKET 

The received data is invalid and transfer must be restarted.

Function Documentation

ret_code_t slip_decode_add_byte ( slip_t p_slip,
uint8_t  c 
)

Function for decoding a SLIP packet.

The decoded packet is put into p_slip::p_buffer. The index and buffer state is updated.

Ensure that p_slip is properly initialized. The initial state must be set to SLIP_STATE_DECODING.

Parameters
[in,out]p_slipState of the decoding process.
[in]cByte to decode.
Return values
NRF_SUCCESSIf a packet has been parsed. The received packet can be retrieved from p_slip.
NRF_ERROR_NULLIf p_slip is NULL.
NRF_ERROR_NO_MEMIf there is no more room in the buffer provided by p_slip.
NRF_ERROR_BUSYIf the packet has not been parsed completely yet.
NRF_ERROR_INVALID_DATAIf the packet is encoded wrong. In this case, p_slip::state is set to SLIP_STATE_CLEARING_INVALID_PACKET, and decoding will stay in this state until the END byte is received.
ret_code_t slip_encode ( uint8_t *  p_output,
uint8_t *  p_input,
uint32_t  input_length,
uint32_t *  p_output_buffer_length 
)

Function for encoding a SLIP packet.

The maximum size of the output data is (2*input size + 1) bytes. Ensure that the provided buffer is large enough.

Parameters
[in,out]p_outputThe buffer where the encoded SLIP packet is stored. Ensure that it is large enough.
[in,out]p_inputThe buffer to be encoded.
[in,out]input_lengthThe length of the input buffer.
[out]p_output_buffer_lengthThe length of the output buffer after the input has been encoded.
Return values
NRF_SUCCESSIf the input was successfully encoded into output.
NRF_ERROR_NULLIf one of the provided parameters is NULL.

Documentation feedback | Developer Zone | Subscribe | Updated