OpenCyphal / libcanard

A compact implementation of the Cyphal/CAN protocol in C for high-integrity real-time embedded systems

Home Page:http://opencyphal.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Add user callback on struct CanardRxSubscription

Cherish-forever opened this issue · comments

I think CanardRxSubscription need add a function call, named user_callback.

typedef void (*user_callback)(CanardInstance *ins, CanardTransferKind kind, CanardTransfer *transfer);

So that when after receive done, it will call user callback, so user can decode transfer and do something else.

This would go against some high-integrity coding guidelines that generally prohibit function pointers. We use function pointers for memory allocation/deallocation routines because there is no sensible alternative, whereas what you suggested is adequately covered already by canardRxAccept(). If you want a callback-based interface, write a simple wrapper on top of canardRxAccept().