You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This is kinda an open question as some code review feedback.
Disclaimer: I'm not a heavy Arduino user, I could miss some code, some forum posts, ...
My feedback goes around the discrepancy between giving tools to users to get data easily using a separator and the real implementation.
I'm assuming most of your community are beginners with embedded and programming, hence the readBytesUntil, readStringUntil, find, ... functions.
Such functions job should be described as "return data if the terminator has been found otherwise keep adding data in the buffer".
Meaning, if we didn't receive the terminator yet, we will wait until we get it before returning everything. No data should be read as per the Stream until we know the terminator is there. So calling the function more than once will return the complete data.
(Eg. of the complete expected string: "ABCDEF\n" where \n is the terminal character; if we receive "AB", then "CDEF\n", where we call read*Until each time, we should get "ABCDEF", NOT "CDEF")
In the case of the Arduino, my assumption is that the last part ("keep adding data in the buffer") is impossible because of the low RAM constraint.
Which let me introduce some potential solutions:
readUntil do a hybrid between reading and seeking. Seek until we found the terminator character, making multiple calls to readUntil possible if we can't find yet the terminator. When it is found, move the current read position (referenced as head in the code) to the terminator character to do as if everything has been read. User (or read*Until?) would have the job to discard data if the buffer is full.
keep read*Until as it is now, but add a seek find/findUntil (As a dev I would prefer if it returns the index of the match but since it is oriented to be beginner friendly and find/findUtil return a bool I guess you should return a bool)
Labels suggestion:
enhancement
question
waiting for feedback
The text was updated successfully, but these errors were encountered:
Hi,
This is kinda an open question as some code review feedback.
Disclaimer: I'm not a heavy Arduino user, I could miss some code, some forum posts, ...
My feedback goes around the discrepancy between giving tools to users to get data easily using a separator and the real implementation.
I'm assuming most of your community are beginners with embedded and programming, hence the readBytesUntil, readStringUntil, find, ... functions.
Such functions job should be described as "return data if the terminator has been found otherwise keep adding data in the buffer".
Meaning, if we didn't receive the terminator yet, we will wait until we get it before returning everything. No data should be read as per the Stream until we know the terminator is there. So calling the function more than once will return the complete data.
(Eg. of the complete expected string: "ABCDEF\n" where \n is the terminal character; if we receive "AB", then "CDEF\n", where we call read*Until each time, we should get "ABCDEF", NOT "CDEF")
In the case of the Arduino, my assumption is that the last part ("keep adding data in the buffer") is impossible because of the low RAM constraint.
Which let me introduce some potential solutions:
Labels suggestion:
enhancement
question
waiting for feedback
The text was updated successfully, but these errors were encountered: