mirror of
https://github.com/PX4/PX4-Autopilot.git
synced 2026-05-27 10:17:45 +08:00
feat(uavcan): param for enabling/disabling tracing
This commit is contained in:
@@ -9,6 +9,8 @@ param set-default SYS_DM_BACKEND 1
|
|||||||
param set-default MAV_0_CONFIG 0
|
param set-default MAV_0_CONFIG 0
|
||||||
# Disable logger writing to FRAM, only stream over MAVLINK
|
# Disable logger writing to FRAM, only stream over MAVLINK
|
||||||
param set-default SDLOG_BACKEND 2
|
param set-default SDLOG_BACKEND 2
|
||||||
|
# Disable UAVCAN tracing
|
||||||
|
param set-default UAVCAN_TRACE_EN 0
|
||||||
|
|
||||||
# 200kOhm/10kOhm voltage divider on V_BAT
|
# 200kOhm/10kOhm voltage divider on V_BAT
|
||||||
param set-default BAT1_V_DIV 21
|
param set-default BAT1_V_DIV 21
|
||||||
|
|||||||
+5
@@ -37,10 +37,13 @@ class FileEventTracer : public uavcan::dynamic_node_id_server::IEventTracer
|
|||||||
typedef uavcan::MakeString<MaxPathLength>::Type PathString;
|
typedef uavcan::MakeString<MaxPathLength>::Type PathString;
|
||||||
|
|
||||||
PathString path_;
|
PathString path_;
|
||||||
|
bool initialized_ = false;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void onEvent(uavcan::dynamic_node_id_server::TraceCode code, uavcan::int64_t argument)
|
virtual void onEvent(uavcan::dynamic_node_id_server::TraceCode code, uavcan::int64_t argument)
|
||||||
{
|
{
|
||||||
|
if (!initialized_) { return; }
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
timespec ts = timespec(); // If clock_gettime() fails, zero time will be used
|
timespec ts = timespec(); // If clock_gettime() fails, zero time will be used
|
||||||
@@ -89,6 +92,8 @@ public:
|
|||||||
if (fd >= 0) {
|
if (fd >= 0) {
|
||||||
(void)close(fd);
|
(void)close(fd);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
initialized_ = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
return rv;
|
return rv;
|
||||||
|
|||||||
@@ -30,6 +30,13 @@ parameters:
|
|||||||
min: 1
|
min: 1
|
||||||
max: 125
|
max: 125
|
||||||
reboot_required: true
|
reboot_required: true
|
||||||
|
UAVCAN_TRACE_EN:
|
||||||
|
description:
|
||||||
|
short: UAVCAN event tracing
|
||||||
|
long: Enable logging of UAVCAN events
|
||||||
|
type: boolean
|
||||||
|
default: 1
|
||||||
|
reboot_required: true
|
||||||
UAVCAN_BITRATE:
|
UAVCAN_BITRATE:
|
||||||
description:
|
description:
|
||||||
short: UAVCAN CAN bus bitrate
|
short: UAVCAN CAN bus bitrate
|
||||||
|
|||||||
@@ -104,11 +104,16 @@ int UavcanServers::init()
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Initialize trace in the UAVCAN_NODE_DB_PATH directory */
|
/* Initialize trace in the UAVCAN_NODE_DB_PATH directory */
|
||||||
ret = _tracer.init(UAVCAN_LOG_FILE);
|
int32_t trace_en = 1;
|
||||||
|
(void)param_get(param_find("UAVCAN_TRACE_EN"), &trace_en);
|
||||||
|
|
||||||
if (ret < 0) {
|
if (trace_en) {
|
||||||
PX4_ERR("FileEventTracer init: %d, errno: %d", ret, errno);
|
ret = _tracer.init(UAVCAN_LOG_FILE);
|
||||||
return ret;
|
|
||||||
|
if (ret < 0) {
|
||||||
|
PX4_ERR("FileEventTracer init: %d, errno: %d", ret, errno);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* hardware version */
|
/* hardware version */
|
||||||
|
|||||||
Reference in New Issue
Block a user