-
Notifications
You must be signed in to change notification settings - Fork 43
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
regex pseudo converter failing misbehaving? #97
Comments
If you simply want to have more meaningful strings in an mbbi record, I suggest to use the %{} enum converter. It reads (the ugly) strings, and converts them to integers. Then the mbbi can take that integer and convert it to "nice" strings. |
The buffer you see is the 40 char string that should store the value I need to check what happens here. It does not seem to be new input, because I see no second My string buffers work like a circular buffer. New data is appended at the end and consumed data simply moves the start index without moving actual content. Only when the buffer would overflow when new data is appended, remaining valid content is copied from the end to the beginning. It seems that it is not properly terminated here but merges with old content. I need to check this. Maybe related to #96. I need to dig through my code. |
Thanks for the input! I'll look at the enum converter.
Right, I did notice that hence the
My guess is that it is just some junk at the end of the buffer that was there before. The
Sounds about right. Been digging a little bit myself.. |
Maybe |
Can't find anything wrong. So this may take a while... |
As demonstrated in the PR #98 I think there are two issues at play, AFAICT. The PR is too dirty for the merge and I think you can come up with better/cleaner more complete fix. |
Thanks a lot! I will have a look. |
I think I found the actual bug. StreamDevice/src/StreamBuffer.cc Line 277 in 211f689
This needs to be a < instead of <= .A <= may not leave the terminating 0x00 intact if the new content would just fit the buffer capacity, because the terminating 0x00 is not included in len /newlen .Can you test if that fixes your problem? (And the following // comment should be in the else block. I will correct that, too.)I will push an update once you confirm that is fixes the problem. Thank you for your debugging and analysis which lead me to this! |
Found another, related bug in StreamDevice/src/StreamBuffer.cc Line 289 in 211f689
This needs to use len+offs instead of len because content is moved from offs to 0 .This may be the actual bug that you have seen. If content grows ( newlen>len ) and is moved to buffer start, there is still old content to clear up to (old) offs+len if newlen is shorter than off+len .
|
You mean like this?
|
|
How the buffer looks like before and after:
|
Got it. Changed and running the test. Preliminary results look good, let me run this for a couple of hours. |
I've been with running the fix over the night and I can confirm that the above two changes solve the issue for me. |
Fixed in commit 1496089 tagged 2.8.25. |
I have a device sending an ASCII string with fields of different types (strings, chars, decimal integer, hex integer,..), delimited by ':'. I want to parse it out into several records. A sample input might look like this:
66:+44:255:0x122:1:R:190:A03
. FWIW, values '66', '+44' and '190' may change from one message to another; and take up 1 - 5 chars each.If I do not use regex pseudo converter to convert 1 char value to a string all looks fine with this protocol:
$4
is setting a value of astringin
record with a single char.Then I discovered regex pseudo converter and hoped I could convert a single char into more representative string and set a value of
mbbi
record, instead.Here is the protocol that does that:
It works .. most of the time (no errors reported), but quite often I do see an error:
Status
PV is being processed every 2 s and sometimes the error happens and sometimes not. The error is always about the last token that needs to be parsed.I've attached two dumps of debug messages, first one for successfully parsed string and the second one for the failed.
stream-parsing.txt
From what I can tell the buffer that regex touches seems to overflow (sometimes?). For example this would be reported in debug for failing case:
while this is seen in case of success:
The text was updated successfully, but these errors were encountered: