Build: add GCC-13, Clang-14, Clang-15, Clang-16, Clang-17
[marnav.git] / src / marnav / nmea / checksum.cpp
blob23a8fe1e303ab9313df85d360ffe0fecc07384b8
1 #include <marnav/nmea/checksum.hpp>
2 #include "hex_digit.hpp"
4 namespace marnav::nmea
6 checksum_error::checksum_error(uint8_t exp, uint8_t act)
7 : expected_(exp)
8 , actual_(act)
10 snprintf(text_, sizeof(text_), "checksum error (actual:%02X, expected:%02X)", actual_,
11 expected_);
14 /// Returns the specified checksum as string.
15 ///
16 /// @param[in] sum The checksum to render as string.
17 /// @return The checksum as string. This string is always two characters.
18 ///
19 std::string checksum_to_string(uint8_t sum)
21 char buf[3]{detail::hex_digit(sum >> 4), detail::hex_digit(sum), '\0'};
22 return buf;