43 uart::sensors::UartSensor*
operator->() {
return &_sensor; };
48 std::unique_ptr<uart::protocol::Packet>
findPacket(uint8_t dataByte);
56 const std::string _name;
59 uart::sensors::UartSensor _sensor{ ENDIANNESS,
66 PACKET_HEADER_LENGTH };
74 static void packetFinderFunction(
const std::vector<uint8_t>& data,
75 const uart::xplat::TimeStamp& timestamp,
76 uart::sensors::UartSensor::ValidPacketFoundHandler dispatchPacket,
void* dispatchPacketUserData,
82 static uart::protocol::Packet::Type packetTypeFunction(
const uart::protocol::Packet& packet);
87 static bool checksumFunction(
const uart::protocol::Packet& packet);
91 static bool isErrorFunction(
const uart::protocol::Packet& packet);
95 static bool isResponseFunction(
const uart::protocol::Packet& packet);
97 static constexpr uart::Endianness ENDIANNESS = uart::Endianness::ENDIAN_LITTLE;
98 static constexpr size_t PACKET_HEADER_LENGTH = 2;
99 static constexpr uint8_t ASCII_END_CHAR_1 =
'\r';
100 static constexpr uint8_t ASCII_END_CHAR_2 =
'\n';
101 static constexpr uint8_t ASCII_ESCAPE_CHAR =
'\0';
103 bool _currentlyBuildingAsciiPacket{
false };
104 bool _currentlyBuildingBinaryPacket{
false };
106 bool _asciiEndChar1Found{
false };
107 bool _binarySyncChar2Found{
false };
108 bool _binaryMsgIdFound{
false };
109 bool _binaryPayloadLength1Found{
false };
110 bool _binaryPayloadLength2Found{
false };
113 uint8_t _binaryMsgId{ 0 };
115 uint16_t _binaryPayloadLength{ 0 };
118 std::vector<uint8_t> _buffer;
121 size_t _runningDataIndex{ 0 };
123 size_t _numOfBytesRemainingForCompletePacket{ 0 };
126 void resetTracking();