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

ReadBytesUntil should be able to return empty if a terminator is detected without data #491

Open
Suisse00 opened this issue Jul 24, 2022 · 1 comment

Comments

@Suisse00
Copy link

Suisse00 commented Jul 24, 2022

Hi,

Just some feedback and an open question of a possible redesign of ReadBytesUntil functions.

ReadBytesUntil should have a return state that means "we detected your terminator character but there were no data".

I don't think it should be the user to peek at this since the name of the method implicitly suggest it does that and it was just not in mind in the first place.

ReadBytesUntil, it is where things can be more dangerous. I would go with returning 0 meaning the terminator has been found but there was no data and "-1" (maximum of size_t) means the terminator has not been found.
However, doing so will be a breaking change.

Disclaimer: I'm not a heavy user of Arduino, so I don't know your actual restriction, limitations, overall users history with breaking changes, ...

Such discussion should affect ticket #290 in someway (don't just read the title)

NOTE: There is ReadStringUntil that technically do the job already.

Labels suggestion:

  • enhancement
  • question
  • waiting for feedback
@Suisse00
Copy link
Author

Update description.
Title should read as "ReadBytesUntil should be able to return empty if a terminator is detected without data" instead

@per1234 per1234 changed the title Read*Until should be able to return empty if a terminator is detected without data ReadBytesUntil should be able to return empty if a terminator is detected without data Jul 25, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants