This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

reading AT responses from the modem

I am trying to read from the modem on the nrf9160 DK using the AF_LTE socket and am running to a problem with reading the response from AT+CLAC. I've chosen that command to stress test the code to see if it can handle big responses. The normal response is somewhere in the range of 1000 bytes and the buffer I supply to recv is only 128 bytes. I expected I could keep calling recv() to get a chunk at a time until the OK shows up but after I get the first 128 bytes, my next call to recv() just hangs.

The behavior I see makes me think the socket works more like a datagram socket (eg UDP) instead of a stream socket (eg TCP). Can somebody confirm how I am supposed to read an arbitrarily large response? Can I do it in chunks or do I have to read the whole thing at once? And is AT+CLAC the only command that can cause this problem?

Modem firmware v1.0.0, btw.

Parents
  • Hi.

    Regarding other AT commands with long responses, I only know of %CMNG. Looking at the documentation, I also expect it might be necessary with %XPMNG, %XBANDLOCK, %XMIPIRFFEDEV, %XMONITOR, and +CMT notifications. However, I have not confirmed the max length of those responses.

    As to how you can receive long responses, you can do this by setting CONFIG_AT_CMD_RESPONSE_MAX_LEN to a sufficiently large number in your prj.conf.

    Best regards,

    Didrik

  • Thanks for the command suggestions. For the time being I will keep the max size small as I have no need for the commands listed above.

    I am not using the AT driver, but similar code to what the driver does and the same resolution applies, to set a max response size. I added a call to recv(..., MSG_PEEK) which works nicely to let me know if the response would exceed the buffer size.

Reply Children
No Data
Related