diff --git a/src/drivers/uavcan_v1/CMakeLists.txt b/src/drivers/uavcan_v1/CMakeLists.txt index b07540af96..39c4800696 100644 --- a/src/drivers/uavcan_v1/CMakeLists.txt +++ b/src/drivers/uavcan_v1/CMakeLists.txt @@ -124,6 +124,7 @@ px4_add_module( Publishers/uORB/uorb_publisher.cpp Subscribers/uORB/uorb_subscriber.cpp ${SRCS} + Publishers/Publisher.cpp o1heap/o1heap.c o1heap/o1heap.h ${LIBCANARD_DIR}/libcanard/canard.c diff --git a/src/drivers/uavcan_v1/Publishers/DS-015/Gnss.hpp b/src/drivers/uavcan_v1/Publishers/DS-015/Gnss.hpp index 1447e42ae2..f9babd4da4 100644 --- a/src/drivers/uavcan_v1/Publishers/DS-015/Gnss.hpp +++ b/src/drivers/uavcan_v1/Publishers/DS-015/Gnss.hpp @@ -45,7 +45,9 @@ #include #include -#include "../Publisher.hpp" +class UavcanNode; + +#include "Publisher.hpp" class UavcanGnssPublisher : public UavcanPublisher { @@ -124,6 +126,8 @@ public: // set the data ready in the buffer and chop if needed ++_transfer_id_2; // The transfer-ID shall be incremented after every transmission on this subject. result = canardTxPush(&_canard_instance, &transfer2); + + transmit(); } } }; diff --git a/src/drivers/uavcan_v1/Publishers/DS-015/Readiness.hpp b/src/drivers/uavcan_v1/Publishers/DS-015/Readiness.hpp index 98b5cd4837..dc41bd479d 100644 --- a/src/drivers/uavcan_v1/Publishers/DS-015/Readiness.hpp +++ b/src/drivers/uavcan_v1/Publishers/DS-015/Readiness.hpp @@ -95,6 +95,8 @@ public: // set the data ready in the buffer and chop if needed ++_transfer_id; // The transfer-ID shall be incremented after every transmission on this subject. result = canardTxPush(&_canard_instance, &transfer); + + transmit(); } } }; diff --git a/src/drivers/uavcan_v1/Publishers/Publisher.cpp b/src/drivers/uavcan_v1/Publishers/Publisher.cpp new file mode 100644 index 0000000000..ca7b247056 --- /dev/null +++ b/src/drivers/uavcan_v1/Publishers/Publisher.cpp @@ -0,0 +1,49 @@ +/**************************************************************************** + * + * Copyright (c) 2021 PX4 Development Team. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * 3. Neither the name PX4 nor the names of its contributors may be + * used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + ****************************************************************************/ + +/** + * @file Publisher.cpp + * + * Defines basic functionality of UAVCAN v1 publisher class + * + * @author Jacob Crabill + */ + +#include "Publisher.hpp" + +#include "../Uavcan.hpp" + +void UavcanPublisher::transmit() +{ + UavcanNode::do_transmit(); +} diff --git a/src/drivers/uavcan_v1/Publishers/Publisher.hpp b/src/drivers/uavcan_v1/Publishers/Publisher.hpp index f13c176b68..6de4d8fa49 100644 --- a/src/drivers/uavcan_v1/Publishers/Publisher.hpp +++ b/src/drivers/uavcan_v1/Publishers/Publisher.hpp @@ -142,4 +142,6 @@ protected: CanardTransferID _transfer_id {0}; UavcanPublisher *_next_pub {nullptr}; + + void transmit(); }; diff --git a/src/drivers/uavcan_v1/Publishers/uORB/uorb_publisher.hpp b/src/drivers/uavcan_v1/Publishers/uORB/uorb_publisher.hpp index 518915da12..a422b4cac0 100644 --- a/src/drivers/uavcan_v1/Publishers/uORB/uorb_publisher.hpp +++ b/src/drivers/uavcan_v1/Publishers/uORB/uorb_publisher.hpp @@ -81,6 +81,7 @@ public: // set the data ready in the buffer and chop if needed ++_transfer_id; // The transfer-ID shall be incremented after every transmission on this subject. canardTxPush(&_canard_instance, &transfer); + transmit(); } }; diff --git a/src/drivers/uavcan_v1/Uavcan.hpp b/src/drivers/uavcan_v1/Uavcan.hpp index 500a5e9845..74f40026a3 100644 --- a/src/drivers/uavcan_v1/Uavcan.hpp +++ b/src/drivers/uavcan_v1/Uavcan.hpp @@ -140,6 +140,8 @@ public: static UavcanNode *instance() { return _instance; } + static void do_transmit() { if (_instance) _instance->transmit(); }; + /* The bit rate that can be passed back to the bootloader */ int32_t active_bitrate{0};