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

wirenboard / wb-mqtt-serial / 666

08 Jul 2025 11:10AM UTC coverage: 73.854% (+0.1%) from 73.706%
666

push

github

web-flow
Port handling refactoring (#960)

Pass port by reference when needed instead of storing it in every device

6444 of 9057 branches covered (71.15%)

526 of 700 new or added lines in 56 files covered. (75.14%)

6 existing lines in 5 files now uncovered.

12341 of 16710 relevant lines covered (73.85%)

305.53 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 "rpc_helpers.h"
3
#include "rpc_port_handler.h"
4
#include "rpc_port_scan_serial_client_task.h"
5
#include "serial_port.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
}
29

30
ISerialClientTask::TRunResult TRPCDeviceProbeSerialClientTask::Run(PPort port,
×
31
                                                                   TSerialClientDeviceAccessHandler& lastAccessedDevice,
32
                                                                   const std::list<PSerialDevice>& polledDevices)
33
{
34
    if (std::chrono::steady_clock::now() > ExpireTime) {
×
35
        if (OnError) {
×
36
            OnError(WBMQTT::E_RPC_REQUEST_TIMEOUT, "RPC request timeout");
×
37
        }
38
        return ISerialClientTask::TRunResult::OK;
×
39
    }
40

41
    try {
42
        if (!port->IsOpen()) {
×
43
            port->Open();
×
44
        }
NEW
45
        lastAccessedDevice.PrepareToAccess(*port, nullptr);
×
46
        TSerialPortSettingsGuard settingsGuard(port, SerialPortSettings);
×
47
        Modbus::TModbusRTUTraits modbusTraits;
×
48
        RpcPortScan::TRegisterReader reader(*port, modbusTraits, SlaveId);
×
49
        OnResult(RpcPortScan::GetDeviceDetails(reader, SlaveId, polledDevices));
×
50
    } catch (const std::exception& error) {
×
51
        if (OnError) {
×
52
            OnError(WBMQTT::E_RPC_SERVER_ERROR, std::string("Port IO error: ") + error.what());
×
53
        }
54
    }
55

56
    return ISerialClientTask::TRunResult::OK;
×
57
}
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