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.
This commit is contained in:
@@ -110,21 +110,26 @@ get_hash_key (const gchar *subsys,
|
|||||||
static void
|
static void
|
||||||
serial_port_timed_out_cb (MMPortSerial *port,
|
serial_port_timed_out_cb (MMPortSerial *port,
|
||||||
guint n_consecutive_timeouts,
|
guint n_consecutive_timeouts,
|
||||||
gpointer user_data)
|
MMBaseModem *self)
|
||||||
{
|
{
|
||||||
MMBaseModem *self = (MM_BASE_MODEM (user_data));
|
/* If reached the maximum number of timeouts, invalidate modem */
|
||||||
|
if (n_consecutive_timeouts >= self->priv->max_timeouts) {
|
||||||
if (self->priv->max_timeouts > 0 &&
|
mm_err ("(%s/%s) %s port timed out %u consecutive times, marking modem '%s' as invalid",
|
||||||
n_consecutive_timeouts >= self->priv->max_timeouts) {
|
mm_port_subsys_get_string (mm_port_get_subsys (MM_PORT (port))),
|
||||||
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))),
|
|
||||||
mm_port_get_device (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,
|
n_consecutive_timeouts,
|
||||||
g_dbus_object_get_object_path (G_DBUS_OBJECT (self)));
|
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);
|
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
|
gboolean
|
||||||
@@ -214,11 +219,12 @@ mm_base_modem_grab_port (MMBaseModem *self,
|
|||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* For serial ports, enable port timeout checks */
|
/* For serial ports, enable port timeout checks if requested to do so */
|
||||||
g_signal_connect (port,
|
if (self->priv->max_timeouts > 0)
|
||||||
"timed-out",
|
g_signal_connect (port,
|
||||||
G_CALLBACK (serial_port_timed_out_cb),
|
"timed-out",
|
||||||
self);
|
G_CALLBACK (serial_port_timed_out_cb),
|
||||||
|
self);
|
||||||
|
|
||||||
/* For serial ports, optionally use a specific baudrate */
|
/* For serial ports, optionally use a specific baudrate */
|
||||||
if (mm_kernel_device_has_property (kernel_device, "ID_MM_TTY_BAUDRATE"))
|
if (mm_kernel_device_has_property (kernel_device, "ID_MM_TTY_BAUDRATE"))
|
||||||
|
Reference in New Issue
Block a user