diff options
author | Aleksander Morgado <aleksander@aleksander.es> | 2018-04-30 12:57:50 +0200 |
---|---|---|
committer | Aleksander Morgado <aleksander@aleksander.es> | 2018-04-30 18:23:39 +0200 |
commit | 43d0bd0f9135512a0531b5808354e00db9d6f22a (patch) | |
tree | a4d7ae7d710c3f354a2b5e7bcf1c7eb5b6168487 /src/mm-base-modem.c | |
parent | 21c9a239ecc56d941032630649ca6149296bf98d (diff) |
base-modem: improve broken modem detection logic
If the serial port timeout detection logic is enabled, warn whenever
more than one consecutive command timeout happens, not just when the
limit is reached.
Diffstat (limited to 'src/mm-base-modem.c')
-rw-r--r-- | src/mm-base-modem.c | 34 |
1 files changed, 20 insertions, 14 deletions
diff --git a/src/mm-base-modem.c b/src/mm-base-modem.c index 458ec74a..12e96dc0 100644 --- a/src/mm-base-modem.c +++ b/src/mm-base-modem.c @@ -110,21 +110,26 @@ get_hash_key (const gchar *subsys, static void serial_port_timed_out_cb (MMPortSerial *port, guint n_consecutive_timeouts, - gpointer user_data) + MMBaseModem *self) { - MMBaseModem *self = (MM_BASE_MODEM (user_data)); - - if (self->priv->max_timeouts > 0 && - n_consecutive_timeouts >= self->priv->max_timeouts) { - mm_warn ("(%s/%s) port timed out %u times, marking modem '%s' as disabled", - mm_port_type_get_string (mm_port_get_port_type (MM_PORT (port))), + /* If reached the maximum number of timeouts, invalidate modem */ + if (n_consecutive_timeouts >= self->priv->max_timeouts) { + mm_err ("(%s/%s) %s port timed out %u consecutive times, marking modem '%s' as invalid", + mm_port_subsys_get_string (mm_port_get_subsys (MM_PORT (port))), mm_port_get_device (MM_PORT (port)), + mm_port_type_get_string (mm_port_get_port_type (MM_PORT (port))), n_consecutive_timeouts, g_dbus_object_get_object_path (G_DBUS_OBJECT (self))); - - /* Only set action to invalidate modem if not already done */ g_cancellable_cancel (self->priv->cancellable); + return; } + + if (n_consecutive_timeouts > 1) + mm_warn ("(%s/%s) %s port timed out %u consecutive times", + mm_port_subsys_get_string (mm_port_get_subsys (MM_PORT (port))), + mm_port_get_device (MM_PORT (port)), + mm_port_type_get_string (mm_port_get_port_type (MM_PORT (port))), + n_consecutive_timeouts); } gboolean @@ -214,11 +219,12 @@ mm_base_modem_grab_port (MMBaseModem *self, return FALSE; } - /* For serial ports, enable port timeout checks */ - g_signal_connect (port, - "timed-out", - G_CALLBACK (serial_port_timed_out_cb), - self); + /* For serial ports, enable port timeout checks if requested to do so */ + if (self->priv->max_timeouts > 0) + g_signal_connect (port, + "timed-out", + G_CALLBACK (serial_port_timed_out_cb), + self); /* For serial ports, optionally use a specific baudrate */ if (mm_kernel_device_has_property (kernel_device, "ID_MM_TTY_BAUDRATE")) |