Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: define receive queue sizing constant #17

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion inc/rtcan.h
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ typedef struct
#define RTCAN_TX_QUEUE_SIZE (RTCAN_TX_QUEUE_LENGTH * RTCAN_TX_QUEUE_ITEM_SIZE)

#define RTCAN_RX_NOTIF_QUEUE_LENGTH 10
#define RTCAN_RX_NOTIF_QUEUE_ITEM_SIZE 1 // one pointer = 1x ULONG
#define RTCAN_RX_NOTIF_QUEUE_ITEM_SIZE (sizeof(rtcan_msg_t*) / sizeof(ULONG)) // one pointer = 1x ULONG
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the right constant value, but I don't think this should be the name of the constant that users use in their code. This particular group of constants is internal to RTCAN (used to send pointers to received messages to the RTCAN Rx thread for dispatch to subscribers).

I suggest:

// user constant
#define RTCAN_RX_QUEUE_ITEM_SIZE (sizeof(rtcan_msg_t*) / sizeof(ULONG))

// internal constant
#define RTCAN_RX_NOTIF_QUEUE_ITEM_SIZE (RTCAN_RX_QUEUE_ITEM_SIZE)

I think we should perhaps rename all of the internal constants, or #undef them at the end of the header so they don't get exposed to users and potentially cause confusion. Maybe they should be prefixed with an underscore if they are internal?

#define RTCAN_RX_NOTIF_QUEUE_SIZE (RTCAN_RX_NOTIF_QUEUE_LENGTH * RTCAN_RX_NOTIF_QUEUE_ITEM_SIZE)

/**
Expand Down