1 #include <marnav-io/default_seatalk_reader.hpp>
3 /// @example simple_seatalk_nmea_converter.cpp
4 /// This is a very simplistic conversion from SeaTalk messages to NMEA sentences.
6 /// SeaTalk message are being read from a serial port, converted to a corresponding
7 /// NMEA message, which is sent on another serial port.
9 /// This example uses the marnav::io::default_seatalk_reader to read SeaTalk
10 /// messages and \c boost.asio to send NMEA sentences.
16 default_seatalk_reader::default_seatalk_reader(std::unique_ptr
<device
> && dv
)
17 : seatalk_reader(std::move(dv
))
18 , message_received_(false)
22 /// Reads synchronously messages from the device.
24 /// @param[out] data The received message.
25 /// @retval true Success.
26 /// @retval false End of file.
27 /// @exception std::runtime_error
28 bool default_seatalk_reader::read_message(seatalk::raw
& data
)
30 // reads as long as the message is not complete.
32 // the message was received, return it and reset the 'semaphore'.
33 // please note: this works only in single threaded environment,
34 // since the 'semaphore' isn't really one.
35 if (message_received_
) {
37 message_received_
= false;
44 /// Processes the received message. Uses the data member 'message_received'
45 /// as poor-mans semaphore to signal the receipt.
47 /// After the reception, the message will be stored temporarily.
48 void default_seatalk_reader::process_message(const seatalk::raw
& msg
)
51 message_received_
= true;