mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-05-02 05:04:08 +08:00
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:
parent
8cd4055da9
commit
aba7e592c3
@ -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
|
||||
|
||||
@ -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();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@ -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();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
49
src/drivers/uavcan_v1/Publishers/Publisher.cpp
Normal file
49
src/drivers/uavcan_v1/Publishers/Publisher.cpp
Normal 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();
|
||||
}
|
||||
@ -142,4 +142,6 @@ protected:
|
||||
CanardTransferID _transfer_id {0};
|
||||
|
||||
UavcanPublisher *_next_pub {nullptr};
|
||||
|
||||
void transmit();
|
||||
};
|
||||
|
||||
@ -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();
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@ -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};
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user