summaryrefslogtreecommitdiff
path: root/src/mm-port-serial-gps.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/mm-port-serial-gps.c')
-rw-r--r--src/mm-port-serial-gps.c22
1 files changed, 14 insertions, 8 deletions
diff --git a/src/mm-port-serial-gps.c b/src/mm-port-serial-gps.c
index 306df1fe..ea404994 100644
--- a/src/mm-port-serial-gps.c
+++ b/src/mm-port-serial-gps.c
@@ -19,7 +19,7 @@
#include <string.h>
#include "mm-port-serial-gps.h"
-#include "mm-log.h"
+#include "mm-log-object.h"
G_DEFINE_TYPE (MMPortSerialGps, mm_port_serial_gps, MM_TYPE_PORT_SERIAL)
@@ -68,9 +68,10 @@ remove_eval_cb (const GMatchInfo *match_info,
return FALSE;
}
-static gboolean
+static MMPortSerialResponseType
parse_response (MMPortSerial *port,
GByteArray *response,
+ GByteArray **parsed_response,
GError **error)
{
MMPortSerialGps *self = MM_PORT_SERIAL_GPS (port);
@@ -112,7 +113,7 @@ parse_response (MMPortSerial *port,
g_match_info_free (match_info);
if (!matches)
- return FALSE;
+ return MM_PORT_SERIAL_RESPONSE_NONE;
/* Remove matches */
result_len = response->len;
@@ -122,9 +123,11 @@ parse_response (MMPortSerial *port,
0, 0,
remove_eval_cb, &result_len, NULL);
+ /* Cleanup response buffer */
g_byte_array_remove_range (response, 0, response->len);
- g_byte_array_append (response, (const guint8 *) str, result_len);
- g_free (str);
+
+ /* Build parsed response */
+ *parsed_response = g_byte_array_new_take ((guint8 *)str, result_len);
return TRUE;
}
@@ -132,10 +135,13 @@ parse_response (MMPortSerial *port,
/*****************************************************************************/
static void
-debug_log (MMPortSerial *port, const char *prefix, const char *buf, gsize len)
+debug_log (MMPortSerial *self,
+ const gchar *prefix,
+ const gchar *buf,
+ gsize len)
{
static GString *debug = NULL;
- const char *s;
+ const gchar *s;
if (!debug)
debug = g_string_sized_new (256);
@@ -158,7 +164,7 @@ debug_log (MMPortSerial *port, const char *prefix, const char *buf, gsize len)
}
g_string_append_c (debug, '\'');
- mm_dbg ("(%s): %s", mm_port_get_device (MM_PORT (port)), debug->str);
+ mm_obj_dbg (self, "%s", debug->str);
g_string_truncate (debug, 0);
}