From 7b00de2803fef4469c080491edadf8228fddc6da Mon Sep 17 00:00:00 2001 From: Ilia Date: Mon, 27 Apr 2026 10:47:49 +0300 Subject: [PATCH 1/6] feat: ardupilot message generation --- CMakeLists.txt | 5 ++++- cmake/generate_dsdl.cmake | 2 +- include/libdcnode/pub.hpp | 3 ++- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 5978290..539c13a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -8,7 +8,10 @@ project(libdcnode VERSION 0.6.0 LANGUAGES C CXX) # # 1. Generate DSDL # -set(DSDL_IN_DIR "${CMAKE_CURRENT_LIST_DIR}/Libs/DSDL/uavcan") +set(DSDL_IN_DIRS + "${CMAKE_CURRENT_LIST_DIR}/Libs/DSDL/uavcan" + "${CMAKE_CURRENT_LIST_DIR}/Libs/DSDL/ardupilot" +) set(DSDL_OUT_DIR "${CMAKE_CURRENT_BINARY_DIR}/generated/libdcnode/serialization") set(DSDL_COMPILER "${CMAKE_CURRENT_LIST_DIR}/Libs/dronecan_dsdlc/dronecan_dsdlc.py") include(${CMAKE_CURRENT_LIST_DIR}/cmake/generate_dsdl.cmake) diff --git a/cmake/generate_dsdl.cmake b/cmake/generate_dsdl.cmake index 3933ee9..89f6e92 100644 --- a/cmake/generate_dsdl.cmake +++ b/cmake/generate_dsdl.cmake @@ -22,7 +22,7 @@ endif() if(_run_dsdlc) message(STATUS "Generating DSDL sources into: ${DSDL_OUT_DIR}") execute_process( - COMMAND ${DSDL_COMPILER} -O ${DSDL_OUT_DIR} ${DSDL_IN_DIR} + COMMAND ${DSDL_COMPILER} -O ${DSDL_OUT_DIR} ${DSDL_IN_DIRS} RESULT_VARIABLE ret ) if(NOT ret EQUAL 0) diff --git a/include/libdcnode/pub.hpp b/include/libdcnode/pub.hpp index 9723628..770fd0d 100644 --- a/include/libdcnode/pub.hpp +++ b/include/libdcnode/pub.hpp @@ -19,7 +19,7 @@ // Max encoded message size (bytes) for publisher stack buffer. // Override via -DLIBDCNODE_MAX_PUB_MESSAGE_SIZE=... if your DSDL set requires more. #ifndef LIBDCNODE_MAX_PUB_MESSAGE_SIZE -#define LIBDCNODE_MAX_PUB_MESSAGE_SIZE 250U +#define LIBDCNODE_MAX_PUB_MESSAGE_SIZE 600U #endif // Initial delay before first publish after boot/reset (ms). @@ -65,6 +65,7 @@ namespace libdcnode LIBDCNODE_DEFINE_PUB_TRAITS(::uavcan_equipment_actuator_Status, UAVCAN_EQUIPMENT_ACTUATOR_STATUS) LIBDCNODE_DEFINE_PUB_TRAITS(::uavcan_equipment_esc_Status, UAVCAN_EQUIPMENT_ESC_STATUS) LIBDCNODE_DEFINE_PUB_TRAITS(::uavcan_equipment_hardpoint_Status, UAVCAN_EQUIPMENT_HARDPOINT_STATUS) + LIBDCNODE_DEFINE_PUB_TRAITS(::ardupilot_equipment_power_BatteryInfoAux, ARDUPILOT_EQUIPMENT_POWER_BATTERYINFOAUX) template class DronecanPub From 74fada7d8240d78ba01eb9d79fd9b19ff021915b Mon Sep 17 00:00:00 2001 From: PonomarevDA Date: Thu, 12 Mar 2026 00:26:04 +0300 Subject: [PATCH 2/6] feat: add BeginFirmwareUpdate --- src/dronecan.cpp | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/dronecan.cpp b/src/dronecan.cpp index 8b71d18..2adbd5c 100644 --- a/src/dronecan.cpp +++ b/src/dronecan.cpp @@ -12,6 +12,7 @@ #include "libdcnode/legacy/uavcan/protocol/restart_node.h" #include "libdcnode/legacy/uavcan/protocol/param/execute_opcode.h" #include "libdcnode/legacy/uavcan/protocol/param/getset.h" +#include "uavcan.protocol.file.BeginFirmwareUpdate.h" #include "libdcnode/can_driver.h" #include "libdcnode/platform.hpp" @@ -92,6 +93,7 @@ static void uavcanParamExecuteOpcodeHandle(CanardRxTransfer *transfer); static void uavcanProtocolRestartNodeHandle(CanardRxTransfer *transfer); static void uavcanProtocolGetTransportStatHandle(CanardRxTransfer *transfer); static void uavcanProtocolNodeStatusHandle(CanardRxTransfer *transfer); +static void uavcanProtocolBeginFirmwareUpdateHandle(CanardRxTransfer *transfer); int8_t uavcanSubscribe(uint64_t signature, uint16_t id, void (*callback)(CanardRxTransfer *)) { @@ -454,6 +456,17 @@ static void uavcanProtocolNodeStatusHandle(CanardRxTransfer *transfer) } } +static void uavcanProtocolBeginFirmwareUpdateHandle(CanardRxTransfer *transfer) +{ + if (transfer == NULL || transfer->transfer_type != CanardRequest) + { + return; + } + + // Do not send a response intentionally; just force a reboot so the bootloader takes over. + (void)platform.requestRestart(); +} + int16_t uavcanInitApplication(ParamsApi params_api, PlatformApi platform_api, const AppInfo *app_info) { if (app_info) @@ -500,6 +513,9 @@ int16_t uavcanInitApplication(ParamsApi params_api, PlatformApi platform_api, co uavcanSubscribe(UAVCAN_PROTOCOL_RESTART_NODE, uavcanProtocolRestartNodeHandle); uavcanSubscribe(UAVCAN_PROTOCOL_GET_TRANSPORT_STATS, uavcanProtocolGetTransportStatHandle); uavcanSubscribe(UAVCAN_PROTOCOL_NODE_STATUS, uavcanProtocolNodeStatusHandle); + uavcanSubscribe(UAVCAN_PROTOCOL_FILE_BEGINFIRMWAREUPDATE_SIGNATURE, + UAVCAN_PROTOCOL_FILE_BEGINFIRMWAREUPDATE_ID, + uavcanProtocolBeginFirmwareUpdateHandle); return 0; } From 8c2ef6a5dc4f292a656eb8dceb9bb112440503dc Mon Sep 17 00:00:00 2001 From: PonomarevDA Date: Tue, 14 Apr 2026 07:31:28 +0300 Subject: [PATCH 3/6] feat: add more pubs and subs --- include/libdcnode/pub.hpp | 6 ++++++ include/libdcnode/sub.hpp | 2 ++ 2 files changed, 8 insertions(+) diff --git a/include/libdcnode/pub.hpp b/include/libdcnode/pub.hpp index 770fd0d..f5cf60e 100644 --- a/include/libdcnode/pub.hpp +++ b/include/libdcnode/pub.hpp @@ -62,10 +62,16 @@ namespace libdcnode LIBDCNODE_DEFINE_PUB_TRAITS(::uavcan_equipment_ahrs_MagneticFieldStrength2, UAVCAN_EQUIPMENT_AHRS_MAGNETICFIELDSTRENGTH2) LIBDCNODE_DEFINE_PUB_TRAITS(::uavcan_equipment_camera_gimbal_Status, UAVCAN_EQUIPMENT_CAMERA_GIMBAL_STATUS) + LIBDCNODE_DEFINE_PUB_TRAITS(::uavcan_equipment_actuator_ArrayCommand, + UAVCAN_EQUIPMENT_ACTUATOR_ARRAYCOMMAND) LIBDCNODE_DEFINE_PUB_TRAITS(::uavcan_equipment_actuator_Status, UAVCAN_EQUIPMENT_ACTUATOR_STATUS) LIBDCNODE_DEFINE_PUB_TRAITS(::uavcan_equipment_esc_Status, UAVCAN_EQUIPMENT_ESC_STATUS) LIBDCNODE_DEFINE_PUB_TRAITS(::uavcan_equipment_hardpoint_Status, UAVCAN_EQUIPMENT_HARDPOINT_STATUS) LIBDCNODE_DEFINE_PUB_TRAITS(::ardupilot_equipment_power_BatteryInfoAux, ARDUPILOT_EQUIPMENT_POWER_BATTERYINFOAUX) + LIBDCNODE_DEFINE_PUB_TRAITS(::uavcan_equipment_air_data_StaticPressure, + UAVCAN_EQUIPMENT_AIR_DATA_STATICPRESSURE) + LIBDCNODE_DEFINE_PUB_TRAITS(::uavcan_equipment_range_sensor_Measurement, + UAVCAN_EQUIPMENT_RANGE_SENSOR_MEASUREMENT) template class DronecanPub diff --git a/include/libdcnode/sub.hpp b/include/libdcnode/sub.hpp index 411b010..a96f98f 100644 --- a/include/libdcnode/sub.hpp +++ b/include/libdcnode/sub.hpp @@ -48,6 +48,8 @@ namespace libdcnode LIBDCNODE_DEFINE_SUB_TRAITS(::uavcan_equipment_hardpoint_Command, UAVCAN_EQUIPMENT_HARDPOINT_COMMAND) + LIBDCNODE_DEFINE_SUB_TRAITS(::uavcan_equipment_hardpoint_Status, + UAVCAN_EQUIPMENT_HARDPOINT_STATUS) LIBDCNODE_DEFINE_SUB_TRAITS(::uavcan_equipment_indication_LightsCommand, UAVCAN_EQUIPMENT_INDICATION_LIGHTSCOMMAND) LIBDCNODE_DEFINE_SUB_TRAITS(::uavcan_equipment_actuator_ArrayCommand, UAVCAN_EQUIPMENT_ACTUATOR_ARRAYCOMMAND) LIBDCNODE_DEFINE_SUB_TRAITS(::uavcan_equipment_camera_gimbal_AngularCommand, From d167f0889d74e8acc5077c8470016f2251bd3e32 Mon Sep 17 00:00:00 2001 From: PonomarevDA Date: Tue, 14 Apr 2026 07:49:41 +0300 Subject: [PATCH 4/6] fix: update node status pub rate from 2 hz to 1 hz --- .gitignore | 1 + include/libdcnode/legacy/uavcan/protocol/node_status.h | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 6d95ee8..8faf6a9 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ .vscode/ build/ .venv +.codex __pycache__/ diff --git a/include/libdcnode/legacy/uavcan/protocol/node_status.h b/include/libdcnode/legacy/uavcan/protocol/node_status.h index cfb7bbb..4f55d13 100644 --- a/include/libdcnode/legacy/uavcan/protocol/node_status.h +++ b/include/libdcnode/legacy/uavcan/protocol/node_status.h @@ -44,7 +44,7 @@ typedef struct { #define UAVCAN_PROTOCOL_NODE_STATUS_ID 341 #define UAVCAN_PROTOCOL_NODE_STATUS_SIGNATURE 0x0f0868d0c1a7c6f1 #define UAVCAN_PROTOCOL_NODE_STATUS_MESSAGE_SIZE 7 -#define NODE_STATUS_SPIN_PERIOD_MS 500 +#define NODE_STATUS_SPIN_PERIOD_MS 1000 #define UAVCAN_PROTOCOL_NODE_STATUS UAVCAN_EXPAND(UAVCAN_PROTOCOL_NODE_STATUS) #ifdef __cplusplus From 65512024dcc2ffcf3af1eb7ab4146e8fe17a6e47 Mon Sep 17 00:00:00 2001 From: Ilia Date: Mon, 27 Apr 2026 10:47:49 +0300 Subject: [PATCH 5/6] feat: ardupilot message generation --- include/libdcnode/pub.hpp | 1 + 1 file changed, 1 insertion(+) diff --git a/include/libdcnode/pub.hpp b/include/libdcnode/pub.hpp index f5cf60e..8c5f5e8 100644 --- a/include/libdcnode/pub.hpp +++ b/include/libdcnode/pub.hpp @@ -72,6 +72,7 @@ namespace libdcnode UAVCAN_EQUIPMENT_AIR_DATA_STATICPRESSURE) LIBDCNODE_DEFINE_PUB_TRAITS(::uavcan_equipment_range_sensor_Measurement, UAVCAN_EQUIPMENT_RANGE_SENSOR_MEASUREMENT) + LIBDCNODE_DEFINE_PUB_TRAITS(::ardupilot_equipment_power_BatteryInfoAux, ARDUPILOT_EQUIPMENT_POWER_BATTERYINFOAUX) template class DronecanPub From 53d05098ff4ae7c49bcc502549173a1514bb4b19 Mon Sep 17 00:00:00 2001 From: Ilia Date: Mon, 27 Apr 2026 12:19:40 +0300 Subject: [PATCH 6/6] fix: rm redundant definition --- include/libdcnode/pub.hpp | 1 - 1 file changed, 1 deletion(-) diff --git a/include/libdcnode/pub.hpp b/include/libdcnode/pub.hpp index 8c5f5e8..f5cf60e 100644 --- a/include/libdcnode/pub.hpp +++ b/include/libdcnode/pub.hpp @@ -72,7 +72,6 @@ namespace libdcnode UAVCAN_EQUIPMENT_AIR_DATA_STATICPRESSURE) LIBDCNODE_DEFINE_PUB_TRAITS(::uavcan_equipment_range_sensor_Measurement, UAVCAN_EQUIPMENT_RANGE_SENSOR_MEASUREMENT) - LIBDCNODE_DEFINE_PUB_TRAITS(::ardupilot_equipment_power_BatteryInfoAux, ARDUPILOT_EQUIPMENT_POWER_BATTERYINFOAUX) template class DronecanPub