diff --git a/src/drivers/uavcan/actuators/esc.cpp b/src/drivers/uavcan/actuators/esc.cpp index 9e4bb64509..af560293dc 100644 --- a/src/drivers/uavcan/actuators/esc.cpp +++ b/src/drivers/uavcan/actuators/esc.cpp @@ -48,7 +48,8 @@ using namespace time_literals; UavcanEscController::UavcanEscController(uavcan::INode &node) : _node(node), _uavcan_pub_raw_cmd(node), - _uavcan_sub_status(node) + _uavcan_sub_status(node), + _uavcan_sub_status_extended(node) { _uavcan_pub_raw_cmd.setPriority(uavcan::TransferPriority::NumericallyMin); // Highest priority } @@ -64,6 +65,14 @@ UavcanEscController::init() return res; } + //ESC Status Extended subscription + res = _uavcan_sub_status_extended.start(StatusExtendedCbBinder(this, &UavcanEscController::esc_status_extended_sub_cb)); + + if (res < 0) { + PX4_ERR("ESC status extended sub failed %i", res); + return res; + } + _esc_status_pub.advertise(); int32_t iface_mask{0xFF}; diff --git a/src/drivers/uavcan/actuators/esc.hpp b/src/drivers/uavcan/actuators/esc.hpp index 1a8e45c608..0c513b13e7 100644 --- a/src/drivers/uavcan/actuators/esc.hpp +++ b/src/drivers/uavcan/actuators/esc.hpp @@ -47,9 +47,17 @@ #include #include #include +#include +#include #include +#include +#include #include -#include "../node_info.hpp" +#include +#include +#include +#include +#include class UavcanEscController { @@ -67,7 +75,7 @@ public: bool initialized() { return _initialized; }; - void update_outputs(uint16_t outputs[MAX_ACTUATORS], uint8_t output_array_size); + void update_outputs(bool stop_motors, uint16_t outputs[MAX_ACTUATORS], uint8_t output_array_size); /** * Sets the number of rotors and enable timer @@ -85,6 +93,10 @@ private: * ESC status message reception will be reported via this callback. */ void esc_status_sub_cb(const uavcan::ReceivedDataStructure &msg); + /** + * ESC extended status message reception will be stored via this callback. + */ + void esc_status_extended_sub_cb(const uavcan::ReceivedDataStructure &msg); /** * Checks all the ESCs freshness based on timestamp, if an ESC exceeds the timeout then is flagged offline. @@ -94,6 +106,10 @@ private: typedef uavcan::MethodBinder&)> StatusCbBinder; + typedef uavcan::MethodBinder&)> + StatusExtendedCbBinder; + typedef uavcan::MethodBinder TimerCbBinder; @@ -112,6 +128,7 @@ private: uavcan::INode &_node; uavcan::Publisher _uavcan_pub_raw_cmd; uavcan::Subscriber _uavcan_sub_status; + uavcan::Subscriber _uavcan_sub_status_extended; NodeInfoPublisher *_node_info_publisher{nullptr}; };