aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorKevin O'Connor <kevin@koconnor.net>2025-01-14 15:26:29 -0500
committerKevin O'Connor <kevin@koconnor.net>2025-02-02 18:43:34 -0500
commit2db2ef82f2c0ba08d7e72fbab355de0846272b3a (patch)
tree72b11156522886a068ba76fb399656270ad02859 /src
parenteb0581c2646fde09335615fbed8ed39641b096fc (diff)
downloadkutter-2db2ef82f2c0ba08d7e72fbab355de0846272b3a.tar.gz
kutter-2db2ef82f2c0ba08d7e72fbab355de0846272b3a.tar.xz
kutter-2db2ef82f2c0ba08d7e72fbab355de0846272b3a.zip
canbus_stats: Periodically report canbus interface statistics
Add support for a new get_canbus_status command to canserial.c . Add new canbus_stats.py module that will periodically query canbus mcus for connection status information. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Diffstat (limited to 'src')
-rw-r--r--src/generic/canserial.c21
1 files changed, 20 insertions, 1 deletions
diff --git a/src/generic/canserial.c b/src/generic/canserial.c
index d56235f5..b90eb659 100644
--- a/src/generic/canserial.c
+++ b/src/generic/canserial.c
@@ -2,7 +2,7 @@
//
// Copyright (C) 2019 Eug Krashtan <eug.krashtan@gmail.com>
// Copyright (C) 2020 Pontus Borg <glpontus@gmail.com>
-// Copyright (C) 2021 Kevin O'Connor <kevin@koconnor.net>
+// Copyright (C) 2021-2025 Kevin O'Connor <kevin@koconnor.net>
//
// This file may be distributed under the terms of the GNU GPLv3 license.
@@ -318,6 +318,25 @@ DECL_TASK(canserial_rx_task);
* Setup and shutdown
****************************************************************/
+DECL_ENUMERATION("canbus_bus_state", "active", CANBUS_STATE_ACTIVE);
+DECL_ENUMERATION("canbus_bus_state", "warn", CANBUS_STATE_WARN);
+DECL_ENUMERATION("canbus_bus_state", "passive", CANBUS_STATE_PASSIVE);
+DECL_ENUMERATION("canbus_bus_state", "off", CANBUS_STATE_OFF);
+
+void
+command_get_canbus_status(uint32_t *args)
+{
+ struct canbus_status status;
+ memset(&status, 0, sizeof(status));
+ canhw_get_status(&status);
+ sendf("canbus_status rx_error=%u tx_error=%u tx_retries=%u"
+ " canbus_bus_state=%u"
+ , status.rx_error, status.tx_error, status.tx_retries
+ , status.bus_state);
+}
+DECL_COMMAND_FLAGS(command_get_canbus_status, HF_IN_SHUTDOWN
+ , "get_canbus_status");
+
void
command_get_canbus_id(uint32_t *args)
{