ubxlib: Corrupted payload with uSockWrite

Environment

Module type: SARA-U201 Device type: Cell Network type: Cell Enable power pin: N/C (tied to 3v3) Power-on pin: N/C tied high VInt pin: N/C DTR power saving pin: N/C Transport type: UART Baud rate: 115200 CTS/RTS: N/C, pulled to ground with 2kΩ resistors

Platform: esp-idf Firmware: esp-idf v5.1.1 ubxlib: bd8a69efdecc6655fd2f6fcaebc9d63dac1f7571 Example: main_tls.c with no TLS, no credential checking.

Issue

When opening a TCP cellular socket, the payload data is corrupted by the AT+USOWR command (i.e. the beginning of my payload is corrupted and an AT+USOWR is appended and sent to my http server which corrupts my request).

I have a mod on my board which pulls CTS and RTS down to ground with 2kΩ resistors since they are not connected and serial communication over UART was not possible with those pins floating.

See similar issue here: https://portal.u-blox.com/s/question/0D52p00009JhO5VCAV/sara-r412m-sending-at-command-on-socket

Workaround

To fix this issue I had to disable UART power saving for modules that don’t use CTS/RTS and use Tx data to wakeup by commenting out the following:

//else clause in u_cell_pwr.c:987
else {
            success = moduleConfigureOne(atHandle, "AT&K0",
                                         U_CELL_PWR_CONFIGURATION_COMMAND_TRIES);
            // RTS/CTS handshaking is not used by the UART HW, we
            // can use the wake-up on TX line feature without any
            // complications
            if (uAtClientWakeUpHandlerIsSet(atHandle) &&
                U_CELL_PRIVATE_HAS(pInstance->pModule,
                                   U_CELL_PRIVATE_FEATURE_UART_POWER_SAVING)) {
                uartPowerSavingMode = U_CELL_PWR_PSV_MODE_DATA;
            }

(i.e. do not send AT+UPSV=1,1300, or likely any other derivative of that command).

About this issue

  • Original URL
  • State: closed
  • Created 8 months ago
  • Comments: 20 (12 by maintainers)

Most upvoted comments

I’m sane! Well, at least, thank you for the straw to clutch at. Having a working thing is a good start.

FYI, the main support guys for SARA-U201 are in Italy which is currently experiencing one of those European national holidays that are on a Thursday and so no-one will be in now until next week. If nothing has occurred to me by then I know who to contact though.

Yeah just, for your sanity, here is a working example where this time the power saving command was AT+UPSV=0 since U_CFG_CELL_DISABLE_UART_POWER_SAVING was defined.

Wireshark: Screenshot 2023-11-02 152942

My server: Screenshot 2023-11-02 152942

Ubxlib AT log Screenshot 2023-11-02 at 5 45 26 PM

U_CELL_NET: connected after 11 second(s).
Looking up server address...
Address is: IPV4 38.23.179.39
Creating socket...
0000/01/01 00:00:00.049: AT+USOCR=6
0000/01/01 00:00:00.089:
0000/01/01 00:00:00.089: +USOCR: 0
0000/01/01 00:00:00.090:
0000/01/01 00:00:00.090: OK
U_SOCK: socket created, descriptor 0, network handle 0x3fcc0b18, socket handle 0.
U_SOCK: connecting socket to "38.23.179.39:8080"...
0000/01/01 00:00:00.149: AT+USOCO=0,"38.23.179.39",8080
0000/01/01 00:00:00.529:
0000/01/01 00:00:00.529: OK
U_SOCK: socket with descriptor 0, network handle 0x3fcc0b18, socket handle 0, is  connected to address "38.23.179.39:8080".
Sending data...
0000/01/01 00:00:00.589: AT+USOWR=0,44
0000/01/01 00:00:00.639:
0000/01/01 00:00:00.639: @0000/01/01 00:00:00.689: The quick brown fox jumps over the lazy dog[00]AT
0000/01/01 00:00:08.759: AT
0000/01/01 00:00:08.919:
0000/01/01 00:00:08.919: +USOWR: 0,44
0000/01/01 00:00:08.920:
0000/01/01 00:00:08.920: OK
0000/01/01 00:00:08.920: AT+USOER
0000/01/01 00:00:08.959:
0000/01/01 00:00:08.959: +USOER: 0
0000/01/01 00:00:08.959:
0000/01/01 00:00:08.960: OK
Sent 44 byte(s) to echo server.
Done.

Here’s the output, this time appended again. Screenshot 2023-11-02 152942 So it seems to shuffle around a bit.

That looks quite sensible, UART power saving is enabled if nothing happens for 6 seconds. What we appear to be seeing, however, is only the periodic wake-up on paging and NOT the wake-up on a character arriving at the module.

FYI, integration manual:

https://content.u-blox.com/sites/default/files/SARA-G3-U2_SysIntegrManual_UBX-13000995.pdf

…page 58, “Wake-up via data reception”, is the detailed reference.

It says:

On SARA-U2 series, the TXD input line is configured to wake up the system via data reception if AT+UPSV=1 is set with hardware flow control disabled

We have that, AT&K0 being the bit that disables the flow control.

I will continue thinking…

U_CELL: initialising with enable power pin not connected, PWR_ON pin not connected and VInt pin not connected.
[00]AT
AT
OK
U_CELL_PWR: powering on, module is already on.
ATE0
ATE0
OK
AT+CMEE=2
OK
AT+UDCONF=1,0
+UMWI: 0,1
+UMWI: 0,2
+UMWI: 0,3
+UMWI: 0,4
OK
ATI9
23.60,A01.01
OK
AT&C1
OK
AT&D1
OK
AT&K0
OK
AT+UPSV=1,1300
OK
AT+UGPRF?
AT
AT
OK
AT+CFUN=0
OK
Opened device with return code 0.
Bringing up the network...
U_CELL_NET: preparing to register/connect...
AT+CREG=2
OK
AT+CGREG=2
OK
AT+CIMI
234500023270006
OK
U_CELL_NET: user-specified APN is "jtm2m".
U_CELL_NET: setting automatic network selection mode...
AT+COPS?
+COPS: 0
OK
AT+CFUN=1
OK
AT+CREG?
+CREG: 2,0
OK
0: NReg
AT+CGREG?
+CGREG: 2,0
OK
0: NReg
AT+CREG?
+CREG: 2,0
OK
0: NReg
AT+CGREG?
+CGREG: 2,0
OK
0: NReg
AT+CREG?
+CREG: 2,0
OK
0: NReg
AT+CGREG?
+CGREG: 2,0
OK
0: NReg
AT+CREG?
+CREG: 2,0
OK
0: NReg
AT+CGREG?
+CGREG: 2,0
OK
0: NReg
AT+CREG?
+CREG: 2,0
OK
0: NReg
AT+CGREG?
+CGREG: 2,0
OK
0: NReg
AT+CREG?
+CREG: 2,0
OK
0: NReg
AT+CGREG?
+CGREG: 2,0
OK
0: NReg
AT+CREG?
+CREG: 2,0
OK
0: NReg
AT+CGREG?
+CGREG: 2,0
OK
0: NReg
AT+CREG?
+CREG: 2,0
OK
0: NReg
AT+CGREG?
+CGREG: 2,0
OK
0: NReg
AT+CREG?
+CREG: 2,0
OK
0: NReg
AT+CGREG?
+CGREG: 2,0
OK
0: NReg
AT+CREG?
+CREG: 2,0
OK
0: NReg
AT+CGREG?
+CGREG: 2,0
OK
0: NReg
AT+CREG?
+CREG: 2,0
OK
0: NReg
+CREG: 5,"EA6D","544C28",2
+CGREG: 5,"EA6D","544C28",2,"01"
2: RegR
2: RegR
AT+COPS=3,0
OK
AT+COPS?
+COPS: 0,0,"Rogers Wireless",2
OK
AT+CGATT?
+CGATT: 1
OK
AT+UPSD=0,1,"jtm2m"
OK
AT+UPSD=0,2,""
OK
AT+UPSD=0,3,""
OK
AT+UPSD=0,7,"0.0.0.0"
OK
AT+UPSD=0,6,3
OK
AT+UPSDA=0,3
OK
U_CELL_NET: connected after 12 second(s).
Looking up server address...
Address is: IPV4 38.23.179.39
Creating socket...
AT+USOCR=6
+USOCR: 0
OK
U_SOCK: socket created, descriptor 0, network handle 0x3fcc0b18, socket handle 0.
U_SOCK: connecting socket to "38.23.179.39:8080"...
AT+USOCO=0,"38.23.179.39",8080
OK
U_SOCK: socket with descriptor 0, network handle 0x3fcc0b18, socket handle 0, is  connected to address "38.23.179.39:8080".
Sending data...
AT+USOWR=0,44
@The quick brown fox jumps over the lazy dog[00]AT
AT
+USOWR: 0,44
OK
AT+USOER
+USOER: 0
OK
Sent 44 byte(s) to echo server.
Done.