Skip to content

sys/isrpipe: add isrpipe_write#17336

Merged
fjmolinas merged 1 commit intoRIOT-OS:masterfrom
HendrikVE:pr/isrpipe_write
Dec 7, 2021
Merged

sys/isrpipe: add isrpipe_write#17336
fjmolinas merged 1 commit intoRIOT-OS:masterfrom
HendrikVE:pr/isrpipe_write

Conversation

@HendrikVE
Copy link
Copy Markdown
Contributor

Contribution description

The isrpipe module is lacking a function to add a batch of values so we don't need to externally loop on isrpipe_write_one. This PR introduces isrpipe_write.

Testing procedure

There is no dedicated test for isrpipe but it's basically covered by the test of tsrb already.

@github-actions github-actions bot added the Area: sys Area: System label Dec 3, 2021
@benpicco benpicco requested a review from kaspar030 December 3, 2021 15:41
* @returns number of characters that could be added
* @returns -1 if buffer was full
*/
int isrpipe_write(isrpipe_t *isrpipe, uint8_t *buf, size_t n);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
int isrpipe_write(isrpipe_t *isrpipe, uint8_t *buf, size_t n);
int isrpipe_write(isrpipe_t *isrpipe, const void *buf, size_t n);

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Isn't it better to keep consistency with isrpipe_init which also uses uint8_t *buf ?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

You can add arbitrary data here, no? The API doesn't have to care about what buffer is used to back the data structure

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Sure, but ringbuffer for instance even uses const char *buf so maybe it's worth a thought to remodel those values in general.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

It's just more convenient to use an API that takes a void * for arbitrary data than a uint8_t * - let the function do the cast if it needs to operate on bytes, not the caller.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

See also #5497

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I don't have a strong opinion here, maybe just in favor of keeping things aligned, currently isrpipe is lying on top of tsrb which is using uint8_t, and all current users use uint8_t.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Should be const still

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I added a const qualifier. I'm for keeping uint8_t as well, for uniformity.

@benpicco benpicco added the CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR label Dec 7, 2021
Copy link
Copy Markdown
Contributor

@fjmolinas fjmolinas left a comment

Choose a reason for hiding this comment

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

ACK

@fjmolinas fjmolinas enabled auto-merge December 7, 2021 14:19
@fjmolinas fjmolinas merged commit 07e7a6e into RIOT-OS:master Dec 7, 2021
@HendrikVE HendrikVE deleted the pr/isrpipe_write branch December 28, 2021 22:34
@fjmolinas fjmolinas added this to the Release 2022.01 milestone Jan 21, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Area: sys Area: System CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants