[PATCH] Re: problem with cinterion TC63i rs232 modem



Hi,

So the real problem here is that the Cinterion modem sends a NUL byte
before the CONNECT response:

> [mm-at-serial-port.c:298] debug_log(): (ttyS1): --> 'ATD*99***1#<CR>'
> modem-manager[2621]: <debug> [1317807408.548825] 
> [mm-at-serial-port.c:298] debug_log(): (ttyS1): <-- '\0'
> modem-manager[2621]: <debug> [1317807410.433152] 
> [mm-at-serial-port.c:298] debug_log(): (ttyS1): <-- 
> '<CR><LF>CONNECT<CR><LF>' 

It only does that during the first reply to ATD, not in the next tries,
that is why you were able to connect successfully after the first try.

Attached is a patch that solves the issue. It modifies the common serial
parser, so not something Cinterion-specific, but the change is quite
small and shouldn't affect other plugins.

Cheers,

-- 
Aleksander
>From 9d56d7b55c55859e259d22476eef515e90d84a0a Mon Sep 17 00:00:00 2001
From: Aleksander Morgado <aleksander lanedo com>
Date: Thu, 13 Oct 2011 14:59:30 +0200
Subject: [PATCH] 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.
---
 src/mm-serial-parsers.c |    6 +++++-
 1 files changed, 5 insertions(+), 1 deletions(-)

diff --git a/src/mm-serial-parsers.c b/src/mm-serial-parsers.c
index f94e115..85b5380 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 */
-- 
1.7.4.1



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]