OpenCyphal / libcanard

A compact implementation of the Cyphal/CAN protocol in C for high-integrity real-time embedded systems
http://opencyphal.org
MIT License
329 stars 192 forks source link

About reduce memory usage #220

Closed pioneerAlone closed 9 months ago

pioneerAlone commented 10 months ago

Since I'm using a resource-deficient MCU (ram: 20K), and I only use classic can,

So for the payload_buffer size in the structure Txitem, I can use CANARD_MTU_CAN_CLASSIC.

`define CANARD_MTU_CAN_CLASSIC 8U

define CANARD_MTU_CAN_FD 64U

define CANARD_MTU_MAX CANARD_MTU_CAN_FD

typedef struct TxItem { CanardTxQueueItem base; uint8_t payload_buffer[CANARD_MTU_MAX]; } TxItem; `

pavel-kirienko commented 9 months ago

The payload_buffer field here is a flex array member; the declared size has no influence on its memory footprint.

pioneerAlone commented 9 months ago

Thanks for comments,

Sure, got it.