[PATCH 2/2] base-modem: setup a maximum number of timeouts also for USB modems

Aleksander Morgado aleksander at aleksander.es
Sat Jun 2 15:56:15 UTC 2018


On 30/04/18 13:11, Aleksander Morgado wrote:
> We have a maximum number of timeouts that could be enabled for TTY
> modems, e.g. to detect whether the modem is available in the RS232
> port or has been unplugged. This was required because RS232 modems
> aren't notified via udev, so there was no other way to check presence
> of the modem.
> 
> But, the same kind of checks may be used in order to detect failed
> broken modems. If we have a modem that gets into an unstable state
> where no AT port command goes through and all get timed out, we can
> definitely flag the modem as invalid and get rid of it. If we don't do
> this, we would end up leaving the modem exposed and available for
> users of the API, but in a non-working state.
> 
>     ....
>     <info>  Modem /org/freedesktop/ModemManager1/Modem/0: state changed (registered -> connecting)
>     <debug> Launching 3GPP connection attempt with APN 'telefonica.es'
>     <debug> Looking for best CID...
>     <debug> (ttyACM2) device open count is 2 (open)
>     <debug> (ttyACM2): --> 'AT+CGDCONT?<CR>'
>     <debug> Unexpected +CGDCONT? error: 'Serial command timed out'
>     <warn>  (tty/ttyACM2) at port timed out 9 consecutive times
>     <debug> Using empty CID 1 with PDP type 'ipv4'
>     <debug> (ttyACM2) device open count is 3 (open)
>     <debug> (ttyACM2) device open count is 2 (close)
>     <debug> (ttyACM2): --> 'AT+CGDCONT=1,"IP","telefonica.es"<CR>'
>     <warn>  Couldn't initialize PDP context with our APN: 'Serial command timed out'
>     <debug> Couldn't connect bearer '/org/freedesktop/ModemManager1/Bearer/0': 'Serial command timed out'
>     <info>  Modem /org/freedesktop/ModemManager1/Modem/0: state changed (connecting -> registered)
>     <debug> Couldn't connect bearer: 'Serial command timed out'
>     <debug> (ttyACM2) device open count is 1 (close)
>     <error> (tty/ttyACM2) at port timed out 10 consecutive times, marking modem '/org/freedesktop/ModemManager1/Modem/0' as invalid
>     <debug> Removing from DBus bearer at '/org/freedesktop/ModemManager1/Bearer/0'
>     <debug> [device /sys/devices/pci0000:00/0000:00:14.0/usb1/1-5/1-5.5] unexported modem from path '/org/freedesktop/ModemManager1/Modem/0'
>     <debug> Periodic signal checks disabled
>     <debug> (ttyACM2) device open count is 0 (close)
>     <debug> (ttyACM2) closing serial port...
>     <debug> (ttyACM2) serial port closed
>     <debug> (ttyACM2) forced to close port
>     <debug> Modem (u-blox) '/sys/devices/pci0000:00/0000:00:14.0/usb1/1-5/1-5.5' completely disposed
> ---

This has been now merged in git master (not in the 1.8 release).

>  src/mm-base-modem.c | 8 +++++++-
>  1 file changed, 7 insertions(+), 1 deletion(-)
> 
> diff --git a/src/mm-base-modem.c b/src/mm-base-modem.c
> index 12e96dc0..996fbc13 100644
> --- a/src/mm-base-modem.c
> +++ b/src/mm-base-modem.c
> @@ -36,6 +36,10 @@
>  
>  G_DEFINE_ABSTRACT_TYPE (MMBaseModem, mm_base_modem, MM_GDBUS_TYPE_OBJECT_SKELETON);
>  
> +/* If we get 10 consecutive timeouts in a serial port, we consider the modem
> + * invalid and we request re-probing. */
> +#define DEFAULT_MAX_TIMEOUTS 10
> +
>  enum {
>      PROP_0,
>      PROP_VALID,
> @@ -1318,6 +1322,8 @@ mm_base_modem_init (MMBaseModem *self)
>                                                 g_str_equal,
>                                                 g_free,
>                                                 g_object_unref);
> +
> +    self->priv->max_timeouts = DEFAULT_MAX_TIMEOUTS;
>  }
>  
>  static void
> @@ -1497,7 +1503,7 @@ mm_base_modem_class_init (MMBaseModemClass *klass)
>                             "Max timeouts",
>                             "Maximum number of consecutive timed out commands sent to "
>                             "the modem before disabling it. If 0, this feature is disabled.",
> -                           0, G_MAXUINT, 0,
> +                           0, G_MAXUINT, DEFAULT_MAX_TIMEOUTS,
>                             G_PARAM_READWRITE);
>      g_object_class_install_property (object_class, PROP_MAX_TIMEOUTS, properties[PROP_MAX_TIMEOUTS]);
>  
> 


-- 
Aleksander
https://aleksander.es


More information about the ModemManager-devel mailing list