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

wirenboard / wb-mqtt-serial / 2

29 Dec 2025 12:28PM UTC coverage: 76.817% (+4.0%) from 72.836%
2

Pull #1045

github

54aa0c
pgasheev
up changelog
Pull Request #1045: Fix firmware version in WB-M1W2 template

6873 of 9161 branches covered (75.02%)

12966 of 16879 relevant lines covered (76.82%)

1651.61 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)
×
22
    : SerialPortSettings(ParseRPCSerialPortSettings(request)),
23
      ExpireTime(std::chrono::steady_clock::now() + DefaultRPCTotalTimeout),
×
24
      OnResult(onResult),
25
      OnError(onError)
×
26
{
27
    WBMQTT::JSON::Get(request, "slave_id", SlaveId);
×
28
    std::string protocol;
×
29
    WBMQTT::JSON::Get(request, "protocol", protocol);
×
30
    if (protocol == "modbus-tcp") {
×
31
        ModbusTraits = std::make_unique<Modbus::TModbusTCPTraits>();
×
32
    } else {
33
        ModbusTraits = std::make_unique<Modbus::TModbusRTUTraits>();
×
34
    }
35
}
36

37
ISerialClientTask::TRunResult TRPCDeviceProbeSerialClientTask::Run(PFeaturePort port,
×
38
                                                                   TSerialClientDeviceAccessHandler& lastAccessedDevice,
39
                                                                   const std::list<PSerialDevice>& polledDevices)
40
{
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);
×
53
        TSerialPortSettingsGuard settingsGuard(port, SerialPortSettings);
×
54
        RpcPortScan::TRegisterReader reader(*port, *ModbusTraits, SlaveId);
×
55
        OnResult(RpcPortScan::GetDeviceDetails(reader, SlaveId, polledDevices));
×
56
    } catch (const std::exception& error) {
×
57
        if (OnError) {
×
58
            OnError(WBMQTT::E_RPC_SERVER_ERROR, std::string("Port IO error: ") + error.what());
×
59
        }
60
    }
61

62
    return ISerialClientTask::TRunResult::OK;
×
63
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc