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
This commit is contained in:

committed by
Jiří Klimeš

parent
44194ac04d
commit
d5d9eec2b5
@@ -4226,7 +4226,7 @@ get_csq_done (MMAtSerialPort *port,
|
|||||||
gpointer user_data)
|
gpointer user_data)
|
||||||
{
|
{
|
||||||
MMCallbackInfo *info = (MMCallbackInfo *) user_data;
|
MMCallbackInfo *info = (MMCallbackInfo *) user_data;
|
||||||
char *reply = response->str;
|
char *reply;
|
||||||
gboolean parsed = FALSE;
|
gboolean parsed = FALSE;
|
||||||
|
|
||||||
/* If the modem has already been removed, return without
|
/* If the modem has already been removed, return without
|
||||||
@@ -4239,6 +4239,7 @@ get_csq_done (MMAtSerialPort *port,
|
|||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
reply = response->str;
|
||||||
if (!strncmp (reply, "+CSQ: ", 6)) {
|
if (!strncmp (reply, "+CSQ: ", 6)) {
|
||||||
/* Got valid reply */
|
/* Got valid reply */
|
||||||
int quality;
|
int quality;
|
||||||
@@ -5756,6 +5757,9 @@ simple_status_got_signal_quality (MMModem *modem,
|
|||||||
if (!error) {
|
if (!error) {
|
||||||
properties = (GHashTable *) mm_callback_info_get_data (info, SS_HASH_TAG);
|
properties = (GHashTable *) mm_callback_info_get_data (info, SS_HASH_TAG);
|
||||||
g_hash_table_insert (properties, "signal_quality", simple_uint_value (result));
|
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);
|
mm_callback_info_chain_complete_one (info);
|
||||||
}
|
}
|
||||||
@@ -5772,6 +5776,9 @@ simple_status_got_band (MMModem *modem,
|
|||||||
if (!error) {
|
if (!error) {
|
||||||
properties = (GHashTable *) mm_callback_info_get_data (info, SS_HASH_TAG);
|
properties = (GHashTable *) mm_callback_info_get_data (info, SS_HASH_TAG);
|
||||||
g_hash_table_insert (properties, "band", simple_uint_value (result));
|
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);
|
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))
|
if (!modem || mm_callback_info_check_modem_removed (info))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (error)
|
if (error) {
|
||||||
|
g_clear_error (&info->error);
|
||||||
info->error = g_error_copy (error);
|
info->error = g_error_copy (error);
|
||||||
else {
|
} else {
|
||||||
properties = (GHashTable *) mm_callback_info_get_data (info, SS_HASH_TAG);
|
properties = (GHashTable *) mm_callback_info_get_data (info, SS_HASH_TAG);
|
||||||
|
|
||||||
g_hash_table_insert (properties, "registration_status", simple_uint_value (status));
|
g_hash_table_insert (properties, "registration_status", simple_uint_value (status));
|
||||||
|
@@ -1021,9 +1021,17 @@ internal_queue_command (MMSerialPort *self,
|
|||||||
MMQueueData *info;
|
MMQueueData *info;
|
||||||
|
|
||||||
g_return_if_fail (MM_IS_SERIAL_PORT (self));
|
g_return_if_fail (MM_IS_SERIAL_PORT (self));
|
||||||
g_return_if_fail (priv->open_count > 0);
|
|
||||||
g_return_if_fail (command != NULL);
|
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);
|
info = g_slice_new0 (MMQueueData);
|
||||||
if (take_command)
|
if (take_command)
|
||||||
info->command = command;
|
info->command = command;
|
||||||
|
Reference in New Issue
Block a user