• 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

0.0
/src/rpc/rpc_device_probe_task.cpp
1
#include "rpc_device_probe_task.h"
2
#include "port/serial_port.h"
3
#include "rpc_helpers.h"
4
#include "rpc_port_handler.h"
5
#include "rpc_port_scan_serial_client_task.h"
6

7
#define LOG(logger) ::logger.Log() << "[RPC] "
8

9
template<> bool inline WBMQTT::JSON::Is<uint8_t>(const Json::Value& value)
×
10
{
11
    return value.isUInt();
×
12
}
13

14
template<> inline uint8_t WBMQTT::JSON::As<uint8_t>(const Json::Value& value)
×
15
{
16
    return value.asUInt() & 0xFF;
×
17
}
18

19
TRPCDeviceProbeSerialClientTask::TRPCDeviceProbeSerialClientTask(const Json::Value& request,
×
20
                                                                 WBMQTT::TMqttRpcServer::TResultCallback onResult,
21
                                                                 WBMQTT::TMqttRpcServer::TErrorCallback onError)
×
UNCOV
22
    : SerialPortSettings(ParseRPCSerialPortSettings(request)),
×
23
      ExpireTime(std::chrono::steady_clock::now() + DefaultRPCTotalTimeout),
×
UNCOV
24
      OnResult(onResult),
×
25
      OnError(onError)
×
26
{
27
    WBMQTT::JSON::Get(request, "slave_id", SlaveId);
×
UNCOV
28
    std::string protocol;
×
UNCOV
29
    WBMQTT::JSON::Get(request, "protocol", protocol);
×
30
    ModbusTraits = MakeModbusTraits(protocol);
×
UNCOV
31
}
×
32

UNCOV
33
ISerialClientTask::TRunResult TRPCDeviceProbeSerialClientTask::Run(PFeaturePort port,
×
34
                                                                   TSerialClientDeviceAccessHandler& lastAccessedDevice,
35
                                                                   const std::list<PSerialDevice>& polledDevices)
36
{
UNCOV
37
    if (IsCancelled()) {
×
38
        AnswerRequestCancelled(OnError);
×
UNCOV
39
        return ISerialClientTask::TRunResult::OK;
×
40
    }
UNCOV
41
    if (std::chrono::steady_clock::now() > ExpireTime) {
×
42
        if (OnError) {
×
43
            OnError(WBMQTT::E_RPC_REQUEST_TIMEOUT, "RPC request timeout");
×
44
        }
45
        return ISerialClientTask::TRunResult::OK;
×
46
    }
47

48
    try {
49
        if (!port->IsOpen()) {
×
50
            port->Open();
×
51
        }
52
        lastAccessedDevice.PrepareToAccess(*port, nullptr);
×
UNCOV
53
        TSerialPortSettingsGuard settingsGuard(port, SerialPortSettings);
×
UNCOV
54
        RpcPortScan::TRegisterReader reader(*port, *ModbusTraits, SlaveId);
×
UNCOV
55
        OnResult(RpcPortScan::GetDeviceDetails(reader, SlaveId, polledDevices));
×
56
    } catch (const std::exception& error) {
×
UNCOV
57
        if (OnError) {
×
UNCOV
58
            OnError(WBMQTT::E_RPC_SERVER_ERROR, std::string("Port IO error: ") + error.what());
×
59
        }
UNCOV
60
    }
×
61

UNCOV
62
    return ISerialClientTask::TRunResult::OK;
×
63
}
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