mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-11-11 15:41:36 +08:00
[UAVCANv1] TX deadline fix and other fixes
This commit is contained in:
committed by
Lorenz Meier
parent
02a4d93c74
commit
1804cea92c
@@ -168,7 +168,7 @@ void UavcanNode::init()
|
||||
CANARD_DEFAULT_TRANSFER_ID_TIMEOUT_USEC,
|
||||
&_heartbeat_subscription);
|
||||
|
||||
canardRxSubscribe(&_canard_instance, //Temporory GPS message DSDL not defined yet
|
||||
canardRxSubscribe(&_canard_instance, // uORB over UAVCAN GPS message
|
||||
CanardTransferKindMessage,
|
||||
gps_port_id,
|
||||
sizeof(struct sensor_gps_s),
|
||||
@@ -241,8 +241,9 @@ void UavcanNode::Run()
|
||||
// Transmitting
|
||||
// Look at the top of the TX queue.
|
||||
for (const CanardFrame *txf = nullptr; (txf = canardTxPeek(&_canard_instance)) != nullptr;) {
|
||||
// Check if the frame has timed out.
|
||||
if (hrt_absolute_time() > txf->timestamp_usec) { //FIXME wrong I think
|
||||
// Attempt transmission only if the frame is not yet timed out while waiting in the TX queue.
|
||||
// Otherwise just drop it and move on to the next one.
|
||||
if (txf->timestamp_usec == 0 || hrt_absolute_time() > txf->timestamp_usec) {
|
||||
// Send the frame. Redundant interfaces may be used here.
|
||||
const int tx_res = _can_interface->transmit(*txf);
|
||||
|
||||
@@ -416,7 +417,7 @@ void UavcanNode::sendHeartbeat()
|
||||
|
||||
|
||||
CanardTransfer transfer = {
|
||||
.timestamp_usec = hrt_absolute_time(),
|
||||
.timestamp_usec = hrt_absolute_time() + CANARD_DEFAULT_TRANSFER_ID_TIMEOUT_USEC,
|
||||
.priority = CanardPriorityNominal,
|
||||
.transfer_kind = CanardTransferKindMessage,
|
||||
.port_id = uavcan_node_Heartbeat_1_0_FIXED_PORT_ID_,
|
||||
|
||||
Reference in New Issue
Block a user