u-blox / ubxlib

Portable C libraries which provide APIs to build applications with u-blox products and services. Delivered as add-on to existing microcontroller and RTOS SDKs.
Apache License 2.0
287 stars 82 forks source link

Socket sometimes hangs for 10s #169

Closed arnoutdekimo closed 7 months ago

arnoutdekimo commented 7 months ago

Hi,

While trying to avoid issues with the httplib (by going to socket-based api), I ran into another issue: Sometimes, the socket read "hangs" for 10 seconds, before continuing.

socketlbox.txt socketblocks-cap.zip

In the logs, we can see (take into account that timestamp is added on the NEXT line):

image

So a reply +UUSORD: 0,3036 comes in, but only 10 seconds later do we send another AT command On the logic captures, this is also clear:

image

I even breaked in the code, and checked where the system was:

image image

My code basically connected, wrote some data, but upon the LAST piece of data (contain the double newline, causing the remote to start replying the whole data), the ubxcode hangs. 10s later, everything eventually succeeds, but I don't want to lose 10s:)

I'm guessing something goes wrong in timing when handling the AT commands

arnoutdekimo commented 7 months ago

FYI, I am guessing the 10s timeout comes from here, in bufferFill:

image

RobMeades commented 7 months ago

Seems likely: the timeout when reading the +UUSORD URC should be the 100 ms one, based on checking if we're in a callback task, so there shouldn't be a 10 second timeout around there.

arnoutdekimo commented 7 months ago

This issue has the same underlying root cause as https://github.com/u-blox/ubxlib/issues/163

I'm closing this one, and typing my final conclusion in the other one