mm-port-serial: add new MM_SERIAL_ERROR_SEND_TIMEOUT
This new error code 'MM_SERIAL_ERROR_SEND_TIMEOUT' is used to make it easier to distinguish why the transmission failed. Until now, 'MM_SERIAL_ERROR_SEND_FAILED' was always returned. This new error code is now returned for an 'EAGAIN', as this is more likely to be a TIMEOUT. This makes debugging easier, as a better error analysis is now possible. Signed-off-by: Florian Eckert <fe@dev.tdt.de>
This commit is contained in:
committed by
Dan Williams
parent
37f17d4b58
commit
44b9f74301
@@ -329,6 +329,7 @@ static const gchar *serial_error_messages[] = {
|
||||
[MM_SERIAL_ERROR_NOT_OPEN] = "Not open",
|
||||
[MM_SERIAL_ERROR_PARSE_FAILED] = "Parse failed",
|
||||
[MM_SERIAL_ERROR_FRAME_NOT_FOUND] = "Frame not found",
|
||||
[MM_SERIAL_ERROR_SEND_TIMEOUT] = "Send timeout",
|
||||
};
|
||||
|
||||
static const gchar *
|
||||
|
||||
@@ -596,7 +596,7 @@ port_serial_process_command (MMPortSerial *self,
|
||||
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_TIMEOUT,
|
||||
"Sending command failed: '%s'", g_strerror (errno));
|
||||
return FALSE;
|
||||
}
|
||||
@@ -631,7 +631,7 @@ port_serial_process_command (MMPortSerial *self,
|
||||
/* If we reach the limit of EAGAIN errors, treat as a timeout error. */
|
||||
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_TIMEOUT,
|
||||
"Sending command failed: '%s'", g_strerror (errno));
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user