-
Notifications
You must be signed in to change notification settings - Fork 32
Handle carriage returns if present #123
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
Conversation
class KiViBufferWalker(): | ||
"""! Simple auxiliary class used to walk through a buffer and search for KV tokens """ | ||
def __init__(self): | ||
self.KIVI_REGEX = r"\{\{([\w\d_-]+);([^\}]+)\}\}\n" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since the key value protocol is based on start {{
and end }}
tags. I would suggest removing \n
. That way it will be more robust to match. Even if on some platform \n
goes missing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought about doing that, but #104 put the newline character in.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@bridadan in #104 your have add \n
to the K,V regex. I think K,V protocol and \n
and \r
are different things. If htrun should send after receiving a \n
then we should received until \n
and then do the parsing. So that K,V parsing is independent of these terminating characters and also since data in K,V has nothing to do with serial limitation. In future this protocol can be on network interface as well.
So the work around for preventing DAPLINK bad state should be in the place where we are receiving data i.e. receive until \n
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mazimkhan Could you clarify a bit? I'm not sure what you mean. Are you saying you want to completely remove \n
and/or \r
from the KV regex?
The \n
had been there before, but at when point @PrzemekWirkus had removed it, which caused issues in DAPLink, so I just added it back in that PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes. It can be removed from the regex. But used after receiving characters to see if one line is received. To satisfy DAPlink limitation.
Basically process complete lines terminated with \n
one at a time. Also this can only work if target writes one K,V at a time and waits for a response. If it sends two in a row (or printfs) and host test responds to the first one then this situation can not be avoided. If this situation is really a limitation then perhaps this should also be part of the test guidelines.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
closing as fix added in #128 |
I was running htrun on Linux Mint 17.3 and even though only new line characters were being written from the DUT, htrun was reading in a carriage return character and new line character. I added an optional carriage return character to the regex that searches for KV tokens.