Paparazzi UAS v7.0_unstable
Paparazzi is a free software Unmanned Aircraft System.
Loading...
Searching...
No Matches
uavcan.c File Reference
#include "uavcan.h"
#include "mcu_periph/can.h"
#include "modules/core/threads.h"
#include "uavcan.protocol.NodeStatus.h"
#include "uavcan_reporting.h"
#include "mcu_periph/sys_time.h"
#include "modules/uavcan/uavcan_allocator.h"
+ Include dependency graph for uavcan.c:

Go to the source code of this file.

Macros

#define UAVCAN_NODE_ID   100
 
#define UAVCAN_BAUDRATE   1000000
 

Functions

static void can_frame_cb (struct pprzcan_frame *rx_msg, UNUSED struct pprzaddr_can *src_addr, void *user_data)
 
static void uavcan_tx (void *p)
 
static void onTransferReceived (CanardInstance *ins, CanardRxTransfer *transfer)
 Whenever a valid and 'accepted' transfer is received.
 
static bool shouldAcceptTransfer (const CanardInstance *ins, uint64_t *out_data_type_signature, uint16_t data_type_id, CanardTransferType transfer_type, uint8_t source_node_id)
 If we should accept this transfer.
 
static void uavcanInitIface (struct uavcan_iface_t *iface)
 Initialize uavcan interface.
 
void uavcan_init (void)
 Initialize all uavcan interfaces.
 
void uavcan_bind (uint16_t data_type_id, uint64_t data_type_signature, uavcan_event *ev, uavcan_callback cb)
 Bind to a receiving message from uavcan.
 
static uint8_tget_transfer_id (struct uavcan_iface_t *iface, uint8_t destination_node_id, CanardTxTransfer *transfer)
 
void uavcan_transfer (struct uavcan_iface_t *iface, CanardTxTransfer *transfer)
 
void uavcan_request (struct uavcan_iface_t *iface, uint8_t destination_node_id, CanardTxTransfer *transfer)
 
void uavcan_broadcast (struct uavcan_iface_t *iface, uint64_t data_type_signature, uint16_t data_type_id, uint8_t priority, const void *payload, uint16_t payload_len)
 Legacy function Broadcast an uavcan message to a specific interface.
 
void uavcan_response (struct uavcan_iface_t *iface, uint8_t destination_node_id, CanardTxTransfer *transfer)
 

Variables

static uavcan_eventuavcan_event_hd = NULL
 

Macro Definition Documentation

◆ UAVCAN_BAUDRATE

#define UAVCAN_BAUDRATE   1000000

Definition at line 40 of file uavcan.c.

◆ UAVCAN_NODE_ID

#define UAVCAN_NODE_ID   100

Definition at line 36 of file uavcan.c.

Function Documentation

◆ can_frame_cb()

static void can_frame_cb ( struct pprzcan_frame rx_msg,
UNUSED struct pprzaddr_can src_addr,
void user_data 
)
static

Definition at line 81 of file uavcan.c.

References CAN_EID_MASK, CAN_FRAME_EFF, CAN_SID_MASK, uavcan_iface_t::canard, and foo.

Referenced by uavcanInitIface().

+ Here is the caller graph for this function:

◆ get_transfer_id()

static uint8_t * get_transfer_id ( struct uavcan_iface_t iface,
uint8_t  destination_node_id,
CanardTxTransfer transfer 
)
static

Definition at line 252 of file uavcan.c.

References foo, kv_get(), kv_set(), uavcan_iface_t::node_id, transfer(), and uavcan_iface_t::transfer_ids_store.

Referenced by uavcan_request(), and uavcan_transfer().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ onTransferReceived()

static void onTransferReceived ( CanardInstance ins,
CanardRxTransfer transfer 
)
static

Whenever a valid and 'accepted' transfer is received.

Definition at line 141 of file uavcan.c.

References abi_struct::cb, ev, foo, abi_struct::next, transfer(), and uavcan_event_hd.

Referenced by uavcanInitIface().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ shouldAcceptTransfer()

static bool shouldAcceptTransfer ( const CanardInstance ins,
uint64_t out_data_type_signature,
uint16_t  data_type_id,
CanardTransferType  transfer_type,
uint8_t  source_node_id 
)
static

If we should accept this transfer.

Definition at line 155 of file uavcan.c.

References ev, foo, abi_struct::next, and uavcan_event_hd.

Referenced by uavcanInitIface().

+ Here is the caller graph for this function:

◆ uavcan_bind()

void uavcan_bind ( uint16_t  data_type_id,
uint64_t  data_type_signature,
uavcan_event ev,
uavcan_callback  cb 
)

◆ uavcan_broadcast()

void uavcan_broadcast ( struct uavcan_iface_t iface,
uint64_t  data_type_signature,
uint16_t  data_type_id,
uint8_t  priority,
const void payload,
uint16_t  payload_len 
)

Legacy function Broadcast an uavcan message to a specific interface.

Definition at line 313 of file uavcan.c.

References foo, transfer(), and uavcan_transfer().

Referenced by actuators_uavcan_cmd_commit(), actuators_uavcan_commit(), handleAllocationRequest(), id_alloc_uavcan_cb(), tunnel_uavcan_send_message(), and uavcan_reporting().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ uavcan_init()

void uavcan_init ( void  )

Initialize all uavcan interfaces.

uavcan interfaces

Definition at line 225 of file uavcan.c.

References foo, uavcan_allocator_init(), uavcan_init_reporting(), and uavcanInitIface().

+ Here is the call graph for this function:

◆ uavcan_request()

void uavcan_request ( struct uavcan_iface_t iface,
uint8_t  destination_node_id,
CanardTxTransfer transfer 
)
Parameters
transfershould be initialized with canardInitTxTransfer.

Definition at line 289 of file uavcan.c.

References uavcan_iface_t::bsem, uavcan_iface_t::canard, foo, get_transfer_id(), uavcan_iface_t::initialized, uavcan_iface_t::nb_errors, pprz_bsem_signal(), pprz_mtx_lock(), pprz_mtx_unlock(), transfer(), and uavcan_iface_t::tx_mutex.

Referenced by request_node_info().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ uavcan_response()

void uavcan_response ( struct uavcan_iface_t iface,
uint8_t  destination_node_id,
CanardTxTransfer transfer 
)
Parameters
inout_transfer_idshould be set to the request transfer id before calling this function

Definition at line 332 of file uavcan.c.

References uavcan_iface_t::bsem, uavcan_iface_t::canard, foo, uavcan_iface_t::initialized, pprz_bsem_signal(), pprz_mtx_lock(), pprz_mtx_unlock(), transfer(), and uavcan_iface_t::tx_mutex.

Referenced by node_info_cb().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ uavcan_transfer()

void uavcan_transfer ( struct uavcan_iface_t iface,
CanardTxTransfer transfer 
)
Parameters
transfershould be initialized with canardInitTxTransfer.

Definition at line 268 of file uavcan.c.

References uavcan_iface_t::bsem, uavcan_iface_t::canard, foo, get_transfer_id(), uavcan_iface_t::initialized, uavcan_iface_t::nb_errors, pprz_bsem_signal(), pprz_mtx_lock(), pprz_mtx_unlock(), transfer(), and uavcan_iface_t::tx_mutex.

Referenced by uavcan_broadcast().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ uavcan_tx()

static void uavcan_tx ( void p)
static

◆ uavcanInitIface()

Variable Documentation

◆ uavcan_event_hd

uavcan_event* uavcan_event_hd = NULL
static

Definition at line 43 of file uavcan.c.

Referenced by onTransferReceived(), shouldAcceptTransfer(), and uavcan_bind().