completed ring buffer parser
Some checks are pending
EIVE/eive-obsw/pipeline/head Build started...
EIVE/eive-obsw/pipeline/pr-develop This commit looks good

This commit is contained in:
2022-11-04 12:38:30 +01:00
parent af0853a42b
commit b5cd873f6d
6 changed files with 28 additions and 41 deletions

View File

@ -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;

View File

@ -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;

View File

@ -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

View File

@ -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_ */