diff options
author | Nathan Williams <njw@chromium.org> | 2011-11-23 16:16:20 -0500 |
---|---|---|
committer | Jiří Klimeš <jklimes@redhat.com> | 2011-11-30 09:38:42 +0100 |
commit | d5d9eec2b52363a7460aeec0c020b1c6a7af6b03 (patch) | |
tree | fef2e75e78250e8a17b7ec1cb3c9989424a0d43f /src | |
parent | 44194ac04d7926cb80de03fe95ce98bd64a1c6c6 (diff) |
serial: report port-not-open in queueing commands via callback
Reporting errors instead of just returning permits routines like
mm-generic-gsm.c:simple_get_status() to work again, as their callbacks
get the error they are expecting. To make this work, adapt get_csq_done()
to handle a NULL response when error is set, and make sure that multiple
errors don't step on each other in the mm_callback_info_chain() sequence
created by simple_get_status().
Change-Id: Ie3a72b1ce71b7f117e8b1f3da7a406c4d2da9e02
Diffstat (limited to 'src')
-rw-r--r-- | src/mm-generic-gsm.c | 14 | ||||
-rw-r--r-- | src/mm-serial-port.c | 10 |
2 files changed, 20 insertions, 4 deletions
diff --git a/src/mm-generic-gsm.c b/src/mm-generic-gsm.c index 2604b09f..b6d56616 100644 --- a/src/mm-generic-gsm.c +++ b/src/mm-generic-gsm.c @@ -4226,7 +4226,7 @@ get_csq_done (MMAtSerialPort *port, gpointer user_data) { MMCallbackInfo *info = (MMCallbackInfo *) user_data; - char *reply = response->str; + char *reply; gboolean parsed = FALSE; /* If the modem has already been removed, return without @@ -4239,6 +4239,7 @@ get_csq_done (MMAtSerialPort *port, goto done; } + reply = response->str; if (!strncmp (reply, "+CSQ: ", 6)) { /* Got valid reply */ int quality; @@ -5756,6 +5757,9 @@ simple_status_got_signal_quality (MMModem *modem, if (!error) { properties = (GHashTable *) mm_callback_info_get_data (info, SS_HASH_TAG); g_hash_table_insert (properties, "signal_quality", simple_uint_value (result)); + } else { + g_clear_error (&info->error); + info->error = g_error_copy (error); } mm_callback_info_chain_complete_one (info); } @@ -5772,6 +5776,9 @@ simple_status_got_band (MMModem *modem, if (!error) { properties = (GHashTable *) mm_callback_info_get_data (info, SS_HASH_TAG); g_hash_table_insert (properties, "band", simple_uint_value (result)); + } else { + g_clear_error (&info->error); + info->error = g_error_copy (error); } mm_callback_info_chain_complete_one (info); } @@ -5791,9 +5798,10 @@ simple_status_got_reg_info (MMModemGsmNetwork *modem, if (!modem || mm_callback_info_check_modem_removed (info)) return; - if (error) + if (error) { + g_clear_error (&info->error); info->error = g_error_copy (error); - else { + } else { properties = (GHashTable *) mm_callback_info_get_data (info, SS_HASH_TAG); g_hash_table_insert (properties, "registration_status", simple_uint_value (status)); diff --git a/src/mm-serial-port.c b/src/mm-serial-port.c index 29f99ef3..ab64dc80 100644 --- a/src/mm-serial-port.c +++ b/src/mm-serial-port.c @@ -1021,9 +1021,17 @@ internal_queue_command (MMSerialPort *self, MMQueueData *info; g_return_if_fail (MM_IS_SERIAL_PORT (self)); - g_return_if_fail (priv->open_count > 0); g_return_if_fail (command != NULL); + if (priv->open_count == 0) { + GError *error = g_error_new_literal (MM_SERIAL_ERROR, + MM_SERIAL_ERROR_SEND_FAILED, + "Sending command failed: device is not enabled"); + callback (self, NULL, error, user_data); + g_error_free (error); + return; + } + info = g_slice_new0 (MMQueueData); if (take_command) info->command = command; |