I use stm32G4 with CAN ID.
I have 2 devices: device A and device B.
Device A: i send real32 array on while cycle
static inline void sendReal32ArrayMessage(void) {
static uint8_t real32_transfer_id = 0;
uavcan_primitive_array_Real32_1_0 message = {
.value.elements = {1.6f, 2.0f, 3.0f, 4.0f, 5.1f},
.value.count = 5
};
size_t message_ser_buf_size = uavcan_primitive_array_Real32_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_;
uint8_t message_ser_buf[uavcan_primitive_array_Real32_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_] = {0};
if (uavcan_primitive_array_Real32_1_0_serialize_(&message, message_ser_buf, &message_ser_buf_size) < 0) {
Error_Handler();
}
const CanardTransferMetadata transfer_metadata = {
.priority = CanardPriorityNominal,
.transfer_kind = CanardTransferKindMessage,
.port_id = 4, // Укажите свой ID порта
.remote_node_id = CANARD_NODE_ID_UNSET,
.transfer_id = real32_transfer_id,
};
if (canardTxPush(&queue, &canard, 0, &transfer_metadata, message_ser_buf_size, message_ser_buf) < 0) {
Error_Handler();
}
real32_transfer_id++;
}
Device B: Have subscribe to this port_id and handle this message on CANFD interrupt handler
CanardRxSubscription rx_message_subscription;
if( canardRxSubscribe( &canard,
CanardTransferKindMessage,
4,
uavcan_primitive_array_Real32_1_0_EXTENT_BYTES_,
CANARD_DEFAULT_TRANSFER_ID_TIMEOUT_USEC,
&rx_message_subscription) != 1 ){ Error_Handler(); }
But in the canardRxAccept function and the serializer for this data type does not work correctly, what should I do?