Artemis Teensy Flight Software
The software on the Teensy in the Artemis cubesat.
All Classes Namespaces Files Functions Variables Enumerations Enumerator Macros Modules Pages
sliplib.h
Go to the documentation of this file.
1 /********************************************************************
2 * Copyright (C) 2015 by Interstel Technologies, Inc.
3 * and Hawaii Space Flight Laboratory.
4 *
5 * This file is part of the COSMOS/core that is the central
6 * module for COSMOS. For more information on COSMOS go to
7 * <http://cosmos-project.com>
8 *
9 * The COSMOS/core software is licenced under the
10 * GNU Lesser General Public License (LGPL) version 3 licence.
11 *
12 * You should have received a copy of the
13 * GNU Lesser General Public License
14 * If not, go to <http://www.gnu.org/licenses/>
15 *
16 * COSMOS/core is free software: you can redistribute it and/or
17 * modify it under the terms of the GNU Lesser General Public License
18 * as published by the Free Software Foundation, either version 3 of
19 * the License, or (at your option) any later version.
20 *
21 * COSMOS/core is distributed in the hope that it will be useful, but
22 * WITHOUT ANY WARRANTY; without even the implied warranty of
23 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
24 * Lesser General Public License for more details.
25 *
26 * Refer to the "licences" folder for further information on the
27 * condititons and terms to use this software.
28 ********************************************************************/
29 
30 #ifndef _SLIPLIB_H
31 #define _SLIPLIB_H
32 
40 
41 
43 
44 #include "support/cosmos-errno.h"
45 #include <cstring>
46 
50 
51 // **************************************************************************
52 // SLIP Byte Definitions - Added 20140610 - To prevent errors with other SLIP Libs
53 // **************************************************************************
55 #ifndef SLIP_FEND
56  #define SLIP_FEND 0xC0
57 #endif
59 #ifndef SLIP_FESC
60  #define SLIP_FESC 0xDB
61 #endif
63 #ifndef SLIP_TFEND
64  #define SLIP_TFEND 0xDC
65 #endif
67 #ifndef SLIP_TFESC
68  #define SLIP_TFESC 0xDD
69 #endif
70 
72 
76 
77 int32_t slip_unpack(uint8_t *sbuf, uint16_t ssize, uint8_t *rbuf, uint16_t rsize);
78 int32_t slip_decode(uint8_t *sbuf, uint16_t ssize, uint8_t *rbuf, uint16_t rsize);
79 int32_t slip_pack(uint8_t *rbuf, uint16_t rsize, uint8_t *sbuf, uint16_t ssize);
80 int32_t slip_encode(uint8_t *rbuf, uint16_t rsize, uint8_t *sbuf, uint16_t ssize);
81 int32_t slip_unpack(vector<uint8_t> &sbuf, vector<uint8_t> &rbuf);
82 int32_t slip_decode(vector<uint8_t> &sbuf, vector<uint8_t> &rbuf);
83 int32_t slip_pack(vector<uint8_t> &rbuf, vector<uint8_t> &sbuf);
84 int32_t slip_encode(vector<uint8_t> &rbuf, vector<uint8_t> &sbuf);
85 int32_t slip_extract(FILE *fp, vector<uint8_t> &buf);
86 uint16_t slip_calc_crc(uint8_t *buf, uint16_t size);
87 uint16_t slip_calc_crc(vector<uint8_t> &buf);
88 
89 
91 
92 #endif
Headers and definitions common to all COSMOS Kernel.
COSMOS Error Codes.
int32_t slip_unpack(uint8_t *sbuf, uint16_t ssize, uint8_t *rbuf, uint16_t rsize)
Unpack SLIP packet.
Definition: sliplib.cpp:50
int32_t slip_decode(uint8_t *sbuf, uint16_t ssize, uint8_t *rbuf, uint16_t rsize)
Decode SLIP packet.
Definition: sliplib.cpp:70
int32_t slip_encode(uint8_t *rbuf, uint16_t rsize, uint8_t *sbuf, uint16_t ssize)
Encode data in to SLIP packet.
Definition: sliplib.cpp:173
int32_t slip_pack(uint8_t *rbuf, uint16_t rsize, uint8_t *sbuf, uint16_t ssize)
Pack data in to SLIP packet.
Definition: sliplib.cpp:247
uint16_t slip_calc_crc(uint8_t *buf, uint16_t size)
Calculate CRC-16-CCITT.
Definition: sliplib.cpp:334