1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2025-01-17 04:52:59 +01:00

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.
This commit is contained in:
Toon Stegen 2018-09-18 10:57:24 +02:00
parent b518f3c73e
commit 021ab9764a

View File

@ -121,8 +121,6 @@ ssize_t at_send_cmd_get_lines(at_dev_t *dev, const char *command,
size_t bytes_left = len - 1;
char *pos = resp_buf;
memset(resp_buf, '\0', len);
at_drain(dev);
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,
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) {
res = at_readline(dev, pos, bytes_left, keep_eol, timeout);
if (res == 0) {