added basic unittests for hdlc encoder
All checks were successful
EIVE/eive-obsw/pipeline/head This commit looks good
All checks were successful
EIVE/eive-obsw/pipeline/head This commit looks good
This commit is contained in:
@ -3,4 +3,22 @@
|
||||
|
||||
#include "rwHelpers.h"
|
||||
|
||||
void rws::encodeHdlc(const uint8_t* sourceBuf, size_t sourceLen, uint8_t* encodedBuffer,
|
||||
size_t& encodedLen) {
|
||||
encodedBuffer[0] = rws::FRAME_DELIMITER;
|
||||
encodedLen = 1;
|
||||
for (size_t sourceIdx = 0; sourceIdx < sourceLen; sourceIdx++) {
|
||||
if (sourceBuf[sourceIdx] == 0x7E) {
|
||||
encodedBuffer[encodedLen++] = 0x7D;
|
||||
encodedBuffer[encodedLen++] = 0x5E;
|
||||
} else if (sourceBuf[sourceIdx] == 0x7D) {
|
||||
encodedBuffer[encodedLen++] = 0x7D;
|
||||
encodedBuffer[encodedLen++] = 0x5D;
|
||||
} else {
|
||||
encodedBuffer[encodedLen++] = sourceBuf[sourceIdx];
|
||||
}
|
||||
}
|
||||
encodedBuffer[encodedLen++] = rws::FRAME_DELIMITER;
|
||||
}
|
||||
|
||||
#endif /* MISSION_DEVICES_DEVICEDEFINITIONS_RWHELPERS_CPP_ */
|
||||
|
Reference in New Issue
Block a user