1 #ifndef __IO__SEATALK_READER__HPP__
2 #define __IO__SEATALK_READER__HPP__
4 #include <marnav/io/device.hpp>
5 #include <marnav/seatalk/message.hpp>
12 /// This class reads SeaTalk messages from a device. Normally this would
13 /// be a serial character device (e.g. /dev/ttyS0 or /dev/ttyUSB0).
15 /// In order to use this SeaTalk reader, it must be subclassed.
17 /// @example read_seatalk.cpp
21 seatalk_reader(std::unique_ptr
<device
> && dev
);
22 virtual ~seatalk_reader();
26 uint32_t get_collisions() const { return ctx
.collisions
; }
29 virtual void process_message(const seatalk::raw
&) = 0;
32 enum class State
{ READ
, ESCAPE
, PARITY
};
38 uint8_t data
[seatalk::MAX_MESSAGE_SIZE
];
46 uint8_t parity(uint8_t a
) const;
47 void write_cmd(uint8_t c
);
48 void write_data(uint8_t c
);
49 void process_seatalk();
53 std::unique_ptr
<device
> dev
; ///< Device to read data from.