51 lines
1.3 KiB
C
Raw Normal View History

2022-11-04 09:35:17 +01:00
//**************************************************************************************
/*! \copyright: 2020-2021 Thales Alenia Space Deutschland GmbH
* \project: multiMIND
* \file: (name of source file: hdlc.h)
* \date: (09.02.2022)
* \author: (Stelios Filippopoulos)
* \brief: (hdlc header file)
* \language: (C)
**************************************************************************************
*/
#ifndef LIB_HDLC_H_
#define LIB_HDLC_H_
2022-11-04 12:38:30 +01:00
#ifdef __cplusplus
extern "C" {
#endif
#include <stdint.h>
#include <stddef.h>
2022-11-04 09:35:17 +01:00
#define HDLC_ENABLE
#define HDLC_START_BYTE (0x7Eu)
#define HDLC_ESC_BYTE (0x7Du)
#define HDLC_END_BYTE (0x7Cu)
#define HDLC_ESCAPE_CHAR (0x20u)
2022-11-04 12:38:30 +01:00
void hdlc_add_framing(const uint8_t *src, size_t slen, uint8_t *dst, size_t *dlen);
2022-11-16 14:42:18 +01:00
/**
* Decode a HDLC frame, including CRC check and CRC removal in addition
* to the removal of the frame markers.
* @param src
* @param slen
* @param dst
* @param dlen
* @return
* -1 Invalid source length
* -2 No start marker at first byte or end marker at slen - 1
* 1 Invalid CRC
* 0 CRC OK, framing and CRC removed
*/
int hdlc_remove_framing_with_crc_check(const uint8_t *src, size_t slen, uint8_t *dst, size_t *dlen);
2022-11-04 09:35:17 +01:00
2022-11-04 12:38:30 +01:00
#ifdef __cplusplus
}
#endif
2022-11-04 09:35:17 +01:00
#endif /* LIB_HDLC_H_ */