From b2529089f4d306f63a47bc917f0019ed96ca76e8 Mon Sep 17 00:00:00 2001 From: linbo <1034003879@qq.com> Date: Wed, 19 Aug 2026 10:53:29 +0800 Subject: [PATCH] fix(ethercat): log CiA402 device state transitions --- .../src/cia402/cia402_status_monitor.cpp | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/cmvr-es/devices/motor/drivers/ethercat_motor/src/cia402/cia402_status_monitor.cpp b/cmvr-es/devices/motor/drivers/ethercat_motor/src/cia402/cia402_status_monitor.cpp index 1e0eeb5f..d5e3b47f 100644 --- a/cmvr-es/devices/motor/drivers/ethercat_motor/src/cia402/cia402_status_monitor.cpp +++ b/cmvr-es/devices/motor/drivers/ethercat_motor/src/cia402/cia402_status_monitor.cpp @@ -153,8 +153,11 @@ void Cia402StatusMonitor::reportStatuswordTransition_( const StatusSample& previous, const StatusSample& current) const { - const bool status_changed = + const bool device_state_changed = !had_previous || !previous.read_ok || + (previous.statusword & 0x006F) != (current.statusword & 0x006F); + const bool status_changed = + device_state_changed || previous.status_problem != current.status_problem || (previous.statusword & 0x0888) != (current.statusword & 0x0888); if (current.status_problem && status_changed) { @@ -178,9 +181,20 @@ void Cia402StatusMonitor::reportStatuswordTransition_( previous.status_problem) { CMVR_LOG(INFO) << "[Cia402StatusMonitor] [statusword] recovered" << ", node=" << static_cast(node_id) + << ", current_statusword=0x" << std::hex << std::uppercase + << std::setw(4) << std::setfill('0') << current.statusword + << std::dec << std::nouppercase << std::setfill(' ') + << ' ' << deviceStateName_(current.statusword) << ", previous_statusword=0x" << std::hex << std::uppercase << std::setw(4) << std::setfill('0') << previous.statusword << std::dec << std::nouppercase << std::setfill(' '); + } else if (device_state_changed) { + CMVR_LOG(INFO) << "[Cia402StatusMonitor] [statusword] 0x" + << std::hex << std::uppercase << std::setw(4) + << std::setfill('0') << current.statusword + << std::dec << std::nouppercase << std::setfill(' ') + << ' ' << deviceStateName_(current.statusword) + << ", node=" << static_cast(node_id); } }