aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAleksander Morgado <aleksander@aleksander.es>2021-03-31 00:43:32 +0200
committerAleksander Morgado <aleksander@aleksander.es>2021-03-31 13:55:47 +0200
commit3ca80d8e512061728ed02d66e06b77ac384a9766 (patch)
tree1123178a27fc1304c3c6114a84cd2de64230ed5b
parent9f7bbf28d210a4986f2d0d353e4e37024bc91c4a (diff)
mmtty: make sure \r\n is removed from the user line
-rw-r--r--test/mmtty.c13
1 files changed, 11 insertions, 2 deletions
diff --git a/test/mmtty.c b/test/mmtty.c
index 28df6285..7bffd3c0 100644
--- a/test/mmtty.c
+++ b/test/mmtty.c
@@ -125,12 +125,21 @@ input_callback (GIOChannel *channel,
status = g_io_channel_read_line (channel, &line, NULL, NULL, &error);
switch (status) {
- case G_IO_STATUS_NORMAL:
+ case G_IO_STATUS_NORMAL: {
+ gsize line_len = 0;
+
+ /* remove \r\n before running as AT command */
+ line_len = strlen (line);
+ while (line_len > 0 && (line[line_len - 1] == '\r' || line[line_len - 1] == '\n')) {
+ line[line_len - 1] = '\0';
+ line_len--;
+ }
+
mm_port_serial_at_command (port, line, 60, FALSE, FALSE, NULL,
(GAsyncReadyCallback) at_command_ready, NULL);
g_free (line);
return TRUE;
-
+ }
case G_IO_STATUS_ERROR:
g_printerr ("error: %s\n", error->message);
g_error_free (error);