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

correct ATParser::read() and ATParser::write() to behave as documented #3

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions ATParser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,10 @@ int ATParser::write(const char *data, int size)
int i = 0;
for ( ; i < size; i++) {
if (putc(data[i]) < 0) {
return -1;
break;
}
}
return i;
return (i == 0) ? -1 : i;
}

int ATParser::read(char *data, int size)
Expand All @@ -79,11 +79,12 @@ int ATParser::read(char *data, int size)
for ( ; i < size; i++) {
int c = getc();
if (c < 0) {
return -1;
break;
} else {
data[i] = c;
}
data[i] = c;
}
return i;
return (i == 0) ? -1 : i;
}


Expand Down
2 changes: 1 addition & 1 deletion ATParser.h
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ class ATParser
/**
* Allows timeout to be changed between commands
*
* @param timeout timeout of the connection
* @param timeout timeout of the connection in ms
*/
void setTimeout(int timeout) {
_timeout = timeout;
Expand Down