-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathslip.h
30 lines (23 loc) · 840 Bytes
/
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
/*
* Copyright (c) 2019 Nordic Semiconductor
*
* SPDX-License-Identifier: LicenseRef-BSD-5-Clause-Nordic
*/
#ifndef _SLIP_H_
#define _SLIP_H_
#include <stdint.h>
#include <stdlib.h>
#define SLIP_DECODER_BUFFER_SIZE (256 * 1024)
typedef struct
{
size_t writeIndex; // where to put data in decoderPut
size_t readIndex; // where source data for decoding ended
// | temp decoded | encoded | free |
// ^readIndex ^writeIndex ^SLIP_DECODER_BUFFER_SIZE
uint8_t buffer[SLIP_DECODER_BUFFER_SIZE];
} DecoderContext;
size_t slip_encode(uint8_t *output, uint8_t *input, size_t length);
void slip_decode_init(DecoderContext *ctx);
size_t slip_decode_put(DecoderContext *ctx, uint8_t *input, size_t length);
size_t slip_decode_read(DecoderContext *ctx, uint8_t **result);
#endif