aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/mm-serial-port.c18
1 files changed, 14 insertions, 4 deletions
diff --git a/src/mm-serial-port.c b/src/mm-serial-port.c
index 0f81c7bf..8774d40c 100644
--- a/src/mm-serial-port.c
+++ b/src/mm-serial-port.c
@@ -868,6 +868,7 @@ mm_serial_port_open (MMSerialPort *self, GError **error)
const char *device;
struct serial_struct sinfo = { 0 };
GTimeVal tv_start, tv_end;
+ int errno_save;
g_return_val_if_fail (MM_IS_SERIAL_PORT (self), FALSE);
@@ -897,6 +898,7 @@ mm_serial_port_open (MMSerialPort *self, GError **error)
devfile = g_strdup_printf ("/dev/%s", device);
errno = 0;
priv->fd = open (devfile, O_RDWR | O_EXCL | O_NONBLOCK | O_NOCTTY);
+ errno_save = errno;
g_free (devfile);
}
@@ -908,13 +910,16 @@ mm_serial_port_open (MMSerialPort *self, GError **error)
g_set_error (error,
MM_SERIAL_ERROR,
(errno == ENODEV) ? MM_SERIAL_ERROR_OPEN_FAILED_NO_DEVICE : MM_SERIAL_ERROR_OPEN_FAILED,
- "Could not open serial device %s: %s", device, strerror (errno));
+ "Could not open serial device %s: %s", device, strerror (errno_save));
+ mm_warn ("(%s) could not open serial device (%d)", device, errno_save);
return FALSE;
}
if (ioctl (priv->fd, TIOCEXCL) < 0) {
+ errno_save = errno;
g_set_error (error, MM_SERIAL_ERROR, MM_SERIAL_ERROR_OPEN_FAILED,
- "Could not lock serial device %s: %s", device, strerror (errno));
+ "Could not lock serial device %s: %s", device, strerror (errno_save));
+ mm_warn ("(%s) could not lock serial device (%d)", device, errno_save);
goto error;
}
@@ -922,14 +927,18 @@ mm_serial_port_open (MMSerialPort *self, GError **error)
tcflush (priv->fd, TCIOFLUSH);
if (tcgetattr (priv->fd, &priv->old_t) < 0) {
+ errno_save = errno;
g_set_error (error, MM_SERIAL_ERROR, MM_SERIAL_ERROR_OPEN_FAILED,
- "Could not open serial device %s: %s", device, strerror (errno));
+ "Could not set attributes on serial device %s: %s", device, strerror (errno_save));
+ mm_warn ("(%s) could not set attributes on serial device (%d)", device, errno_save);
goto 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))
+ if (!MM_SERIAL_PORT_GET_CLASS (self)->config_fd (self, priv->fd, error)) {
+ mm_dbg ("(%s) failed to configure serial device", device);
goto error;
+ }
/* Don't wait for pending data when closing the port; this can cause some
* stupid devices that don't respond to URBs on a particular port to hang
@@ -966,6 +975,7 @@ success:
return TRUE;
error:
+ mm_warn ("(%s) failed to open serial device", device);
close (priv->fd);
priv->fd = -1;
return FALSE;