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

allow 3 EOS characters rather than 2 #182

Closed
wants to merge 1 commit into from

Conversation

rerpha
Copy link

@rerpha rerpha commented Jun 2, 2023

Hi, we weren't sure if there was a reason why asyn only seemed to allow 2 chars for the EOS/terminator string. We spotted a comment on line 217, but can't quite figure out what it's trying to do - are there any other areas which expect or rely on the EOS chars being 2 characters?

@MarkRivers
Copy link
Member

The comment in line 217 is the key to the problem. The asynOctet drivers get data from the device in "chunks". The problem arises when a potential terminator begins on the last character of the current chunk, and might continue on the first character of the next chunk. The logic currently implemented correctly handles the case of a 2-character terminator. The logic gets more complicated if the terminator can be longer than 2 characters, since we need to keep track of how many characters of the potential terminator have been received. It gets messy if the next chunk is only 1 character. When the EOS limit is 2 characters it is pretty easy, since the next chunk will contain at least 1 character. But if the EOS limit is more than 2 then we need to look at the following chunks as well. Real serial port drivers often return data 1 character at a time, so this is not just a hypothetical problem.

I agree it would be nice to do this, and it is not impossible, it just requires careful thought and testing.

@AppVeyorBot
Copy link

Build asyn 1.0.235 completed (commit 41eb856430 by @rerpha)

@MarkRivers MarkRivers closed this May 30, 2024
@rerpha rerpha deleted the allow_3_eos_chars branch May 31, 2024 06:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants