COSMOS core  1.0.2 (beta)
Comprehensive Open-architecture Solution for Mission Operations Systems
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 
37 
41 
42 #include "support/configCosmos.h"
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
58 #ifndef SLIP_FESC
60  #define SLIP_FESC 0xDB
61 #endif
62 #ifndef SLIP_TFEND
64  #define SLIP_TFEND 0xDC
65 #endif
66 #ifndef SLIP_TFESC
68  #define SLIP_TFESC 0xDD
69 #endif
70 
72 
76 typedef vector <uint8_t> slip_t;
78 
79 
83 
84 int32_t slip_check_crc(uint8_t *sbuf, uint16_t ssize);
85 int32_t slip_unpack(uint8_t *sbuf, uint16_t ssize, uint8_t *rbuf, uint16_t rsize);
86 int32_t slip_decode(uint8_t *sbuf, uint16_t ssize, uint8_t *rbuf, uint16_t rsize);
87 int32_t slip_pack(uint8_t *rbuf, uint16_t rsize, uint8_t *sbuf, uint16_t ssize);
88 int32_t slip_encode(uint8_t *rbuf, uint16_t rsize, uint8_t *sbuf, uint16_t ssize);
89 uint16_t slip_calc_crc(uint8_t *buf, uint16_t size);
90 uint16_t slip_get_crc(uint8_t *buf, uint16_t size);
91 uint16_t slip_set_crc(uint8_t *buf, uint16_t size);
92 int32_t slip_check_crc(slip_t &sbuf);
93 int32_t slip_unpack(slip_t &sbuf, slip_t &rbuf);
94 int32_t slip_decode(slip_t &sbuf, slip_t &rbuf);
95 int32_t slip_pack(slip_t &rbuf, slip_t &sbuf);
96 int32_t slip_encode(slip_t &rbuf, slip_t &sbuf);
97 uint16_t slip_calc_crc(slip_t &buf);
98 uint16_t slip_get_crc(slip_t &buf);
99 uint16_t slip_set_crc(slip_t &buf);
100 
102 
103 #endif
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:212
int32_t slip_unpack(uint8_t *sbuf, uint16_t ssize, uint8_t *rbuf, uint16_t rsize)
Unpack SLIP packet.
Definition: sliplib.cpp:79
int32_t slip_decode(uint8_t *sbuf, uint16_t ssize, uint8_t *rbuf, uint16_t rsize)
Decode SLIP packet.
Definition: sliplib.cpp:109
uint16_t slip_get_crc(uint8_t *buf, uint16_t index)
Get CRC from SLIP buffer.
Definition: sliplib.cpp:364
Headers and definitions common to all COSMOS.
COSMOS Error Codes.
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:288
uint16_t slip_calc_crc(uint8_t *buf, uint16_t size)
Calculate CRC-16-CCITT.
Definition: sliplib.cpp:322
int32_t slip_check_crc(uint8_t *sbuf, uint16_t ssize)
Check SLIP packet CRC.
Definition: sliplib.cpp:47
vector< uint8_t > slip_t
Definition: sliplib.h:76
char buf[128]
Definition: rw_test.cpp:40
uint16_t slip_set_crc(uint8_t *buf, uint16_t index)
Set CRC for SLIP buffer.
Definition: sliplib.cpp:388