Artemis Teensy Flight Software
The software on the Teensy in the Artemis cubesat.
COSMOS SLIP support functions

Functions

int32_t slip_unpack (uint8_t *sbuf, uint16_t ssize, uint8_t *rbuf, uint16_t rsize)
 Unpack SLIP packet. More...
 
int32_t slip_unpack (vector< uint8_t > &sbuf, vector< uint8_t > &rbuf)
 
int32_t slip_decode (uint8_t *sbuf, uint16_t ssize, uint8_t *rbuf, uint16_t rsize)
 Decode SLIP packet. More...
 
int32_t slip_decode (vector< uint8_t > &sbuf, vector< uint8_t > &rbuf)
 
int32_t slip_encode (uint8_t *rbuf, uint16_t rsize, uint8_t *sbuf, uint16_t ssize)
 Encode data in to SLIP packet. More...
 
int32_t slip_encode (vector< uint8_t > &rbuf, vector< uint8_t > &sbuf)
 
int32_t slip_pack (uint8_t *rbuf, uint16_t rsize, uint8_t *sbuf, uint16_t ssize)
 Pack data in to SLIP packet. More...
 
int32_t slip_pack (vector< uint8_t > &rbuf, vector< uint8_t > &sbuf)
 
int32_t slip_extract (FILE *fp, vector< uint8_t > &rbuf)
 
uint16_t slip_calc_crc (uint8_t *buf, uint16_t size)
 Calculate CRC-16-CCITT. More...
 
uint16_t slip_calc_crc (vector< uint8_t > &buf)
 

Detailed Description

Function Documentation

◆ slip_calc_crc()

uint16_t slip_calc_crc ( uint8_t *  buf,
uint16_t  size 
)

Calculate CRC-16-CCITT.

Calculate 16-bit CCITT CRC for the indicated buffer and number of bytes. The initial shift register value is 0xffff, and the calculation starts with the LSB, so the Polynomial is 0x8408.

Parameters
bufbytes to calculate on
sizenumber of bytes
Returns
calculated CRC

◆ slip_decode()

int32_t slip_decode ( uint8_t *  sbuf,
uint16_t  ssize,
uint8_t *  rbuf,
uint16_t  rsize 
)

Decode SLIP packet.

Convert SLIP data in one buffer to raw ASCII data in second buffer and return length.

Parameters
sbufcharacter buffer to read SLIP data from
ssizesize of SLIP buffer
rbufcharacter buffer to store raw data
rsizesize of raw buffer, including terminal 0
Returns
bytes in raw buffer

◆ slip_encode()

int32_t slip_encode ( uint8_t *  rbuf,
uint16_t  rsize,
uint8_t *  sbuf,
uint16_t  ssize 
)

Encode data in to SLIP packet.

Convert raw ASCII in one buffer to SLIP encoded data in second buffer.

Parameters
rbufBuffer with raw data
rsizeNumber of bytes in raw buffer
sbufBuffer to place SLIP data in
ssizeMaximum size of SLIP buffer
Returns
bytes actually written

◆ slip_pack()

int32_t slip_pack ( uint8_t *  rbuf,
uint16_t  rsize,
uint8_t *  sbuf,
uint16_t  ssize 
)

Pack data in to SLIP packet.

Convert raw ASCII in one buffer to SLIP encoded data in second buffer, appending a 16 bit CCITT CRC.

Parameters
rbufBuffer with raw data
rsizeNumber of bytes in raw buffer
sbufBuffer to place SLIP data in
ssizeMaximum size of SLIP buffer
Returns
bytes actually written

◆ slip_unpack()

int32_t slip_unpack ( uint8_t *  sbuf,
uint16_t  ssize,
uint8_t *  rbuf,
uint16_t  rsize 
)

Unpack SLIP packet.

Convert SLIP data in one buffer to raw ASCII data in second buffer and return length.

Parameters
sbufcharacter buffer to read SLIP data from
ssizesize of SLIP buffer
rbufcharacter buffer to store raw data
rsizesize of raw buffer, including terminal 0
Returns
bytes in raw buffer