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

Electron socketSend max buffer size logic 1 byte too small for 1024 byte chunks #1104

technobly opened this issue Aug 28, 2016 · 0 comments


Copy link

commented Aug 28, 2016

Please see community discussion here:

int MDMParser::socketSend(int socket, const char * buf, int len)
    int cnt = len;
    while (cnt > 0) {
        int blk = USO_MAX_WRITE;
        if (cnt < blk)
            blk = cnt;
        bool ok = false;
            if (ISSOCKET(socket)) {
                if (RESP_PROMPT == waitFinalResp()) {
                    send(buf, blk);
                    if (RESP_OK == waitFinalResp())
                        ok = true;
        if (!ok)
            return MDM_SOCKET_ERROR;
        buf += blk;
        cnt -= blk;
    return (len - cnt);

From the community:

Basically, USO_MAX_WRITE is 1024, so if you send a chunk of 1024 bytes, it fails the cnt < blk test. Things go bad from there. So use 1023. Or 512. Or anything less than 1024 (but not equal to).

When 1024 is used, blk gets set to USO_MAX_WRITE and failing the cnt < blk test is inconsequential.

Note that USOWR max buffer sizes are:

Number of data bytes to write:
• Base syntax normal mode: range 0-1024
• Base syntax HEX mode: range 0-512
• Binary extended syntax: range 0-1024


  • Minimum test case added
  • Device, system and user firmware versions stated (electron, 0.6.0-rc.1 or 0.5.3-rc.2 would have this issue)
  • Particle confirmed

@technobly technobly added this to the 0.7.x milestone Sep 9, 2016

@avtolstoy avtolstoy self-assigned this Oct 16, 2016

avtolstoy added a commit that referenced this issue Oct 16, 2016

@technobly technobly modified the milestones: 0.7.x, 0.6.1 Nov 29, 2016

@technobly technobly closed this Nov 29, 2016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
2 participants
You can’t perform that action at this time.