| Directory: | src/ |
|---|---|
| File: | src/message_parser/sub_message_parser/parse_co2.cpp |
| Date: | 2026-03-27 13:31:42 |
| Exec | Total | Coverage | |
|---|---|---|---|
| Lines: | 0 | 8 | 0.0% |
| Branches: | 0 | 14 | 0.0% |
| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | #include "sub_message_parser.h" | ||
| 2 | |||
| 3 | ✗ | std::string sub_message_parser::parse_co2(const std::vector<uint8_t> &payload) | |
| 4 | { | ||
| 5 | ✗ | if(payload.size() != 2) { | |
| 6 | ✗ | std::cerr << "Warning: CO2 payload isn't 2 bytes long." << std::endl; | |
| 7 | ✗ | return ERROR_VALUE; | |
| 8 | } | ||
| 9 | |||
| 10 | ✗ | const uint16_t co2 = static_cast<uint16_t>(payload[1] << 8 | payload[0]); | |
| 11 | |||
| 12 | ✗ | std::ostringstream oss; | |
| 13 | ✗ | oss << co2; | |
| 14 | |||
| 15 | ✗ | return oss.str(); | |
| 16 | } | ||
| 17 |