port-serial: allow deciding whether the command is queued last or run next
By default all the commands we were sending through the serial port were added at the tail of the pending queue, but we may want to queue them at the head in very specific cases (e.g. while sending an SMS).
This commit is contained in:
committed by
Dan Williams
parent
c78ba5ea0a
commit
8092e301fc
@@ -1262,7 +1262,8 @@ gps_enabled_ready (MMBaseModem *self,
|
||||
mm_port_serial_command (MM_PORT_SERIAL (gps_port),
|
||||
buf,
|
||||
3,
|
||||
FALSE,
|
||||
FALSE, /* never cached */
|
||||
FALSE, /* always queued last */
|
||||
NULL,
|
||||
NULL,
|
||||
NULL);
|
||||
|
||||
@@ -427,6 +427,7 @@ mm_port_serial_at_command (MMPortSerialAt *self,
|
||||
buf,
|
||||
timeout_seconds,
|
||||
allow_cached,
|
||||
FALSE, /* always queued last */
|
||||
cancellable,
|
||||
(GAsyncReadyCallback)serial_command_ready,
|
||||
simple);
|
||||
|
||||
@@ -193,6 +193,7 @@ mm_port_serial_qcdm_command (MMPortSerialQcdm *self,
|
||||
command,
|
||||
timeout_seconds,
|
||||
FALSE, /* never cached */
|
||||
FALSE, /* always queued last */
|
||||
cancellable,
|
||||
(GAsyncReadyCallback)serial_command_ready,
|
||||
task);
|
||||
|
||||
@@ -163,6 +163,7 @@ mm_port_serial_command (MMPortSerial *self,
|
||||
GByteArray *command,
|
||||
guint32 timeout_seconds,
|
||||
gboolean allow_cached,
|
||||
gboolean run_next,
|
||||
GCancellable *cancellable,
|
||||
GAsyncReadyCallback callback,
|
||||
gpointer user_data)
|
||||
@@ -203,7 +204,12 @@ mm_port_serial_command (MMPortSerial *self,
|
||||
if (!allow_cached)
|
||||
port_serial_set_cached_reply (self, ctx->command, NULL);
|
||||
|
||||
g_queue_push_tail (self->priv->queue, ctx);
|
||||
/* If requested to run next, push to the head of the queue so that it really is
|
||||
* the next one sent */
|
||||
if (run_next)
|
||||
g_queue_push_head (self->priv->queue, ctx);
|
||||
else
|
||||
g_queue_push_tail (self->priv->queue, ctx);
|
||||
|
||||
if (g_queue_get_length (self->priv->queue) == 1)
|
||||
port_serial_schedule_queue_process (self, 0);
|
||||
|
||||
@@ -144,6 +144,7 @@ void mm_port_serial_command (MMPortSerial *self,
|
||||
GByteArray *command,
|
||||
guint32 timeout_seconds,
|
||||
gboolean allow_cached,
|
||||
gboolean run_next,
|
||||
GCancellable *cancellable,
|
||||
GAsyncReadyCallback callback,
|
||||
gpointer user_data);
|
||||
|
||||
Reference in New Issue
Block a user