aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/mm-port-probe-at.c11
-rw-r--r--src/mm-port-probe.c25
2 files changed, 31 insertions, 5 deletions
diff --git a/src/mm-port-probe-at.c b/src/mm-port-probe-at.c
index d7e6fefe..10cce9e5 100644
--- a/src/mm-port-probe-at.c
+++ b/src/mm-port-probe-at.c
@@ -50,11 +50,15 @@ mm_port_probe_response_processor_is_at (const gchar *command,
return FALSE;
}
- /* If error is NOT known by the parser, request to abort */
- if (!mm_serial_parser_v1_is_known_error (error)) {
+ /* If error is NOT known by the parser, or if the error is actually
+ * the generic parsing filter error, request to abort */
+ if (!mm_serial_parser_v1_is_known_error (error) ||
+ g_error_matches (error,
+ MM_SERIAL_ERROR,
+ MM_SERIAL_ERROR_PARSE_FAILED)) {
*result_error = g_error_copy (error);
g_prefix_error (result_error,
- "Fatal error parsing AT reply. ");
+ "Fatal error parsing AT reply: ");
return FALSE;
}
@@ -91,4 +95,3 @@ mm_port_probe_response_processor_string (const gchar *command,
return TRUE;
}
-
diff --git a/src/mm-port-probe.c b/src/mm-port-probe.c
index 6c36e6ba..33f0be86 100644
--- a/src/mm-port-probe.c
+++ b/src/mm-port-probe.c
@@ -955,6 +955,23 @@ serial_buffer_full (MMSerialPort *serial,
}
static gboolean
+serial_parser_filter_cb (gpointer filter,
+ gpointer user_data,
+ GString *response,
+ GError **error)
+{
+ if (is_non_at_response ((const guint8 *) response->str, response->len)) {
+ g_set_error (error,
+ MM_SERIAL_ERROR,
+ MM_SERIAL_ERROR_PARSE_FAILED,
+ "Not an AT response");
+ return FALSE;
+ }
+
+ return TRUE;
+}
+
+static gboolean
serial_open_at (MMPortProbe *self)
{
PortProbeRunTask *task = self->priv->task;
@@ -968,6 +985,8 @@ serial_open_at (MMPortProbe *self)
/* Create AT serial port if not done before */
if (!task->serial) {
+ gpointer parser;
+
task->serial = MM_SERIAL_PORT (mm_at_serial_port_new (g_udev_device_get_name (self->priv->port)));
if (!task->serial) {
port_probe_run_task_complete (
@@ -989,9 +1008,13 @@ serial_open_at (MMPortProbe *self)
MM_SERIAL_PORT_SPEW_CONTROL, TRUE,
NULL);
+ parser = mm_serial_parser_v1_new ();
+ mm_serial_parser_v1_add_filter (parser,
+ serial_parser_filter_cb,
+ NULL);
mm_at_serial_port_set_response_parser (MM_AT_SERIAL_PORT (task->serial),
mm_serial_parser_v1_parse,
- mm_serial_parser_v1_new (),
+ parser,
mm_serial_parser_v1_destroy);
}