1 #include "checksum.hpp"
7 checksum_error::checksum_error(uint8_t expected
, uint8_t actual
)
12 text
, sizeof(text
), "checksum error (actual:%02X, expected:%02X)", actual
, expected
);
18 static constexpr char hex_digit(unsigned int t
) noexcept
20 return "0123456789ABCDEF"[t
& 0xf];
25 /// Returns the specified checksum as string.
27 /// @param[in] sum The checksum to render as string.
28 /// @return The checksum as string. This string is always two characters.
30 std::string
checksum_to_string(uint8_t sum
)
32 char buf
[3]{detail::hex_digit(sum
>> 4), detail::hex_digit(sum
), '\0'};