4#include "cool_serial/byte_queue.hpp"
5#include "cool_serial/continuous_parser.hpp"
6#include "cool_serial/idata_handler.hpp"
12#include <unordered_map>
25 template<tap::communication::serial::Uart::UartPort kPort,
int kBaudrate>
30 using HandlerMap = std::unordered_map<coolSerial::Byte, DataHandlerRef>;
35 handlerMap_{handlerMap}
47 uart_.
init<kPort, kBaudrate, tap::communication::serial::Uart::Parity::Disabled>();
65 handlerMap_.at(dataType) = handler;
69 void updateByteQueue()
75 byteQueue_.push(
byte);
81 if(!parser_.currentMessageProcessed())
83 referMessage(parser_.getCurrentMessage());
86 void referMessage(
const coolSerial::CoolMessageData& message)
90 handlerMap_.at(message.dataType).get().handleData(message.data);
95 coolSerial::ByteQueue byteQueue_{};
96 coolSerial::ContinuousParser parser_{byteQueue_};
Definition cool_serial_uart.hpp:27
CoolSerialUart(tap::Drivers &drivers, const HandlerMap &handlerMap)
Definition cool_serial_uart.hpp:32
std::unordered_map< coolSerial::Byte, DataHandlerRef > HandlerMap
Definition cool_serial_uart.hpp:30
void addHandler(coolSerial::Byte dataType, DataHandlerRef handler)
Definition cool_serial_uart.hpp:61
std::reference_wrapper< coolSerial::IDataHandler > DataHandlerRef
Definition cool_serial_uart.hpp:29
CoolSerialUart(tap::Drivers &drivers)
Definition cool_serial_uart.hpp:39
void update()
Definition cool_serial_uart.hpp:50
void initialize()
Definition cool_serial_uart.hpp:45
Definition drivers.hpp:70
void init()
Definition uart.hpp:81
mockable bool read(UartPort port, uint8_t *data)
Definition uart.cpp:33
@ Uart1
Definition uart.hpp:52
Definition basic_target_handler.cpp:6
fang::Drivers & drivers
Definition robot_singleton.cpp:45