drivers: modem: Add support for different line endings
This makes it possible to handle devices that use different line endings. Signed-off-by: Tobias Svehagen <tobias.svehagen@gmail.com>
This commit is contained in:
parent
6881da0afa
commit
8a9c9d43bf
3 changed files with 11 additions and 1 deletions
|
@ -388,7 +388,7 @@ static int _modem_cmd_send(struct modem_iface *iface,
|
|||
}
|
||||
|
||||
iface->write(iface, buf, strlen(buf));
|
||||
iface->write(iface, "\r", 1);
|
||||
iface->write(iface, data->eol, data->eol_len);
|
||||
|
||||
if (timeout == K_NO_WAIT) {
|
||||
ret = 0;
|
||||
|
@ -482,6 +482,12 @@ int modem_cmd_handler_init(struct modem_cmd_handler *handler,
|
|||
return -EINVAL;
|
||||
}
|
||||
|
||||
if (data->eol == NULL) {
|
||||
data->eol_len = 0;
|
||||
} else {
|
||||
data->eol_len = strlen(data->eol);
|
||||
}
|
||||
|
||||
handler->cmd_handler_data = data;
|
||||
handler->process = cmd_handler_process;
|
||||
|
||||
|
|
|
@ -75,6 +75,9 @@ struct modem_cmd_handler_data {
|
|||
|
||||
int last_error;
|
||||
|
||||
const char *eol;
|
||||
size_t eol_len;
|
||||
|
||||
/* rx net buffer */
|
||||
struct net_buf *rx_buf;
|
||||
|
||||
|
|
|
@ -1315,6 +1315,7 @@ static int modem_init(struct device *dev)
|
|||
mdata.cmd_handler_data.match_buf_len = sizeof(mdata.cmd_match_buf);
|
||||
mdata.cmd_handler_data.buf_pool = &mdm_recv_pool;
|
||||
mdata.cmd_handler_data.alloc_timeout = BUF_ALLOC_TIMEOUT;
|
||||
mdata.cmd_handler_data.eol = "\r";
|
||||
ret = modem_cmd_handler_init(&mctx.cmd_handler,
|
||||
&mdata.cmd_handler_data);
|
||||
if (ret < 0) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue