aboutsummaryrefslogtreecommitdiff
path: root/src/mm-serial-port.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/mm-serial-port.c')
-rw-r--r--src/mm-serial-port.c29
1 files changed, 28 insertions, 1 deletions
diff --git a/src/mm-serial-port.c b/src/mm-serial-port.c
index f05a1aea..8b683dd3 100644
--- a/src/mm-serial-port.c
+++ b/src/mm-serial-port.c
@@ -44,6 +44,7 @@ enum {
PROP_STOPBITS,
PROP_SEND_DELAY,
PROP_FD,
+ PROP_SPEW_CONTROL,
LAST_PROP
};
@@ -67,6 +68,7 @@ typedef struct {
char parity;
guint stopbits;
guint64 send_delay;
+ gboolean spew_control;
guint queue_id;
guint watch_id;
@@ -569,6 +571,17 @@ mm_serial_port_queue_process (gpointer data)
const GByteArray *cached = mm_serial_port_get_cached_reply (self, info->command);
if (cached) {
+ /* Ensure the response array is fully empty before setting the
+ * cached response. */
+ if (priv->response->len > 0) {
+ g_warning ("%s: (%s) response array is not empty when using "
+ "cached reply, cleaning up %u bytes",
+ __func__,
+ mm_port_get_device (MM_PORT (self)),
+ priv->response->len);
+ g_byte_array_set_size (priv->response, 0);
+ }
+
g_byte_array_append (priv->response, cached->data, cached->len);
mm_serial_port_got_response (self, NULL);
return FALSE;
@@ -657,7 +670,7 @@ data_available (GIOChannel *source,
}
/* Make sure the response doesn't grow too long */
- if (priv->response->len > SERIAL_BUF_SIZE) {
+ if ((priv->response->len > SERIAL_BUF_SIZE) && priv->spew_control) {
/* Notify listeners and then trim the buffer */
g_signal_emit_by_name (self, "buffer-full", priv->response);
g_byte_array_remove_range (priv->response, 0, (SERIAL_BUF_SIZE / 2));
@@ -1250,6 +1263,9 @@ set_property (GObject *object, guint prop_id,
case PROP_SEND_DELAY:
priv->send_delay = g_value_get_uint64 (value);
break;
+ case PROP_SPEW_CONTROL:
+ priv->spew_control = g_value_get_boolean (value);
+ break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
@@ -1281,6 +1297,9 @@ get_property (GObject *object, guint prop_id,
case PROP_SEND_DELAY:
g_value_set_uint64 (value, priv->send_delay);
break;
+ case PROP_SPEW_CONTROL:
+ g_value_set_boolean (value, priv->spew_control);
+ break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
@@ -1383,6 +1402,14 @@ mm_serial_port_class_init (MMSerialPortClass *klass)
0, G_MAXUINT64, 0,
G_PARAM_READWRITE));
+ g_object_class_install_property
+ (object_class, PROP_SPEW_CONTROL,
+ g_param_spec_boolean (MM_SERIAL_PORT_SPEW_CONTROL,
+ "SpewControl",
+ "Spew control",
+ FALSE,
+ G_PARAM_READWRITE));
+
/* Signals */
g_signal_new ("buffer-full",
G_OBJECT_CLASS_TYPE (object_class),