18#include "uart/sensors/sensors.hpp"
48 std::unique_ptr<uart::protocol::Packet>
findPacket(uint8_t dataByte);
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);
97 static constexpr uart::Endianness
ENDIANNESS = uart::Endianness::ENDIAN_LITTLE;
static uart::protocol::Packet::Type packetTypeFunction(const uart::protocol::Packet &packet)
Function which is called to determine the packet type (ascii/binary)
bool _binaryPayloadLength1Found
Flag if the first byte of the payload length was found.
bool _binarySyncChar2Found
Flag if the second binary end character was found.
bool _binaryPayloadLength2Found
Flag if the second byte of the payload length was found.
bool _binaryMsgIdFound
Flag if the message id was found.
uart::sensors::UartSensor * operator->()
Arrow operator overload.
static constexpr size_t PACKET_HEADER_LENGTH
Length of the header of each packet.
~EmlidUartSensor()=default
Destructor.
size_t _runningDataIndex
Used for correlating raw data with where the packet was found for the end user.
bool _currentlyBuildingAsciiPacket
Flag if currently a ascii packet is built.
static bool isErrorFunction(const uart::protocol::Packet &packet)
Function which determines, if the packet is an Error Packet.
EmlidUartSensor(EmlidUartSensor &&)=delete
Move constructor.
EmlidUartSensor & operator=(const EmlidUartSensor &)=delete
Copy assignment operator.
static constexpr uint8_t ASCII_END_CHAR_1
First Ascii End character.
static bool isResponseFunction(const uart::protocol::Packet &packet)
Function which determines, if the packet is a Response.
std::vector< uint8_t > _buffer
Buffer to collect messages till they are complete.
void resetTracking()
Resets the current message tracking.
static constexpr uart::Endianness ENDIANNESS
Endianess of the sensor.
static constexpr uint8_t BINARY_SYNC_CHAR_2
E - Second sync character which begins a new binary message.
static bool checksumFunction(const uart::protocol::Packet &packet)
Function which is called to verify packet integrity.
uint16_t _binaryPayloadLength
Payload length of the current packet.
const std::string _name
Name of the Parent Node.
EmlidUartSensor(const EmlidUartSensor &)=delete
Copy constructor.
EmlidUartSensor()=default
Default constructor.
static constexpr uint8_t ASCII_START_CHAR
Ascii character which begins a new ascii message.
size_t _numOfBytesRemainingForCompletePacket
Amount of bytes remaining for a complete packet.
EmlidUartSensor & operator=(EmlidUartSensor &&)=delete
Move assignment operator.
static constexpr uint8_t ASCII_ESCAPE_CHAR
Ascii Escape charater.
uart::sensors::UartSensor _sensor
UartSensor object which handles the UART interface.
std::unique_ptr< uart::protocol::Packet > findPacket(uint8_t dataByte)
Collects data bytes and searches for packages inside of them.
static constexpr uint8_t ASCII_END_CHAR_2
Second Ascii End character.
uint8_t _binaryMsgId
Message id of the current packet.
static void packetFinderFunction(const std::vector< uint8_t > &data, const uart::xplat::TimeStamp ×tamp, uart::sensors::UartSensor::ValidPacketFoundHandler dispatchPacket, void *dispatchPacketUserData, void *userData)
Function which is called to find packets in the provided data buffer.
EmlidUartSensor(std::string name)
Constructor.
bool _asciiEndChar1Found
Flag if the first ascii end character was found.
static constexpr uint8_t BINARY_SYNC_CHAR_1
R - First sync character which begins a new binary message.
bool _currentlyBuildingBinaryPacket
Flag if currently a binary packet is built.