Hello. I’m new about UAVCAN.
I’m trying implementation UAVCAN on ChibiOS using C language.
I found that I need to apply “libcanard” for C language.
I’m reading UAVCAN_Specification depending on the text “RTFM at [url]” on Ardupilot FW. It’s so hard to me.
My plan is using “ardupilo/Tools/AP_Periph/can.cpp”, change to C language.
In “if grammer” below source, I know “canTransmit” function use CAN BUS.
Is “canardPopTxQueue” function using uavcan?
static void processTx(void)
{
static uint8_t fail_count;
for (const CanardCANFrame* txf = NULL; (txf = canardPeekTxQueue(&canard)) != NULL;) {
CANTxFrame txmsg {};
txmsg.DLC = txf->data_len;
memcpy(txmsg.data8, txf->data, 8);
txmsg.EID = txf->id & CANARD_CAN_EXT_ID_MASK;
txmsg.IDE = 1;
txmsg.RTR = 0;
if (canTransmit(&CAND1, CAN_ANY_MAILBOX, &txmsg, TIME_IMMEDIATE) == MSG_OK) {
canardPopTxQueue(&canard);
fail_count = 0;
} else {
// just exit and try again later. If we fail 8 times in a row
// then start discarding to prevent the pool filling up
if (fail_count < 8) {
fail_count++;
} else {
canardPopTxQueue(&canard);
}
return;
}
}
}