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

wirenboard / wb-mqtt-serial / 1

20 Oct 2026 04:57AM UTC coverage: 86.817% (+14.0%) from 72.836%
1

Pull #1281

github

fab311
KraPete
Fix device model fallback in device/LoadConfig RPC

The short model register was never read because the extended register
error was converted to TRPCException. The RPC error now says that
the device model could not be read.
Pull Request #1281: Fix device model fallback in device/LoadConfig RPC

31180 of 80922 branches covered (38.53%)

74 of 76 new or added lines in 2 files covered. (97.37%)

1379 existing lines in 84 files now uncovered.

22464 of 25875 relevant lines covered (86.82%)

5205.91 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)
42 ✔
10
{
11
    uint32_t ret = 0U;
42 ✔
12
    /* note the absense of breaks here.
13
    the execution will propagate to the very end of
14
    the switch statement*/
15
    switch (size) {
42 !
16
        case WordSizes::W32_SZ:
20 ✔
17
            ret |= (*bytes++ << 24);
20 ✔
18
        case WordSizes::W24_SZ:
26 ✔
19
            ret |= (*bytes++ << 16);
26 ✔
20
        case WordSizes::W16_SZ:
40 ✔
21
            ret |= (*bytes++ << 8);
40 ✔
22
        case WordSizes::W8_SZ:
42 ✔
23
            ret |= (*bytes << 0);
42 ✔
24
    }
25
    return ret;
42 ✔
26
}
27

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

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

57
uint32_t IntToPackedBCD(uint32_t value, WordSizes size)
10 ✔
58
{
59
    auto bcdArray = IntToBCDArray(value, size);
10 !
60
    return PackBytes(bcdArray.data(), size);
20 ✔
61
}
10 ✔
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