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

*CLOS* in the output #20

Open
faritka opened this issue Mar 29, 2013 · 2 comments
Open

*CLOS* in the output #20

faritka opened this issue Mar 29, 2013 · 2 comments
Assignees

Comments

@faritka
Copy link

faritka commented Mar 29, 2013

I try to make subsequent calls to retrieve multiple files from a server.

The flag "connected" is unreliable. In the first call, it's true. In the second, after "open" it's true, then suddenly it's false.

Because this flag is incorrect, when I download a file and save it on the SD card, it's 6 bytes longer because of the added "CLOS" phrase inside of the WiFly stream.

The main problem is in the function "available":

int WiFly::available()
{
int count;

count = serial->available();
if (count > 0) {
if (debugOn) {
    debug.print(F("available: peek = "));
    debug.println((char)serial->peek());
}
/* Check for TCP stream closure */
if (serial->peek() == '*') {
    if (connected) {
    if (checkClose(true)) {
        return -1;
    } else {
        return peekCount + serial->available();
    }
    } else {
    checkOpen(true);
    return peekCount + serial->available();
    }
}
}

return count+peekCount;

}

I modified it to always check for the "CLOS" statement, connected or not, and now files are correct.

int WiFly::available()
{
int count;

count = serial->available();
if (count > 0) {
if (debugOn) {
    debug.print(F("available: peek = "));
    debug.println((char)serial->peek());
}
/* Check for TCP stream closure */
if (serial->peek() == '*') {
    if (checkClose(true)) {
        return -1;
    } else {
        return peekCount + serial->available();
    }
    if (!connected) {
    checkOpen(true);
    return peekCount + serial->available();
    }
}
}

return count+peekCount;

}

@ghost ghost assigned harlequin-tech Apr 4, 2013
@harlequin-tech
Copy link
Owner

Thanks for the bug report. I'll try out your fix and see if I can fix the connected flag status.

@faritka
Copy link
Author

faritka commented Apr 5, 2013

It won't fix the connected flag.
At least, it'll delete the CLOS string from the incoming data.

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

2 participants