v1.17.0 #327
@ -941,41 +941,15 @@ ReturnValue_t PlocSupvHelper::parseRecRingBufForHdlc(size_t& readSize) {
|
||||
if (encodedBuf[idx] == HDLC_END_MARKER) {
|
||||
if (startMarkerFound) {
|
||||
// Probably a packet, so decode it
|
||||
size_t decodedLen = 0;
|
||||
hdlc_remove_framing(encodedBuf.data() + startIdx, idx + 1, decodedBuf.data(), &decodedLen);
|
||||
readSize = decodedLen;
|
||||
return returnvalue::OK;
|
||||
} else {
|
||||
readSize = ++idx;
|
||||
return POSSIBLE_PACKET_LOSS_CONSECUTIVE_END;
|
||||
}
|
||||
}
|
||||
}
|
||||
// // handle ETX char
|
||||
// if (encodedBuf.first[vectorIdx] == DleEncoder::ETX_CHAR) {
|
||||
// if (stxFound) {
|
||||
// // This is propably a packet, so we decode it.
|
||||
// size_t decodedLen = 0;
|
||||
// size_t dummy = 0;
|
||||
//
|
||||
// ReturnValue_t result =
|
||||
// decoder.decode(&encodedBuf.first[stxIdx], availableData - stxIdx, &dummy,
|
||||
// decodedBuf.first, decodedBuf.second,
|
||||
//&decodedLen); if (result == returnvalue::OK) {
|
||||
//ctx.setType(ContextType::PACKET_FOUND); ctx.decodedPacket.first = decodedBuf.first;
|
||||
// ctx.decodedPacket.second = decodedLen;
|
||||
// readSize = ++vectorIdx;
|
||||
// return returnvalue::OK;
|
||||
// } else {
|
||||
// // invalid packet, skip.
|
||||
// readSize = ++vectorIdx;
|
||||
// ErrorInfo info;
|
||||
// info.res = result;
|
||||
// setErrorContext(ErrorTypes::DECODE_ERROR, info);
|
||||
// return POSSIBLE_PACKET_LOSS;
|
||||
// }
|
||||
// } else {
|
||||
// // might be lost packet, so we should advance the read pointer
|
||||
// readSize = ++vectorIdx;
|
||||
// ErrorInfo info;
|
||||
// info.len = 0;
|
||||
// setErrorContext(ErrorTypes::CONSECUTIVE_ETX_CHARS, info);
|
||||
// return POSSIBLE_PACKET_LOSS;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// return NO_PACKET_FOUND;
|
||||
return NO_PACKET_FOUND;
|
||||
}
|
||||
|
@ -226,6 +226,7 @@ class PlocSupvHelper : public DeviceCommunicationIF,
|
||||
#endif
|
||||
std::array<uint8_t, 2048> recBuf = {};
|
||||
std::array<uint8_t, 2048> encodedBuf = {};
|
||||
std::array<uint8_t, 1200> decodedBuf = {};
|
||||
SimpleRingBuffer recRingBuf;
|
||||
uint8_t commandBuffer[supv::MAX_COMMAND_SIZE]{};
|
||||
SpacePacketCreator creator;
|
||||
|
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_ */
|
||||
|
Loading…
Reference in New Issue
Block a user