uavcan_v1: Immediate transmit() from Publishers

Add 'do_transmit()' to UavcanNode
Add 'transmit()' to Publisher base class to call do_transmit()
Call transmit() after canardTxPush from Publishers
This commit is contained in:
JacobCrabill 2022-03-04 22:07:43 -08:00
parent 8cd4055da9
commit aba7e592c3
7 changed files with 62 additions and 1 deletions

View File

@ -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

View File

@ -45,7 +45,9 @@
#include <reg/drone/physics/kinematics/geodetic/Point_0_1.h>
#include <reg/drone/service/gnss/DilutionOfPrecision_0_1.h>
#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();
}
}
};

View File

@ -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();
}
}
};

View File

@ -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 <jacob@flyvoly.com>
*/
#include "Publisher.hpp"
#include "../Uavcan.hpp"
void UavcanPublisher::transmit()
{
UavcanNode::do_transmit();
}

View File

@ -142,4 +142,6 @@ protected:
CanardTransferID _transfer_id {0};
UavcanPublisher *_next_pub {nullptr};
void transmit();
};

View File

@ -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();
}
};

View File

@ -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};