ATParser could not support some strings very well.
- Dominant language
- C++
- Stars
- 39
- Forks
- 24
- PR merge metrics
- No merged PRs in 30d
Description
I am working to integrate a NBIoT module and found that this ATParser could not support some strings.
After debugging, I found it is caused by the poor sscanf().
For example,
`_parser.recv("\"%15[^\n]\"", dev_info.imsi);` from ESP8266 driver as reference , it could work.
`_parser.recv("%15[^\n]", dev_info.imsi); `with no quotes does not work well. it will return the first char in the string to imsi.
Below is a simple test code, would you help to share comments if any idea?
```
void verify_sscanf()
{
//Verify the AT format for esp8266 with quotes
int count = -1;
char test[] = "0\"123456789\"";
char test1[] = "0\"%*9[^\n]\"%n0";
char test2[] = "0\"1234\"";
sscanf(test2, test1, &count);
printf("\nESP8266: expect -1 - count = %d\n", count);
count = -1;
sscanf(test, test1, &count);
printf("\nESP8266: expect 12 - count = %d\n", count);
//Verify the AT format for BC95 without quotes
char test_bc95[] = "0123456789";
char test1_bc95[] = "0%*9[^\n]%n0";
char test2_bc95[] = "01234";
count = -1;
sscanf(test2_bc95, test1_bc95, &count);
printf("\nBC95: expect -1 - count = %d\n", count);
count = -1;
sscanf(test_bc95, test1_bc95, &count);
printf("\nBC95: expect 10 BUT fail- count = %d\n", count);
}
```
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.