45 uart::sensors::UartSensor*
operator->() {
return &_sensor; };
50 std::unique_ptr<uart::protocol::Packet>
findPacket(uint8_t dataByte);
58 const std::string _name;
61 uart::sensors::UartSensor _sensor{ ENDIANNESS,
68 PACKET_HEADER_LENGTH };
76 static void packetFinderFunction(
const std::vector<uint8_t>& data,
77 const uart::xplat::TimeStamp& timestamp,
78 uart::sensors::UartSensor::ValidPacketFoundHandler dispatchPacket,
void* dispatchPacketUserData,
84 static uart::protocol::Packet::Type packetTypeFunction(
const uart::protocol::Packet& packet);
89 static bool checksumFunction(
const uart::protocol::Packet& packet);
93 static bool isErrorFunction(
const uart::protocol::Packet& packet);
97 static bool isResponseFunction(
const uart::protocol::Packet& packet);
99 static constexpr uart::Endianness ENDIANNESS = uart::Endianness::ENDIAN_LITTLE;
100 static constexpr size_t PACKET_HEADER_LENGTH = 2;
101 static constexpr uint8_t ASCII_END_CHAR_1 =
'\r';
102 static constexpr uint8_t ASCII_END_CHAR_2 =
'\n';
103 static constexpr uint8_t ASCII_ESCAPE_CHAR =
'\0';
105 bool _currentlyBuildingAsciiPacket{
false };
106 bool _currentlyBuildingBinaryPacket{
false };
108 bool _asciiEndChar1Found{
false };
109 bool _binarySyncChar2Found{
false };
110 bool _binaryMsgClassFound{
false };
111 bool _binaryMsgIdFound{
false };
112 bool _binaryPayloadLength1Found{
false };
113 bool _binaryPayloadLength2Found{
false };
116 uint8_t _binaryMsgClass{ 0 };
118 uint8_t _binaryMsgId{ 0 };
120 uint16_t _binaryPayloadLength{ 0 };
123 std::vector<uint8_t> _buffer;
126 size_t _runningDataIndex{ 0 };
128 size_t _numOfBytesRemainingForCompletePacket{ 0 };
130#if LOG_LEVEL <= LOG_LEVEL_DATA
132 std::vector<uint8_t> _unrecognizedBytes;
136 void resetTracking();