-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathslip.h
51 lines (46 loc) · 1.29 KB
/
slip.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
/**
* @file SLIP encode/decode functions
* @author Thanasis Georgiou
*/
#pragma once
#define SLIP_END 0xC0
#define SLIP_ESC 0xDB
#define SLIP_ESC_END 0xDC
#define SLIP_ESC_ESC 0xDD
enum slip_result {
SLIP_OK = 0,
SLIP_INVALID_ESCAPE = 1,
SLIP_BUFFER_OVERFLOW = 2,
};
/**
* Encode a piece of data according to the SLIP standard
* @param frame Data to encode
* @param frameLength Data length
* @param output Where to store the encoded frame
* @param maxOutputSize Max output size
* @param outputSize Where to store output length
* @return OK for success, otherwise error code
*/
enum slip_result slip_encode(
unsigned char *frame,
unsigned long frameLength,
unsigned char *output,
unsigned long maxOutputSize,
unsigned long *outputSize
);
/**
* Decode a SLIP packet
* @param encodedFrame Data to decode
* @param frameLength Data length
* @param output Where to store the decoded data
* @param maxOutputSize Max output size
* @param outputSize Where to store output length
* @return OK for success, otherwise error code
*/
enum slip_result slip_decode(
unsigned char *encodedFrame,
unsigned long frameLength,
unsigned char *output,
unsigned long maxOutputSize,
unsigned long *outputSize
);