• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

wirenboard / wb-mqtt-serial / 2

20 Oct 2026 05:26AM UTC coverage: 86.772% (+13.9%) from 72.836%
2

Pull #1283

github

e3f11f
KraPete
Remove comment from service unit

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Pull Request #1283: Order service after mosquitto and restart it without limit

31090 of 80727 branches covered (38.51%)

22401 of 25816 relevant lines covered (86.77%)

2589.67 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

97.3
/src/bcd_utils.cpp
1
#include "bcd_utils.h"
2
#include <cassert>
3

4
// Placing 1-4 bytes to integer in a way it reads
5
// the same as original byte sequence:
6
// bytes: {0x12, 0x34, 0x56, 0x78}
7
// integer value: 0x12345678
8
// actual bytes in integer: 0x78563412
9
uint32_t PackBytes(uint8_t* bytes, WordSizes size)
21 ✔
10
{
11
    uint32_t ret = 0U;
21 ✔
12
    /* note the absense of breaks here.
13
    the execution will propagate to the very end of
14
    the switch statement*/
15
    switch (size) {
21 !
16
        case WordSizes::W32_SZ:
10 ✔
17
            ret |= (*bytes++ << 24);
10 ✔
18
        case WordSizes::W24_SZ:
13 ✔
19
            ret |= (*bytes++ << 16);
13 ✔
20
        case WordSizes::W16_SZ:
20 ✔
21
            ret |= (*bytes++ << 8);
20 ✔
22
        case WordSizes::W8_SZ:
21 ✔
23
            ret |= (*bytes << 0);
21 ✔
24
    }
25
    return ret;
21 ✔
26
}
27

28
uint64_t PackedBCD2Int(uint64_t packed, WordSizes size)
34 ✔
29
{
30
    uint32_t result = 0;
34 ✔
31
    int exp = 1;
34 ✔
32
    for (unsigned i = 0; i < static_cast<unsigned>(size); ++i) {
133 ✔
33
        auto tmp = static_cast<uint8_t>(packed >> (i * 8));
99 ✔
34
        result += ((tmp & 0x0f) * exp);
99 ✔
35
        exp *= 10;
99 ✔
36
        result += ((tmp >> 4) * exp);
99 ✔
37
        exp *= 10;
99 ✔
38
    }
39
    return result;
34 ✔
40
}
41
std::vector<uint8_t> IntToBCDArray(uint64_t value, WordSizes size)
5 ✔
42
{
43
    std::vector<uint8_t> result;
5 ✔
44
    result.resize(static_cast<unsigned>(size));
5 !
45

46
    for (unsigned i = 0; i < static_cast<unsigned>(size); i++) {
19 ✔
47
        // form byte from the end of value
48
        uint8_t byte = value % 10;
14 ✔
49
        value /= 10;
14 ✔
50
        byte |= (value % 10) << 4;
14 ✔
51
        value /= 10;
14 ✔
52
        result[static_cast<unsigned>(size) - i - 1] = byte;
14 ✔
53
    }
54
    return result;
5 ✔
55
}
×
56

57
uint32_t IntToPackedBCD(uint32_t value, WordSizes size)
5 ✔
58
{
59
    auto bcdArray = IntToBCDArray(value, size);
5 !
60
    return PackBytes(bcdArray.data(), size);
10 ✔
61
}
5 ✔
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE TRIAL · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc