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

[BUG] ATCMD socket race condition with SSEND (synchronous) and SEVENT:RECV_READY #17

Open
bpg0x03 opened this issue May 26, 2023 · 1 comment

Comments

@bpg0x03
Copy link

bpg0x03 commented May 26, 2023

Good morning,

I've been running the device in standalone mode with the HSPI ATCMD firmware. I've found a bug that if you send it some data it will go into passthrough mode even if you sent a size on the SSEND command. The data sent in this case ends with a \r\n. Could that be the issue? If you're using strtok or something to find the end of data...

Any future plan to open source the ATCMD firmware?

I (10568) NRC: SEND: AT+SOPEN="tcp",1234

I (10598) NRC: RECV: +SOPEN:0

I (10598) NRC: RECV: OK

...
I (16278) NRC: RECV: +SEVENT:"CONNECT",1

... 
I (16288) NRC: SEND: AT+SSEND=1,24 // size passed, should not go to passthrough

I (16288) NRC: RECV: OK

I (16308) NRC: SEND: DATA 24

I (16308) NRC: SEND: AT ******* THIS IS STILL INTERPRETED AS DATA??

I (16308) NRC: RECV: +SEVENT:"RECV_READY",1,41 // other side sends data

I (17408) NRC: RECV: +SEVENT:"SEND_IDLE",1,0,0,0 **** EVENT TO LEAVE PASSTHROUGH?????
@bpg0x03
Copy link
Author

bpg0x03 commented May 26, 2023

Update, this is due to the +SEVENT:"RECV_READY" arriving in between the SSEND and the data payload.

Example code:

    if(nrc_atcmd_send_cmd("AT+SSEND=%u,%u", sock->id, len) != ATCMD_RET_OK){
        socket_error("send command failed");
        return -1;
    }
    sleep(5);
    socket_log("Up from sleep"); // Send data from other side at this point. Generates RECV READY event
    if(nrc_atcmd_send_data(buf, len) != 0){
        socket_error("sending actual data failed");
        return -1;
    }

//SEND_IDLE event generated

The firmware should be able to handle this case, since we cannot handle it from our drivers. Cannot stop an event from being generated. Sending "AT\r\n" to get out of passthrough mode even after that SEND_IDLE does not break it out of whatever state it is in. The only way I could get it to continue is resetting.

Please advise.

@bpg0x03 bpg0x03 changed the title [BUG] ATCMD socket goes to passthrough mode even when size passed [BUG] ATCMD socket race condition with SSEND (normal) and SEVENT:RECV_READY May 26, 2023
@bpg0x03 bpg0x03 changed the title [BUG] ATCMD socket race condition with SSEND (normal) and SEVENT:RECV_READY [BUG] ATCMD socket race condition with SSEND (synchronous) and SEVENT:RECV_READY May 26, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant