Skip to content
Snippets Groups Projects
Unverified Commit 1f2985df authored by Vincent Dupont's avatar Vincent Dupont Committed by GitHub
Browse files

Merge pull request #9952 from OTAkeys/at_fix_buffer_memset

at driver: allow using same buffer for command and response in at_send_cmd_get_lines()
parents 028bc2a3 021ab976
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,
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) {
......
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