I've attached a patch which uses the "custom regex" feature of the
existing parser in order to detect PPP and say that things are good.
A few things to note:

* I created the regex based on data I saw output from my modem.  At
best it is correct, at worst it won't do any harm.
* Ideally I would only use this for the ME310 modem, but I didn't see
a way to do that in the plugin.  I'm certainly open to suggestions.
* A similar technique was used for a wavecom modem quirk, and this is
definitely based on that.

I've also added hints to the udev rules for the ME310G1-WW device, but
I see that those were already added in git in
fff47478cc5887176830a5debe2c4204434c222f.

These patches are based on 1.14.0, but I can check out master from git
and apply my changes there if needed.

This particular device has a second port configuration (1bc7:1102),
which which  looks like this:

/:  Bus 01.Port 1: Dev 1, Class=root_hub, Driver=atmel-ehci/3p, 480M
    |__ Port 2: Dev 7, If 0, Class=Vendor Specific Class, Driver=option, 480M
    |__ Port 2: Dev 7, If 1, Class=Vendor Specific Class, Driver=option, 480M
    |__ Port 2: Dev 7, If 2, Class=Vendor Specific Class, Driver=option, 480M
    |__ Port 2: Dev 7, If 3, Class=Communications, Driver=cdc_ether, 480M
    |__ Port 2: Dev 7, If 4, Class=CDC Data, Driver=cdc_ether, 480M

I've not been able to get the cdc_ether portion working yet, although
I am hopeful.  If both ECM and "option" serial interfaces are
available, how does ModemManager choose between them?

On Fri, Jul 10, 2020 at 10:08 AM Mark Deneen <mden...@gmail.com> wrote:
>
> Hi!
>
> I have a Telit ME310G1-WW cell modem which is supported in newer
> (5.5.x) kernels with the option driver.  ModemManager (1.12.6, will
> try to test newer versions) almost works, but it appears to be a modem
> quirk which prevents MM from detecting that it is connected.  Here's a
> few log entries showing the issue:
>
> Feb  7 17:19:55 sama5d27 daemon.debug ModemManager[783]: <debug>
> (ttyUSB2): --> 'ATD*99***6#<CR>'
> Feb  7 17:19:55 sama5d27 daemon.debug ModemManager[783]: <debug>
> (ttyUSB2): <-- '~\255}#\192!}!(} }9}"}&} } } }
> }#}%\194#}%}%}&s\168\133;}'}"}(}"0O~'
>
> It selects the appropriate context (6) and issues the ATD command, but
> the modem responds with PPP data and never prints out "CONNECT", and
> MM eventually times out waiting for a response.
>
> This modem is very new, and I likely have one of a few which are out
> in the wild, so there's a chance that this may be corrected at some
> point by Telit.  With that being said, I was considering adding a
> GRegex to mm-serialparsers.c which matches PPP escape sequences in
> order to detect the connection.  Does this seem like a valid approach?
>
> All the best,
> Mark Deneen
From 41a8dc9fc5116938b410b785c1ee2eb3d79cca9d Mon Sep 17 00:00:00 2001
From: Mark Deneen <mden...@gmail.com>
Date: Fri, 10 Jul 2020 16:05:45 -0400
Subject: [PATCH] Detect PPP data if CONNECT is not returned from the modem

---
 plugins/telit/mm-broadband-modem-telit.c | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)

diff --git a/plugins/telit/mm-broadband-modem-telit.c b/plugins/telit/mm-broadband-modem-telit.c
index 48ae4de..97be935 100644
--- a/plugins/telit/mm-broadband-modem-telit.c
+++ b/plugins/telit/mm-broadband-modem-telit.c
@@ -26,6 +26,7 @@
 #include "ModemManager.h"
 #include "mm-log-object.h"
 #include "mm-errors-types.h"
+#include "mm-serial-parsers.h"
 #include "mm-modem-helpers.h"
 #include "mm-base-modem-at.h"
 #include "mm-iface-modem.h"
@@ -310,6 +311,9 @@ static void
 setup_ports (MMBroadbandModem *self)
 {
     MMPortSerialGps *gps_data_port;
+    gpointer parser;
+    MMPortSerialAt *primary;
+    GRegex *regex;
 
     /* Call parent's setup ports first always */
     MM_BROADBAND_MODEM_CLASS (mm_broadband_modem_telit_parent_class)->setup_ports (self);
@@ -328,6 +332,22 @@ setup_ports (MMBroadbandModem *self)
                                               self,
                                               NULL);
     }
+    primary = mm_base_modem_peek_port_primary (MM_BASE_MODEM (self));
+
+    if (primary) {
+        mm_obj_dbg (self, "parser will attempt to detect ppp messages");
+        parser = mm_serial_parser_v1_new ();
+        regex = g_regex_new ("~\xFF}#\xC0!}",
+                             G_REGEX_RAW | G_REGEX_OPTIMIZE,
+                             0, NULL);
+        mm_serial_parser_v1_set_custom_regex (parser, regex, NULL);
+        g_regex_unref (regex);
+
+        mm_port_serial_at_set_response_parser (MM_PORT_SERIAL_AT (primary),
+                                               mm_serial_parser_v1_parse,
+                                               parser,
+                                               mm_serial_parser_v1_destroy);
+    }
 }
 
 static MMModemLocationSource
_______________________________________________
ModemManager-devel mailing list
ModemManager-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/modemmanager-devel

Reply via email to