ARMmbed / mbed-os

Arm Mbed OS is a platform operating system designed for the internet of things
https://mbed.com
Other
4.67k stars 2.98k forks source link

Workaround for Ublox G450 firmware issue #10024

Closed NeilMacMullen closed 3 years ago

NeilMacMullen commented 5 years ago

Description

When using a TCP socket, the Ublox G450 appears to suffer from a firmware bug where, if more bytes are requested with USORD than are available in the internal modem buffer, and then more data is received over the air, an unsolicited response can be generated. Eg.

---> Client requests 20K bytes from remote server <--- +UUSORD 1500 ---> AT+USORD 1000 <--- +USORD 1000 ... <---- +UUSORD 500 ---> AT+USORD 1000 <--- +USORD 500 ... <---- more data received from network. <--- +USORD 1000.... //'unsolicited' response <--- ++UUSORD ...

The Ublox AT command manual says

If the number of data bytes requested to be read from the buffer is bigger than the number of bytes stored in the buffer only the available amount of data bytes will be read.

and the stack has been written with this assumption but the following code appears to be a safer implementation for UBLOX_AT_CellularStack::socket_recvfrom_impl in UBLOX_AT_CellularStack.cpp


 } else if (socket->proto == NSAPI_TCP) {
        while (success && (size > 0)) {

            read_blk = MIN(read_blk,UBLOX_MAX_PACKET_SIZE); //don't request more than +USORD can handle in a single chunk
            read_blk = MIN(read_blk,size); //don't request more than are remaining for socket-read
            read_blk = MIN(read_blk,socket->pending_bytes); //never request more than are actually in modem buffer
            if (socket->pending_bytes > 0) {
                _at.cmd_start("AT+USORD=");
                _at.write_int(socket->id);
                _at.write_int(read_blk);
                _at.cmd_stop();

Issue request type

[ ] Question
[ ] Enhancement
[X Bug
0xc0170 commented 5 years ago

cc @ARMmbed/mbed-os-wan @ARMmbed/team-ublox

0xc0170 commented 4 years ago

@ARMmbed/team-ublox Please review

fahimalavi commented 4 years ago

Looks fine to me

0xc0170 commented 4 years ago

@NeilMacMullen Please send a pull request to fix the issue

ciarmcom commented 4 years ago

Thank you for raising this detailed GitHub issue. I am now notifying our internal issue triagers. Internal Jira reference: https://jira.arm.com/browse/IOTOSM-2280

adbridge commented 3 years ago

@NeilMacMullen Please send a pull request to fix the issue

As there has been no response to this I am closing this issue.