| Line |
Branch |
Exec |
Source |
| 1 |
|
|
#include "sub_message_parser.h" |
| 2 |
|
|
|
| 3 |
|
✗ |
std::string sub_message_parser::parse_distance(const std::vector<uint8_t> &payload) |
| 4 |
|
|
{ |
| 5 |
|
✗ |
if (payload.size() != 2) { |
| 6 |
|
✗ |
std::cerr << "Warning: Distance payload isn't 2 bytes long." << std::endl; |
| 7 |
|
✗ |
return ERROR_VALUE; |
| 8 |
|
|
} |
| 9 |
|
|
|
| 10 |
|
|
const uint16_t distance_cm = |
| 11 |
|
✗ |
static_cast<uint16_t>(payload[0]) | |
| 12 |
|
✗ |
(static_cast<uint16_t>(payload[1]) << 8); |
| 13 |
|
|
|
| 14 |
|
✗ |
std::ostringstream oss; |
| 15 |
|
✗ |
oss << distance_cm; |
| 16 |
|
|
|
| 17 |
|
✗ |
return oss.str(); |
| 18 |
|
|
} |
| 19 |
|
|
|