-
Notifications
You must be signed in to change notification settings - Fork 12
Make parser more tolerant to spaces in responses URC #27
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
- this is needed to support LENA commands
update to sparkfun
Hi Michael (@mazgch ), Happy New Year! Thanks for submitting this PR. I haven't yet had time to test it, but I will - hopefully in the next few days. Very best wishes, |
Hi Michael (@mazgch ), Apologies for the very slow reply on this. I have been "putting it off" as I am slightly nervous about merging it as-is. I don't know if sscanf works the same way on all platforms and whether all platforms will automatically ignore the space in front of %d. I have two options. I can either test it on many boards and make sure they all still work correctly. OR - probably safer - use this technique everywhere... I think I will go with option 2. Merging into release_candidate for testing. Best wishes, |
You are right probably scanf has different behaviour on various compilers I have not thought about this. I think normaly ' ' in format string should even match no space. I was thinking akso to maje just a helper function that checks and skips the start string and following spaces and then does the scanf. Would you prefer this? To my knowledge all conversion specifiers other than [, c, and n consume and discard all leading whitespace characters (determined as if by calling isspace) before attempting to parse the input. These consumed characters do not count towards the specified maximum field width. What is this method that you refer to? It links to this PR for me. |
Working on it now... Please see the latest commits: https://github.com/sparkfun/SparkFun_u-blox_SARA-R5_Arduino_Library/commits/release_candidate I use |
You can limit the length char bar[20]; |
Excellent - thank you. Stealing...! |
Hi Michael (@mazgch ), I think this is complete - but I can not test it as all of my Pay-As-You-Go SIMs have expired! I will need to get a new one. If you have time, can you please test the code in the release_candidate branch? Thank you, |
Hi Paul, my project is running from this branch I have tested LENA-R8 and LARA-R6. But I must admitt that I did not test a lot. |
Hi Michael, |
Hi @PaulZC,
This is an attempt to make the AT parser more tolerant to spaces following the first
:
in URCs and responses.In the past it searched for
between the
+CREG: <data>
this is correct for many modems. but some variants of modems (like LENA-R8 in ES stage) do not strictly follow that format and sometimes omit the space:
and the<data>
following. this pull request tries to make the parser in this library more tolerant. The changes in the code involves searching for a shorter response code only until:
and the either skip the spaces of let the%d
in the followingscanf
handle that.I must admit I have not tested with all the different examples or modems. But my code uses quite many commands and APIs already. I leave it up to you if you think this is useful for everybody. Maybe it would be good to give it a review from your side.