Build: add GCC-13, Clang-14, Clang-15, Clang-16, Clang-17
[marnav.git] / src / marnav / seatalk / message_27.cpp
blob2107723b02e82c5cc3834181daec25c5d9b89159
1 #include <marnav/seatalk/message_27.hpp>
3 namespace marnav::seatalk
6 message_27::message_27()
7 : message(ID)
11 std::unique_ptr<message> message_27::parse(const raw & data)
13 check_size(data, SIZE);
15 std::unique_ptr<message> result = std::make_unique<message_27>();
16 auto & msg = static_cast<message_27 &>(*result);
18 uint16_t value = 0;
19 value += data[2];
20 value <<= 8;
21 value += data[3];
23 msg.temperature_ = value;
24 msg.temperature_ -= 100;
26 return result;
29 raw message_27::get_data() const
31 uint16_t value = (temperature_ + 100) & 0xffff;
33 return raw{static_cast<uint8_t>(ID), 0x01, static_cast<uint8_t>((value >> 8) & 0xff),
34 static_cast<uint8_t>((value >> 0) & 0xff)};