SLIP was originally designed as an encapsulation for IP over serial ports, but can be used for framing of any packet-based data for transmission over a serial port.
◆ SLIP_RX_BUFFER_SIZE
| #define SLIP_RX_BUFFER_SIZE (2000) |
Recommended RX buffer size.
Definition at line 25 of file slip.h.
◆ SLIP_RX_STATE_INIT
| #define SLIP_RX_STATE_INIT |
( |
|
_buffer, |
|
|
|
_buffer_length |
|
) |
| { _buffer, _buffer_length, 0, false, false } |
Static initializer for slip_rx_state.
See slip_rx_state for an example of usage.
- Parameters
-
| _buffer | Pointer to a buffer to be used by SLIP (should be a uint8_t array). |
| _buffer_length | The size of _buffer. |
Definition at line 59 of file slip.h.
◆ slip_transport_tx_fn
| typedef int(* slip_transport_tx_fn) (uint8_t c, void *arg) |
Function to send a character on the SLIP transport.
- Parameters
-
| c | The character to transmit |
| arg | Opaque argument, as passed to slip_tx(). |
- Returns
- 0 on success, otherwise a negative error code.
Definition at line 110 of file slip.h.
◆ slip_rx_status
Enumeration of SLIP status codes.
| Enumerator |
|---|
| SLIP_RX_COMPLETE | A complete packet with length > 0 has been received.
|
| SLIP_RX_IN_PROGRESS | Receive is still in progress.
|
| SLIP_RX_BUFFER_LIMIT | Receive buffer limit has been reached.
|
| SLIP_RX_ERROR | An erroneous packet has been received.
|
Definition at line 81 of file slip.h.
◆ slip_rx()
Handle reception of a character in a SLIP stream.
When reception of a packet is successful, this will return SLIP_RX_COMPLETE and the packet can be found in state->buffer with length state->length.
- Parameters
-
| state | Current slip state. Will be updated by this function. |
| c | The received character. |
- Returns
- an appropriate value of slip_rx_status.
◆ slip_rx_state_reinit()
| static void slip_rx_state_reinit |
( |
struct slip_rx_state * |
state, |
|
|
uint8_t * |
buffer, |
|
|
size_t |
buffer_length |
|
) |
| |
|
inlinestatic |
Dynamic (re)initializer for slip_rx_state.
This can be used as an alternative to SLIP_RX_STATE_INIT when static initialization is not possible.
- Parameters
-
| state | The slip state structure to init. |
| buffer | Pointer to the buffer to be used by SLIP. |
| buffer_length | Length of buffer. |
Definition at line 70 of file slip.h.
◆ slip_tx()
| int slip_tx |
( |
slip_transport_tx_fn |
transport_tx_fn, |
|
|
void * |
transport_tx_arg, |
|
|
const uint8_t * |
packet, |
|
|
size_t |
packet_len |
|
) |
| |
Transmit a packet with SLIP framing.
- Parameters
-
| transport_tx_fn | Function to invoke to send characters on the transport. |
| transport_tx_arg | Argument to pass to transport_tx_fn. |
| packet | The packet to transmit. |
| packet_len | The length of the packet. |
- Returns
- 0 on success, otherwise an error code as returned by
transport_tx_fn.