diff options
author | Dan Williams <dcbw@redhat.com> | 2010-04-05 12:01:54 -0700 |
---|---|---|
committer | Dan Williams <dcbw@redhat.com> | 2010-04-05 12:01:54 -0700 |
commit | 0108a36d27b84dee2bf1934f6d5403b7d683099a (patch) | |
tree | 123b5dff10cd300ad7cfb906a9bf3d55bda07c2d /src/mm-serial-port.c | |
parent | bac945a8e4c1176d75f6c7d6622a516f673aaf65 (diff) |
serial: let port subclasses handle their own debug logging
We want to print out QCDM messages as hex, not ASCII. So let
each port type print out it's own communication as it wants to.
Diffstat (limited to 'src/mm-serial-port.c')
-rw-r--r-- | src/mm-serial-port.c | 36 |
1 files changed, 4 insertions, 32 deletions
diff --git a/src/mm-serial-port.c b/src/mm-serial-port.c index 609e20de..b5323670 100644 --- a/src/mm-serial-port.c +++ b/src/mm-serial-port.c @@ -343,40 +343,12 @@ real_config_fd (MMSerialPort *self, int fd, GError **error) } static void -serial_debug (MMSerialPort *self, const char *prefix, const char *buf, int len) +serial_debug (MMSerialPort *self, const char *prefix, const char *buf, gsize len) { - static GString *debug = NULL; - const char *s; + g_return_if_fail (len > 0); - if (!mm_options_debug ()) - return; - - if (len < 0) - len = strlen (buf); - - if (!debug) - debug = g_string_sized_new (256); - - g_string_append (debug, prefix); - g_string_append (debug, " '"); - - s = buf; - while (len--) { - if (g_ascii_isprint (*s)) - g_string_append_c (debug, *s); - else if (*s == '\r') - g_string_append (debug, "<CR>"); - else if (*s == '\n') - g_string_append (debug, "<LF>"); - else - g_string_append_printf (debug, "\\%d", *s); - - s++; - } - - g_string_append_c (debug, '\''); - g_debug ("(%s): %s", mm_port_get_device (MM_PORT (self)), debug->str); - g_string_truncate (debug, 0); + if (mm_options_debug () && MM_SERIAL_PORT_GET_CLASS (self)->debug_log) + MM_SERIAL_PORT_GET_CLASS (self)->debug_log (self, prefix, buf, len); } static gboolean |