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

esp_modem at_raw has the wrong length output string (IDFGH-13911) #674

Closed
3 tasks done
txf- opened this issue Oct 18, 2024 · 2 comments
Closed
3 tasks done

esp_modem at_raw has the wrong length output string (IDFGH-13911) #674

txf- opened this issue Oct 18, 2024 · 2 comments

Comments

@txf-
Copy link

txf- commented Oct 18, 2024

Answers checklist.

  • I have read the documentation for esp-protocols components and the issue is not addressed there.
  • I have updated my esp-protocols branch (master or release) to the latest version and checked that the issue is present there.
  • I have searched the issue tracker for a similar issue and not found a similar issue.

General issue report

Using a SIM7000 (on the lilygo Tsim7000), I'm executing the following function:

  void getGps(){
    std::string out;
    command_result res = dce->at_raw("AT+CGNSINF\r",out,"+CGNSINF:","ERROR", 10000);
    ESP_LOGI(COMM_TAG,"get gps str: %s", out.c_str()); 
  }

And the response output I get is this (gps coords hidden) :
+CGNSINF: 1,1,20241018103437.000,xx.yyyyyy,-x.yyyyyy,-11.900,0
or this:
+CGNSINF: 1,1,20241018103421.000,xx.yyyyyy,-x.yyyyyy,95.000,0.

its seems the string length is of a fixed size, the whole string should be something like this:
+CGNSINF: 1,1,20241018103758.000,xx.yyyyyyy,-x.yyyyyy,15.300,0.00,4.8,1,,1.1,1.5,0.9,,27,4,3,,37,,

is there a way to set the response buffer size?

@espressif-bot espressif-bot added the Status: Opened Issue is new label Oct 18, 2024
@github-actions github-actions bot changed the title esp_modem at_raw has the wrong length output string esp_modem at_raw has the wrong length output string (IDFGH-13911) Oct 18, 2024
@david-cermak
Copy link
Collaborator

@txf- Are your really calling the C++ API and not the esp_modem_at_raw() plain C wrapper? The C functions indeed have fixed output length parameter, but C++ use standard strings which could grow.

Isn't is possible that the response comes in chunks? Your pass criteria ("+CGNSINF:") are located in the beginning of the reply so that when the first chunk comes, all's good for returning OK with the partial response.

Could you please try:

  void getGps(){
    std::string out;
    command_result res = dce->at_raw("AT+CGNSINF\r",out,"SomethingThatNeverComes:","ERROR", 10000);
    ESP_LOGI(COMM_TAG,"get gps str: %s", out.c_str()); 
  }

Now this should fail, but once it would, should include the entire string.

@txf-
Copy link
Author

txf- commented Nov 5, 2024

@david-cermak
I changed it to look for the "OK", which is sent a few moments after the CGNSINF result string. It then captures the whole string.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants