port: make 'timed-out' a signal for all port types, not just serial
This commit is contained in:
@@ -207,7 +207,7 @@ base_modem_create_tty_port (MMBaseModem *self,
|
|||||||
/* Enable port timeout checks if requested to do so */
|
/* Enable port timeout checks if requested to do so */
|
||||||
if (self->priv->max_timeouts > 0)
|
if (self->priv->max_timeouts > 0)
|
||||||
g_signal_connect (port,
|
g_signal_connect (port,
|
||||||
"timed-out",
|
MM_PORT_SIGNAL_TIMED_OUT,
|
||||||
G_CALLBACK (serial_port_timed_out_cb),
|
G_CALLBACK (serial_port_timed_out_cb),
|
||||||
self);
|
self);
|
||||||
|
|
||||||
|
@@ -65,9 +65,7 @@ enum {
|
|||||||
|
|
||||||
enum {
|
enum {
|
||||||
BUFFER_FULL,
|
BUFFER_FULL,
|
||||||
TIMED_OUT,
|
|
||||||
FORCED_CLOSE,
|
FORCED_CLOSE,
|
||||||
|
|
||||||
LAST_SIGNAL
|
LAST_SIGNAL
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -604,7 +602,7 @@ port_serial_process_command (MMPortSerial *self,
|
|||||||
if (ctx->eagain_count <= 0) {
|
if (ctx->eagain_count <= 0) {
|
||||||
/* If we reach the limit of EAGAIN errors, treat as a timeout error. */
|
/* If we reach the limit of EAGAIN errors, treat as a timeout error. */
|
||||||
self->priv->n_consecutive_timeouts++;
|
self->priv->n_consecutive_timeouts++;
|
||||||
g_signal_emit (self, signals[TIMED_OUT], 0, self->priv->n_consecutive_timeouts);
|
g_signal_emit_by_name (self, MM_PORT_SIGNAL_TIMED_OUT, self->priv->n_consecutive_timeouts);
|
||||||
|
|
||||||
g_set_error (error, MM_SERIAL_ERROR, MM_SERIAL_ERROR_SEND_FAILED,
|
g_set_error (error, MM_SERIAL_ERROR, MM_SERIAL_ERROR_SEND_FAILED,
|
||||||
"Sending command failed: '%s'", g_strerror (errno));
|
"Sending command failed: '%s'", g_strerror (errno));
|
||||||
@@ -640,7 +638,7 @@ port_serial_process_command (MMPortSerial *self,
|
|||||||
if (ctx->eagain_count <= 0) {
|
if (ctx->eagain_count <= 0) {
|
||||||
/* If we reach the limit of EAGAIN errors, treat as a timeout error. */
|
/* If we reach the limit of EAGAIN errors, treat as a timeout error. */
|
||||||
self->priv->n_consecutive_timeouts++;
|
self->priv->n_consecutive_timeouts++;
|
||||||
g_signal_emit (self, signals[TIMED_OUT], 0, self->priv->n_consecutive_timeouts);
|
g_signal_emit_by_name (self, MM_PORT_SIGNAL_TIMED_OUT, self->priv->n_consecutive_timeouts);
|
||||||
g_set_error (error, MM_SERIAL_ERROR, MM_SERIAL_ERROR_SEND_FAILED,
|
g_set_error (error, MM_SERIAL_ERROR, MM_SERIAL_ERROR_SEND_FAILED,
|
||||||
"Sending command failed: '%s'", g_strerror (errno));
|
"Sending command failed: '%s'", g_strerror (errno));
|
||||||
return FALSE;
|
return FALSE;
|
||||||
@@ -786,7 +784,7 @@ port_serial_timed_out (gpointer data)
|
|||||||
|
|
||||||
/* Emit a timed out signal, used by upper layers to identify a disconnected
|
/* Emit a timed out signal, used by upper layers to identify a disconnected
|
||||||
* serial port */
|
* serial port */
|
||||||
g_signal_emit (self, signals[TIMED_OUT], 0, self->priv->n_consecutive_timeouts);
|
g_signal_emit_by_name (self, MM_PORT_SIGNAL_TIMED_OUT, self->priv->n_consecutive_timeouts);
|
||||||
}
|
}
|
||||||
g_object_unref (self);
|
g_object_unref (self);
|
||||||
|
|
||||||
@@ -2177,15 +2175,6 @@ mm_port_serial_class_init (MMPortSerialClass *klass)
|
|||||||
g_cclosure_marshal_generic,
|
g_cclosure_marshal_generic,
|
||||||
G_TYPE_NONE, 1, G_TYPE_POINTER);
|
G_TYPE_NONE, 1, G_TYPE_POINTER);
|
||||||
|
|
||||||
signals[TIMED_OUT] =
|
|
||||||
g_signal_new ("timed-out",
|
|
||||||
G_OBJECT_CLASS_TYPE (object_class),
|
|
||||||
G_SIGNAL_RUN_FIRST,
|
|
||||||
G_STRUCT_OFFSET (MMPortSerialClass, timed_out),
|
|
||||||
NULL, NULL,
|
|
||||||
g_cclosure_marshal_generic,
|
|
||||||
G_TYPE_NONE, 1, G_TYPE_UINT);
|
|
||||||
|
|
||||||
signals[FORCED_CLOSE] =
|
signals[FORCED_CLOSE] =
|
||||||
g_signal_new ("forced-close",
|
g_signal_new ("forced-close",
|
||||||
G_OBJECT_CLASS_TYPE (object_class),
|
G_OBJECT_CLASS_TYPE (object_class),
|
||||||
|
@@ -102,7 +102,6 @@ struct _MMPortSerialClass {
|
|||||||
|
|
||||||
/* Signals */
|
/* Signals */
|
||||||
void (*buffer_full) (MMPortSerial *port, const GByteArray *buffer);
|
void (*buffer_full) (MMPortSerial *port, const GByteArray *buffer);
|
||||||
void (*timed_out) (MMPortSerial *port, guint n_consecutive_replies);
|
|
||||||
void (*forced_close) (MMPortSerial *port);
|
void (*forced_close) (MMPortSerial *port);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@@ -37,6 +37,14 @@ enum {
|
|||||||
LAST_PROP
|
LAST_PROP
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
enum {
|
||||||
|
TIMED_OUT,
|
||||||
|
LAST_SIGNAL
|
||||||
|
};
|
||||||
|
|
||||||
|
static guint signals[LAST_SIGNAL] = { 0 };
|
||||||
|
|
||||||
struct _MMPortPrivate {
|
struct _MMPortPrivate {
|
||||||
gchar *device;
|
gchar *device;
|
||||||
MMPortSubsys subsys;
|
MMPortSubsys subsys;
|
||||||
@@ -270,4 +278,13 @@ mm_port_class_init (MMPortClass *klass)
|
|||||||
"kernel device object",
|
"kernel device object",
|
||||||
MM_TYPE_KERNEL_DEVICE,
|
MM_TYPE_KERNEL_DEVICE,
|
||||||
G_PARAM_READWRITE));
|
G_PARAM_READWRITE));
|
||||||
|
|
||||||
|
signals[TIMED_OUT] =
|
||||||
|
g_signal_new (MM_PORT_SIGNAL_TIMED_OUT,
|
||||||
|
G_OBJECT_CLASS_TYPE (object_class),
|
||||||
|
G_SIGNAL_RUN_FIRST,
|
||||||
|
G_STRUCT_OFFSET (MMPortClass, timed_out),
|
||||||
|
NULL, NULL,
|
||||||
|
g_cclosure_marshal_generic,
|
||||||
|
G_TYPE_NONE, 1, G_TYPE_UINT);
|
||||||
}
|
}
|
||||||
|
@@ -60,6 +60,8 @@ typedef enum { /*< underscore_name=mm_port_type >*/
|
|||||||
#define MM_PORT_CONNECTED "connected"
|
#define MM_PORT_CONNECTED "connected"
|
||||||
#define MM_PORT_KERNEL_DEVICE "kernel-device"
|
#define MM_PORT_KERNEL_DEVICE "kernel-device"
|
||||||
|
|
||||||
|
#define MM_PORT_SIGNAL_TIMED_OUT "timed-out"
|
||||||
|
|
||||||
typedef struct _MMPort MMPort;
|
typedef struct _MMPort MMPort;
|
||||||
typedef struct _MMPortClass MMPortClass;
|
typedef struct _MMPortClass MMPortClass;
|
||||||
typedef struct _MMPortPrivate MMPortPrivate;
|
typedef struct _MMPortPrivate MMPortPrivate;
|
||||||
@@ -71,6 +73,9 @@ struct _MMPort {
|
|||||||
|
|
||||||
struct _MMPortClass {
|
struct _MMPortClass {
|
||||||
GObjectClass parent;
|
GObjectClass parent;
|
||||||
|
|
||||||
|
/* signals */
|
||||||
|
void (* timed_out) (MMPort *port, guint n_consecutive_replies);
|
||||||
};
|
};
|
||||||
|
|
||||||
GType mm_port_get_type (void);
|
GType mm_port_get_type (void);
|
||||||
|
Reference in New Issue
Block a user