completed ring buffer parser
This commit is contained in:
2
thirdparty/tas/crc.c
vendored
2
thirdparty/tas/crc.c
vendored
@ -181,7 +181,7 @@ void calc_crc16_byte_reflected(uint16_t *crc16, uint8_t bt)
|
||||
}
|
||||
|
||||
// initial: 0xFFFF, xorOut: 0xFFFF, RefIn: true, RefOut: true, polynomial: 0x1021
|
||||
uint16_t calc_crc16_buff_reflected(uint8_t *data, uint16_t len)
|
||||
uint16_t calc_crc16_buff_reflected(const uint8_t *data, uint16_t len)
|
||||
{
|
||||
uint16_t crc16 = 0xFFFF;
|
||||
|
||||
|
7
thirdparty/tas/hdlc.c
vendored
7
thirdparty/tas/hdlc.c
vendored
@ -9,10 +9,11 @@
|
||||
**************************************************************************************
|
||||
*/
|
||||
|
||||
#include <stdint.h>
|
||||
#include "tas/hdlc.h"
|
||||
#include "tas/crc.h"
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
static void hdlc_add_byte(uint8_t ch, uint8_t *buff, uint16_t *pos)
|
||||
{
|
||||
uint16_t templen = *pos;
|
||||
@ -29,7 +30,7 @@ static void hdlc_add_byte(uint8_t ch, uint8_t *buff, uint16_t *pos)
|
||||
*pos = templen;
|
||||
}
|
||||
|
||||
void hdlc_add_framing(uint8_t *src, uint16_t slen, uint8_t *dst, uint16_t *dlen)
|
||||
void hdlc_add_framing(const uint8_t *src, size_t slen, uint8_t *dst, size_t *dlen)
|
||||
{
|
||||
uint16_t tlen = 0;
|
||||
uint16_t ii;
|
||||
@ -54,7 +55,7 @@ void hdlc_add_framing(uint8_t *src, uint16_t slen, uint8_t *dst, uint16_t *dlen)
|
||||
*dlen = tlen;
|
||||
}
|
||||
|
||||
void hdlc_remove_framing(uint8_t *src, uint16_t slen, uint8_t *dst, uint16_t *dlen)
|
||||
void hdlc_remove_framing(const uint8_t *src, size_t slen, uint8_t *dst, size_t *dlen)
|
||||
{
|
||||
uint16_t tlen = 0;
|
||||
uint16_t ii;
|
||||
|
2
thirdparty/tas/tas/crc.h
vendored
2
thirdparty/tas/tas/crc.h
vendored
@ -103,5 +103,5 @@ void calc_crc16_byte_reflected(uint16_t *crc16, uint8_t bt);
|
||||
* \param final_xor The value that the final result will be xored
|
||||
* \return CRC result
|
||||
*/
|
||||
uint16_t calc_crc16_buff_reflected(uint8_t *data, uint16_t len);
|
||||
uint16_t calc_crc16_buff_reflected(const uint8_t *data, uint16_t len);
|
||||
#endif
|
||||
|
15
thirdparty/tas/tas/hdlc.h
vendored
15
thirdparty/tas/tas/hdlc.h
vendored
@ -12,6 +12,13 @@
|
||||
#ifndef LIB_HDLC_H_
|
||||
#define LIB_HDLC_H_
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stddef.h>
|
||||
|
||||
#define HDLC_ENABLE
|
||||
|
||||
#define HDLC_START_BYTE (0x7Eu)
|
||||
@ -19,8 +26,12 @@
|
||||
#define HDLC_END_BYTE (0x7Cu)
|
||||
#define HDLC_ESCAPE_CHAR (0x20u)
|
||||
|
||||
void hdlc_add_framing(uint8_t *src, uint16_t slen, uint8_t *dst, uint16_t *dlen);
|
||||
void hdlc_add_framing(const uint8_t *src, size_t slen, uint8_t *dst, size_t *dlen);
|
||||
|
||||
void hdlc_remove_framing(uint8_t *src, uint16_t slen, uint8_t *dst, uint16_t *dlen);
|
||||
void hdlc_remove_framing(const uint8_t *src, size_t slen, uint8_t *dst, size_t *dlen);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* LIB_HDLC_H_ */
|
||||
|
Reference in New Issue
Block a user