diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/mm-serial-port.c | 11 | ||||
-rw-r--r-- | src/mm-serial-port.h | 5 |
2 files changed, 12 insertions, 4 deletions
diff --git a/src/mm-serial-port.c b/src/mm-serial-port.c index 284854be..a31e4299 100644 --- a/src/mm-serial-port.c +++ b/src/mm-serial-port.c @@ -291,7 +291,7 @@ parse_stopbits (guint i) } static gboolean -config_fd (MMSerialPort *self, GError **error) +real_config_fd (MMSerialPort *self, int fd, GError **error) { MMSerialPortPrivate *priv = MM_SERIAL_PORT_GET_PRIVATE (self); struct termio stbuf; @@ -306,7 +306,7 @@ config_fd (MMSerialPort *self, GError **error) stopbits = parse_stopbits (priv->stopbits); memset (&stbuf, 0, sizeof (struct termio)); - if (ioctl (priv->fd, TCGETA, &stbuf) != 0) { + if (ioctl (fd, TCGETA, &stbuf) != 0) { g_warning ("%s (%s): TCGETA error: %d", __func__, mm_port_get_device (MM_PORT (self)), @@ -324,7 +324,7 @@ config_fd (MMSerialPort *self, GError **error) stbuf.c_cflag &= ~(CBAUD | CSIZE | CSTOPB | CLOCAL | PARENB); stbuf.c_cflag |= (speed | bits | CREAD | 0 | parity | stopbits); - if (ioctl (priv->fd, TCSETA, &stbuf) < 0) { + if (ioctl (fd, TCSETA, &stbuf) < 0) { g_set_error (error, MM_MODEM_ERROR, MM_MODEM_ERROR_GENERAL, @@ -731,7 +731,8 @@ mm_serial_port_open (MMSerialPort *self, GError **error) return FALSE; } - if (!config_fd (self, error)) { + g_warn_if_fail (MM_SERIAL_PORT_GET_CLASS (self)->config_fd); + if (!MM_SERIAL_PORT_GET_CLASS (self)->config_fd (self, priv->fd, error)) { close (priv->fd); priv->fd = -1; return FALSE; @@ -1188,6 +1189,8 @@ mm_serial_port_class_init (MMSerialPortClass *klass) object_class->dispose = dispose; object_class->finalize = finalize; + klass->config_fd = real_config_fd; + /* Properties */ g_object_class_install_property (object_class, PROP_BAUD, diff --git a/src/mm-serial-port.h b/src/mm-serial-port.h index c1d8b127..c07d70c8 100644 --- a/src/mm-serial-port.h +++ b/src/mm-serial-port.h @@ -75,6 +75,11 @@ struct _MMSerialPortClass { GError *error, GCallback callback, gpointer callback_data); + + /* Called to configure the serial port after it's opened. On error, should + * return FALSE and set 'error' as appropriate. + */ + gboolean (*config_fd) (MMSerialPort *self, int fd, GError **error); }; GType mm_serial_port_get_type (void); |