From fd4e78fe920492099a45dbf42ba9d4f1e9b0899b Mon Sep 17 00:00:00 2001 From: Tambet Ingo Date: Wed, 22 Oct 2008 16:34:34 +0300 Subject: Add a default send delay to the serial class. Show the correct error in case of write errors (EAGAIN). --- src/mm-serial.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/mm-serial.c b/src/mm-serial.c index 63770090..04bea7dc 100644 --- a/src/mm-serial.c +++ b/src/mm-serial.c @@ -302,12 +302,17 @@ mm_serial_send_command (MMSerial *self, serial_debug ("-->", priv->command->str, -1); s = priv->command->str; - while (*s && eagain_count > 0) { + while (*s) { status = write (priv->fd, s, 1); if (status < 0) { - if (errno == EAGAIN) + if (errno == EAGAIN) { eagain_count--; - else { + if (eagain_count <= 0) { + g_set_error (error, MM_SERIAL_ERROR, MM_SERIAL_SEND_FAILED, + "Sending command failed: '%s'", strerror (errno)); + break; + } + } else { g_set_error (error, MM_SERIAL_ERROR, MM_SERIAL_SEND_FAILED, "Sending command failed: '%s'", strerror (errno)); break; @@ -702,7 +707,7 @@ mm_serial_init (MMSerial *self) priv->bits = 8; priv->parity = 'n'; priv->stopbits = 1; - priv->send_delay = 0; + priv->send_delay = 1000; priv->queue = g_queue_new (); priv->command = g_string_new_len ("AT", SERIAL_BUF_SIZE); -- cgit v1.2.3-70-g09d2