9#include <uavcan.tunnel.Protocol.h>
11#if !defined(TUNNEL_UAVCAN_IFACE) && USE_CAN1
12#define TUNNEL_UAVCAN_IFACE uavcan1
15#if !defined(TUNNEL_UAVCAN_IFACE) && USE_CAN2
16#define TUNNEL_UAVCAN_IFACE uavcan2
19#if !defined(TUNNEL_UAVCAN_PROTOCOL)
20#define TUNNEL_UAVCAN_PROTOCOL 3
23#if !defined(TUNNEL_UAVCAN_CHANNEL_ID)
24#define TUNNEL_UAVCAN_CHANNEL_ID 0
49 ucdl->
iface = &TUNNEL_UAVCAN_IFACE;
65 ucdl->
device.periph = ucdl;
70 struct uavcan_tunnel_Broadcast utb_msg;
71 if(uavcan_tunnel_Broadcast_decode(
transfer, &utb_msg)) {
96 if(len < free_space) {
128 struct uavcan_tunnel_Broadcast msg;
129 uint8_t buffer[UAVCAN_TUNNEL_BROADCAST_MAX_SIZE];
140 msg.buffer.len = len;
141 msg.channel_id =
up->channel_id;
144 uint32_t total_size = uavcan_tunnel_Broadcast_encode(&msg, buffer);
146 uavcan_broadcast(
up->iface, UAVCAN_TUNNEL_BROADCAST_SIGNATURE, UAVCAN_TUNNEL_BROADCAST_ID, CANARD_TRANSFER_PRIORITY_MEDIUM, buffer, total_size);
int pprz_mtx_trylock(pprz_mutex_t *mtx)
Performs a nonblocking lock on the mutex.
int pprz_mtx_unlock(pprz_mutex_t *mtx)
int pprz_mtx_init(pprz_mutex_t *mtx)
int pprz_mtx_lock(pprz_mutex_t *mtx)
size_t ring_buffer_free_space(ring_buffer_t *ring_buffer)
size_t ring_buffer_write(ring_buffer_t *rb, const uint8_t *data, size_t len)
Write.
size_t ring_buffer_read(ring_buffer_t *rb, uint8_t *read_buffer, size_t len)
Read.
size_t ring_buffer_available(ring_buffer_t *rb)
void ring_buffer_init(ring_buffer_t *rb, uint8_t *buf, size_t size)
Init.
static void tunnel_uavcan_put_byte(struct tunnel_uavcan_periph *up, long fd, uint8_t c)
void tunnel_uavcan_init(void)
void tunnel_uavcan_set_baudrate(struct tunnel_uavcan_periph *up, uint32_t baudrate)
#define TUNNEL_UAVCAN_PROTOCOL
static int tunnel_uavcan_char_available(struct tunnel_uavcan_periph *up)
static int tunnel_uavcan_check_free_space(struct tunnel_uavcan_periph *up, long *fd, uint16_t len)
static void tunnel_uavcan_put_buffer(struct tunnel_uavcan_periph *up, long fd, const uint8_t *data, uint16_t len)
static void tunnel_uavcan_send_message(struct tunnel_uavcan_periph *up, long fd)
static void tunnel_uavcan_cb(struct uavcan_iface_t *iface, CanardRxTransfer *transfer)
void tunnel_uavcan_init_periph(struct tunnel_uavcan_periph *ucdl, uint8_t channel_id)
static uint8_t tunnel_uavcan_get_byte(struct tunnel_uavcan_periph *up)
struct tunnel_uavcan_periph tunnel_uavcan0
#define TUNNEL_UAVCAN_CHANNEL_ID
uint8_t _rbuf[RX_BUFFER_SIZE]
uavcan_event tunnel_brd_ev
uint8_t _tbuf[TX_BUFFER_SIZE]
struct link_device device
Generic device interface.
struct uavcan_iface_t * iface
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_bind(uint16_t data_type_id, uint64_t data_type_signature, uavcan_event *ev, uavcan_callback cb)
Bind to a receiving message from uavcan.
unsigned short uint16_t
Typedef defining 16 bit unsigned short type.
unsigned int uint32_t
Typedef defining 32 bit unsigned int type.
unsigned char uint8_t
Typedef defining 8 bit unsigned char type.
int transfer(const Mat *from, const image_t *to)