Skip to content
Snippets Groups Projects
Commit 021ab976 authored by Toon Stegen's avatar Toon Stegen
Browse files

at driver: fix at_send_cmd_get_lines bug

When reusing the same buffer for the at command and response, no command
would be sent because the buffer was cleared. This is fixed by only
clearing the buffer after the command has been sent.
parent b518f3c7
No related branches found
No related tags found
No related merge requests found
...@@ -121,8 +121,6 @@ ssize_t at_send_cmd_get_lines(at_dev_t *dev, const char *command, ...@@ -121,8 +121,6 @@ ssize_t at_send_cmd_get_lines(at_dev_t *dev, const char *command,
size_t bytes_left = len - 1; size_t bytes_left = len - 1;
char *pos = resp_buf; char *pos = resp_buf;
memset(resp_buf, '\0', len);
at_drain(dev); at_drain(dev);
res = at_send_cmd(dev, command, timeout); res = at_send_cmd(dev, command, timeout);
...@@ -130,6 +128,10 @@ ssize_t at_send_cmd_get_lines(at_dev_t *dev, const char *command, ...@@ -130,6 +128,10 @@ ssize_t at_send_cmd_get_lines(at_dev_t *dev, const char *command,
goto out; goto out;
} }
/* only clear the response buffer after sending the command,
* so the same buffer can be used for command and response */
memset(resp_buf, '\0', len);
while (1) { while (1) {
res = at_readline(dev, pos, bytes_left, keep_eol, timeout); res = at_readline(dev, pos, bytes_left, keep_eol, timeout);
if (res == 0) { if (res == 0) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment