aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAleksander Morgado <aleksander@lanedo.com>2011-10-13 14:59:30 +0200
committerAleksander Morgado <aleksander@lanedo.com>2011-10-14 17:22:12 +0200
commitfd9f2d2804a6ebffbc2365b56d34dcf18aaa9942 (patch)
tree777f3e1b29a40594811b10ed91391be98bb223ab
parent6e0e46e51e9b022577db6adeb986d3241da9bd4d (diff)
serial: skip NUL bytes coming before real AT responses
Some Cinterion modems send a NUL byte before the "CONNECTED" reply to "ATD" (only during the first ATD try anyway). This fix will ignore any NUL byte leading the real response.
-rw-r--r--src/mm-serial-parsers.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/src/mm-serial-parsers.c b/src/mm-serial-parsers.c
index f94e1156..85b5380f 100644
--- a/src/mm-serial-parsers.c
+++ b/src/mm-serial-parsers.c
@@ -265,7 +265,11 @@ mm_serial_parser_v1_parse (gpointer data,
g_return_val_if_fail (parser != NULL, FALSE);
g_return_val_if_fail (response != NULL, FALSE);
- if (G_UNLIKELY (!response->len || !strlen (response->str)))
+ /* Skip NUL bytes if they are found leading the response */
+ while (response->len > 0 && response->str[0] == '\0')
+ g_string_erase (response, 0, 1);
+
+ if (G_UNLIKELY (!response->len))
return FALSE;
/* First, check for successful responses */