[Pkg-running-devel] [openambit] 39/131: Added proper debug printing

Christian Perrier bubulle at moszumanska.debian.org
Thu Jul 17 20:19:09 UTC 2014


This is an automated email from the git hooks/post-receive script.

bubulle pushed a commit to branch master
in repository openambit.

commit c491a281d5b1f99f507af4ffd2cb95120a483ba5
Author: Emil Ljungdahl <emil at kratern.se>
Date:   Sat Jan 11 16:54:59 2014 +0100

    Added proper debug printing
---
 src/libambit/CMakeLists.txt | 12 +++++++-
 src/libambit/debug.c        | 71 +++++++++++++++++++++++++++++++++++++++++++++
 src/libambit/libambit.c     | 66 +++++++++++++++++++++++++++++++++++++----
 src/libambit/libambit.h     |  2 +-
 src/libambit/libambit_int.h | 25 ++++++++++++++--
 src/libambit/personal.c     |  2 +-
 src/libambit/pmem20.c       | 35 ++++++++++++++++++++--
 src/libambit/protocol.c     |  2 +-
 8 files changed, 201 insertions(+), 14 deletions(-)

diff --git a/src/libambit/CMakeLists.txt b/src/libambit/CMakeLists.txt
index 4e440ee..bc2d1a7 100644
--- a/src/libambit/CMakeLists.txt
+++ b/src/libambit/CMakeLists.txt
@@ -6,6 +6,15 @@ set (CMAKE_MODULE_PATH "${LIBAMBIT_SOURCE_DIR}/cmake")
 
 set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall")
 
+# Debug defines
+set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -DDEBUG_PRINT_ERROR -DDEBUG_PRINT_WARNING")
+IF (DEFINED DEBUG_PRINT_INFO)
+  set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -DDEBUG_PRINT_INFO=${DEBUG_PRINT_INFO}")
+ENDIF()
+IF (DEFINED DEBUG_PRINT_FILE_LINE)
+  set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -DDEBUG_PRINT_FILE_LINE=${DEBUG_PRINT_FILE_LINE}")
+ENDIF()
+
 find_package(libusb REQUIRED)
 find_package(UDev REQUIRED)
 
@@ -13,8 +22,9 @@ add_library (
   ambit
   SHARED
   crc16.c
-  libambit.c
+  debug.c
   hid.c
+  libambit.c
   personal.c
   pmem20.c
   protocol.c
diff --git a/src/libambit/debug.c b/src/libambit/debug.c
new file mode 100644
index 0000000..bd30f68
--- /dev/null
+++ b/src/libambit/debug.c
@@ -0,0 +1,71 @@
+/*
+ * (C) Copyright 2014 Emil Ljungdahl
+ *
+ * This file is part of libambit.
+ *
+ * libambit is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ * Contributors:
+ *
+ */
+#include "libambit.h"
+#include "libambit_int.h"
+
+#include <stdarg.h>
+#include <stdio.h>
+
+/*
+ * Local variables
+ */
+static char debug_err_text[] = "ERROR";
+static char debug_warn_text[] = "WARNING";
+static char debug_info_text[] = "INFO";
+
+void debug_printf(debug_level_t level, const char *file, int line, const char *func, const char *fmt, ...)
+{
+    FILE *output;
+    const char *leveltxt;
+    va_list ap;
+
+    if (level == debug_level_err) {
+        output = stderr;
+        leveltxt = debug_err_text;
+    }
+    else if (level == debug_level_warn) {
+        output = stderr;
+        leveltxt = debug_warn_text;
+    }
+    else {
+        output = stdout;
+        leveltxt = debug_info_text;
+    }
+
+    fprintf(output, "libambit %s: ", leveltxt);
+#ifdef DEBUG_PRINT_FILE_LINE
+    fprintf(output, "%s:%d ", file, line);
+#else
+    // Remove compiler warning
+    file = NULL;
+    line = 0;
+#endif
+    fprintf(output, "%s(): ", func);
+
+    va_start(ap, fmt);
+    vfprintf(output, fmt, ap);
+    va_end(ap);
+
+    fprintf(output, "\n");
+
+    fflush(output);
+}
diff --git a/src/libambit/libambit.c b/src/libambit/libambit.c
index beb3f43..81b3b26 100644
--- a/src/libambit/libambit.c
+++ b/src/libambit/libambit.c
@@ -1,5 +1,5 @@
 /*
- * (C) Copyright 2013 Emil Ljungdahl
+ * (C) Copyright 2014 Emil Ljungdahl
  *
  * This file is part of libambit.
  *
@@ -24,7 +24,6 @@
 
 #include <stdlib.h>
 #include <string.h>
-#include <stdio.h>
 
 /*
  * Local definitions
@@ -76,11 +75,15 @@ ambit_object_t *libambit_detect(void)
     int i;
     ambit_supported_device_t *device = NULL;
 
+    LOG_INFO("Searching devices");
+
     devs = hid_enumerate(0x0, 0x0);
     cur_dev = devs;
     while (cur_dev) {
         for (i=0; i<sizeof(supported_devices)/sizeof(supported_devices[0]); i++) {
+            LOG_INFO("vendor_id=%04x, product_id=%04x", cur_dev->vendor_id, cur_dev->product_id);
             if (cur_dev->vendor_id == supported_devices[i].vid && cur_dev->product_id == supported_devices[i].pid) {
+                LOG_INFO("match!");
                 // Found at least one supported row, lets remember that!
                 device = &supported_devices[i];
                 break;
@@ -95,6 +98,7 @@ ambit_object_t *libambit_detect(void)
     hid_free_enumeration(devs);
 
     if (device != NULL) {
+        LOG_INFO("Trying to open device");
         handle = hid_open(device->vid, device->pid, NULL);
         if (handle != NULL) {
             // Setup hid device correctly
@@ -130,15 +134,17 @@ ambit_object_t *libambit_detect(void)
 
                 // Initialize pmem
                 libambit_pmem20_init(ret_object, device->pmem20_chunksize);
+
+                LOG_INFO("Successfully opened device \"%s (%s)\" SW: %d.%d.%d, Supported: %s", device->name, device->model, ret_object->device_info.fw_version[0], ret_object->device_info.fw_version[1], ret_object->device_info.fw_version[3] << 8 | ret_object->device_info.fw_version[2], device->supported ? "YES" : "NO");
             }
             else {
                 free(ret_object);
                 ret_object = NULL;
-                printf("Failed to get device info\n");
+                LOG_ERROR("Failed to get device info from \"%s (%s)\"", device->name, device->model);
             }
         }
         else {
-            printf("Failed to open device\n");
+            LOG_ERROR("Failed to open device \"%s (%s)\"", device->name, device->model);
         }
     }
 
@@ -147,6 +153,7 @@ ambit_object_t *libambit_detect(void)
 
 void libambit_close(ambit_object_t *object)
 {
+    LOG_INFO("Closing");
     if (object != NULL) {
         if (object->handle != NULL) {
             // Make sure to clear log lock (if possible)
@@ -200,6 +207,8 @@ int libambit_date_time_set(ambit_object_t *object, struct tm *tm)
     uint8_t time_data[8] = { 0x09, 0x00, 0x01, 0x00 };
     int ret = -1;
 
+    LOG_INFO("Writing date and time to clock");
+
     // Set date
     *(uint16_t*)(&date_data[0]) = htole16(tm->tm_year);
     date_data[2] = 1 + tm->tm_mon;
@@ -216,6 +225,9 @@ int libambit_date_time_set(ambit_object_t *object, struct tm *tm)
 
         ret = 0;
     }
+    else {
+        LOG_WARNING("Failed to write date and time");
+    }
 
     return ret;
 }
@@ -226,12 +238,17 @@ int libambit_device_status_get(ambit_object_t *object, ambit_device_status_t *st
     size_t replylen;
     int ret = -1;
 
+    LOG_INFO("Reading device status");
+
     if (libambit_protocol_command(object, ambit_command_status, NULL, 0, &reply_data, &replylen, 0) == 0) {
         if (status != NULL) {
             status->charge = reply_data[1];
         }
         ret = 0;
     }
+    else {
+        LOG_WARNING("Failed to read device status");
+    }
 
     libambit_protocol_free(reply_data);
 
@@ -244,10 +261,15 @@ int libambit_personal_settings_get(ambit_object_t *object, ambit_personal_settin
     size_t replylen = 0;
     int ret = -1;
 
+    LOG_INFO("Reading personal settings");
+
     if (libambit_protocol_command(object, ambit_command_personal_settings, NULL, 0, &reply_data, &replylen, 0) == 0) {
         ret = libambit_personal_settings_parse(reply_data, replylen, settings);
         libambit_protocol_free(reply_data);
     }
+    else {
+        LOG_WARNING("Failed to read personal settings");
+    }
 
     return ret;
 }
@@ -264,6 +286,9 @@ int libambit_gps_orbit_header_read(ambit_object_t *object, uint8_t data[8])
 
         ret = 0;
     }
+    else {
+        LOG_WARNING("Failed to read GPS orbit header");
+    }
 
     return ret;
 }
@@ -273,6 +298,8 @@ int libambit_gps_orbit_write(ambit_object_t *object, uint8_t *data, size_t datal
     uint8_t header[8], cmpheader[8];
     int ret = -1;
 
+    LOG_INFO("Writing GPS orbit data");
+
     libambit_protocol_command(object, ambit_command_write_start, NULL, 0, NULL, NULL, 0);
 
     if (libambit_gps_orbit_header_read(object, header) == 0) {
@@ -290,6 +317,7 @@ int libambit_gps_orbit_write(ambit_object_t *object, uint8_t *data, size_t datal
             ret = libambit_pmem20_gps_orbit_write(object, data, datalen);
         }
         else {
+            LOG_INFO("Current GPS orbit data is already up to date, skipping");
             ret = 0;
         }
     }
@@ -313,15 +341,20 @@ int libambit_log_read(ambit_object_t *object, ambit_log_skip_cb skip_cb, ambit_l
     ambit_log_header_t log_header;
     ambit_log_entry_t *log_entry;
 
+    LOG_INFO("Reading number of logs");
+
     /*
      * Read number of log entries
      */
     if (libambit_protocol_command(object, ambit_command_log_count, NULL, 0, &reply_data, &replylen, 0) != 0) {
+        LOG_WARNING("Failed to read number of log entries");
         return -1;
     }
     log_entries_total = le16toh(*(uint16_t*)(reply_data + 2));
     libambit_protocol_free(reply_data);
 
+    LOG_INFO("Number of logs=%d", log_entries_total);
+
     /*
      * First part walks through headers to check if there is any point in start
      * reading the PMEM content. If no skip callback is defined, there is no
@@ -330,8 +363,10 @@ int libambit_log_read(ambit_object_t *object, ambit_log_skip_cb skip_cb, ambit_l
      */
 
     if (skip_cb != NULL) {
+        LOG_INFO("Look in headers for new logs");
         // Rewind
         if (libambit_protocol_command(object, ambit_command_log_head_first, NULL, 0, &reply_data, &replylen, 0) != 0) {
+            LOG_WARNING("Failed to rewind header pointer");
             return -1;
         }
         more = le32toh(*(uint32_t*)reply_data);
@@ -339,8 +374,10 @@ int libambit_log_read(ambit_object_t *object, ambit_log_skip_cb skip_cb, ambit_l
 
         // Loop through logs while more entries exists
         while (more == 0x00000400) {
+            LOG_INFO("Reading next header");
             // Go to next entry
             if (libambit_protocol_command(object, ambit_command_log_head_step, NULL, 0, &reply_data, &replylen, 0) != 0) {
+                LOG_WARNING("Failed to walk to next header");
                 return -1;
             }
             libambit_protocol_free(reply_data);
@@ -348,6 +385,7 @@ int libambit_log_read(ambit_object_t *object, ambit_log_skip_cb skip_cb, ambit_l
             // Assume every header is composited by 2 parts, where only the
             // second is of interrest right now
             if (libambit_protocol_command(object, ambit_command_log_head, NULL, 0, &reply_data, &replylen, 0) != 0) {
+                LOG_WARNING("Failed to read first part of header");
                 return -1;
             }
             libambit_protocol_free(reply_data);
@@ -357,21 +395,24 @@ int libambit_log_read(ambit_object_t *object, ambit_log_skip_cb skip_cb, ambit_l
                     if (skip_cb(userref, &log_header) != 0) {
                         // Header was NOT skipped, break out!
                         read_pmem = true;
+                        LOG_INFO("Found new entry, start reading log data");
                         break;
                     }
                 }
                 else {
-                    printf("Failed to parse log header\n");
+                    LOG_ERROR("Failed to parse log header");
                     return -1;
                 }
                 libambit_protocol_free(reply_data);
             }
             else {
+                LOG_WARNING("Failed to read second part of header");
                 return -1;
             }
 
             // Is there more entries to read?
             if (libambit_protocol_command(object, ambit_command_log_head_peek, NULL, 0, &reply_data, &replylen, 0) != 0) {
+                LOG_WARNING("Failed to check for more headers");
                 return -1;
             }
             more = le32toh(*(uint32_t*)reply_data);
@@ -379,6 +420,7 @@ int libambit_log_read(ambit_object_t *object, ambit_log_skip_cb skip_cb, ambit_l
         }
     }
     else {
+        LOG_INFO("No skip callback defined, reading log data");
         read_pmem = true;
     }
 
@@ -389,11 +431,13 @@ int libambit_log_read(ambit_object_t *object, ambit_log_skip_cb skip_cb, ambit_l
 
         // Loop through all log entries, first check headers
         while (log_entries_walked < log_entries_total && libambit_pmem20_log_next_header(object, &log_header) == 1) {
+            LOG_INFO("Reading header of log %d of %d", log_entries_walked, log_entries_total);
             if (progress_cb != NULL) {
                 progress_cb(userref, log_entries_total, log_entries_walked+1, 100*log_entries_walked/log_entries_total);
             }
             // Check if this entry needs to be read
             if (skip_cb == NULL || skip_cb(userref, &log_header) != 0) {
+                LOG_INFO("Reading data of log %d of %d", log_entries_walked, log_entries_total);
                 log_entry = libambit_pmem20_log_read_entry(object);
                 if (log_entry != NULL) {
                     if (push_cb != NULL) {
@@ -402,6 +446,9 @@ int libambit_log_read(ambit_object_t *object, ambit_log_skip_cb skip_cb, ambit_l
                     entries_read++;
                 }
             }
+            else {
+                LOG_INFO("Log %d of %d already exists, skip reading data", log_entries_walked, log_entries_total);
+            }
             log_entries_walked++;
             if (progress_cb != NULL) {
                 progress_cb(userref, log_entries_total, log_entries_walked, 100*log_entries_walked/log_entries_total);
@@ -409,6 +456,8 @@ int libambit_log_read(ambit_object_t *object, ambit_log_skip_cb skip_cb, ambit_l
         }
     }
 
+    LOG_INFO("%d entries read", entries_read);
+
     return entries_read;
 }
 
@@ -448,6 +497,8 @@ static int device_info_get(ambit_object_t *object, ambit_device_info_t *info)
     size_t replylen;
     int ret = -1;
 
+    LOG_INFO("Reading device info");
+
     if (libambit_protocol_command(object, ambit_command_device_info, send_data, sizeof(send_data), &reply_data, &replylen, 1) == 0) {
         if (info != NULL) {
             memcpy(info->model, reply_data, 16);
@@ -459,6 +510,9 @@ static int device_info_get(ambit_object_t *object, ambit_device_info_t *info)
         }
         ret = 0;
     }
+    else {
+        LOG_WARNING("Failed to read log info");
+    }
 
     libambit_protocol_free(reply_data);
 
@@ -480,11 +534,13 @@ static int lock_log(ambit_object_t *object, bool lock)
     }
 
     if (lock && current_lock == 0) {
+        LOG_INFO("Setting Sync message to device display");
         send_data[0] = 1;
         ret = libambit_protocol_command(object, ambit_command_lock_set, send_data, sizeof(send_data), &reply_data, &replylen, 0);
         libambit_protocol_free(reply_data);
     }
     else if (!lock && current_lock == 1) {
+        LOG_INFO("Clearing Sync message to device display");
         send_data[0] = 0;
         ret = libambit_protocol_command(object, ambit_command_lock_set, send_data, sizeof(send_data), &reply_data, &replylen, 0);
         libambit_protocol_free(reply_data);
diff --git a/src/libambit/libambit.h b/src/libambit/libambit.h
index bbac537..570c0a3 100644
--- a/src/libambit/libambit.h
+++ b/src/libambit/libambit.h
@@ -1,5 +1,5 @@
 /*
- * (C) Copyright 2013 Emil Ljungdahl
+ * (C) Copyright 2014 Emil Ljungdahl
  *
  * This file is part of libambit.
  *
diff --git a/src/libambit/libambit_int.h b/src/libambit/libambit_int.h
index 3777772..880b9e7 100644
--- a/src/libambit/libambit_int.h
+++ b/src/libambit/libambit_int.h
@@ -1,5 +1,5 @@
 /*
- * (C) Copyright 2013 Emil Ljungdahl
+ * (C) Copyright 2014 Emil Ljungdahl
  *
  * This file is part of libambit.
  *
@@ -98,7 +98,28 @@ int libambit_pmem20_gps_orbit_write(ambit_object_t *object, uint8_t *data, size_
 int libambit_protocol_command(ambit_object_t *object, uint16_t command, uint8_t *data, size_t datalen, uint8_t **reply_data, size_t *replylen, uint8_t legacy_format);
 void libambit_protocol_free(uint8_t *data);
 
-
+// debug.c
+typedef enum debug_level_e {
+    debug_level_err,
+    debug_level_warn,
+    debug_level_info
+} debug_level_t;
+void debug_printf(debug_level_t level, const char *file, int line, const char *func, const char *fmt, ...);
+#ifdef DEBUG_PRINT_ERROR
+#define LOG_ERROR(fmt, ...) debug_printf(debug_level_err, __FILE__, __LINE__, __func__, fmt, ##__VA_ARGS__)
+#else
+#define LOG_ERROR(fmt, ...)
+#endif
+#ifdef DEBUG_PRINT_WARNING
+#define LOG_WARNING(fmt, ...) debug_printf(debug_level_warn, __FILE__, __LINE__, __func__, fmt, ##__VA_ARGS__)
+#else
+#define LOG_WARNING(fmt, ...)
+#endif
+#ifdef DEBUG_PRINT_INFO
+#define LOG_INFO(fmt, ...) debug_printf(debug_level_info, __FILE__, __LINE__, __func__, fmt, ##__VA_ARGS__)
+#else
+#define LOG_INFO(fmt, ...)
+#endif
 
 // static helpers
 static inline uint8_t read8(uint8_t *buf, size_t offset)
diff --git a/src/libambit/personal.c b/src/libambit/personal.c
index ccb800d..9cfb66c 100644
--- a/src/libambit/personal.c
+++ b/src/libambit/personal.c
@@ -1,5 +1,5 @@
 /*
- * (C) Copyright 2013 Emil Ljungdahl
+ * (C) Copyright 2014 Emil Ljungdahl
  *
  * This file is part of libambit.
  *
diff --git a/src/libambit/pmem20.c b/src/libambit/pmem20.c
index 965ee27..a002ef1 100644
--- a/src/libambit/pmem20.c
+++ b/src/libambit/pmem20.c
@@ -1,5 +1,5 @@
 /*
- * (C) Copyright 2013 Emil Ljungdahl
+ * (C) Copyright 2014 Emil Ljungdahl
  *
  * This file is part of libambit.
  *
@@ -80,6 +80,7 @@ int libambit_pmem20_log_init(ambit_object_t *object)
     object->pmem20.log.buffer = malloc(PMEM20_LOG_SIZE);
     if (object->pmem20.log.buffer != NULL) {
         // Read initial log header
+        LOG_INFO("Reading first log data chunk");
         ret = read_log_chunk(object, PMEM20_LOG_START, object->pmem20.chunk_size, object->pmem20.log.buffer);
         if (ret == 0) {
             object->pmem20.log.prev_read = PMEM20_LOG_START;
@@ -94,9 +95,14 @@ int libambit_pmem20_log_init(ambit_object_t *object)
             object->pmem20.log.current.next = object->pmem20.log.first_entry;
             object->pmem20.log.current.prev = PMEM20_LOG_START;
 
+            LOG_INFO("log data header read, entries=%d, first_entry=%08x, last_entry=%08x, next_free_address=%08x", object->pmem20.log.entries, object->pmem20.log.first_entry, object->pmem20.log.last_entry, object->pmem20.log.next_free_address);
+
             // Set initialized
             object->pmem20.log.initialized = true;
         }
+        else {
+            LOG_WARNING("Failed to read first data chunk");
+        }
     }
 
     return ret;
@@ -118,12 +124,16 @@ int libambit_pmem20_log_next_header(ambit_object_t *object, ambit_log_header_t *
     size_t buffer_offset;
     uint16_t tmp_len;
 
+    LOG_INFO("Reading header of next log entry");
+
     if (!object->pmem20.log.initialized) {
+        LOG_ERROR("Trying to get next log without initialization");
         return -1;
     }
 
     // Check if we reached end of entries
     if (object->pmem20.log.current.current == object->pmem20.log.current.next) {
+        LOG_INFO("No more entries to read");
         return 0;
     }
 
@@ -139,10 +149,20 @@ int libambit_pmem20_log_next_header(ambit_object_t *object, ambit_log_header_t *
             buffer_offset += tmp_len;
             tmp_len = read16inc(object->pmem20.log.buffer, &buffer_offset);
             if (libambit_pmem20_log_parse_header(object->pmem20.log.buffer + buffer_offset, tmp_len, log_header) == 0) {
+                LOG_INFO("Log entry header parsed");
                 ret = 1;
             }
+            else {
+                LOG_ERROR("Failed to parse log entry header correctly");
+            }
+        }
+        else {
+            LOG_ERROR("Failed to find valid log entry header start");
         }
     }
+    else {
+        LOG_WARNING("Failed to read log entry header");
+    }
 
     // Unset initialized of something went wrong
     if (ret < 0) {
@@ -167,6 +187,7 @@ ambit_log_entry_t *libambit_pmem20_log_read_entry(ambit_object_t *object)
     uint32_t last_ehpe = 0;
 
     if (!object->pmem20.log.initialized) {
+        LOG_ERROR("Trying to get log entry without initialization");
         return NULL;
     }
 
@@ -176,6 +197,8 @@ ambit_log_entry_t *libambit_pmem20_log_read_entry(ambit_object_t *object)
         return NULL;
     }
 
+    LOG_INFO("Reading log entry from address=%08x", object->pmem20.log.current.current);
+
     buffer_offset = (object->pmem20.log.current.current - PMEM20_LOG_START);
     buffer_offset += 12;
     // Read samples content definition
@@ -185,6 +208,7 @@ ambit_log_entry_t *libambit_pmem20_log_read_entry(ambit_object_t *object)
     // Parse header
     tmp_len = read16inc(object->pmem20.log.buffer, &buffer_offset);
     if (libambit_pmem20_log_parse_header(object->pmem20.log.buffer + buffer_offset, tmp_len, &log_entry->header) != 0) {
+        LOG_ERROR("Failed to parse log entry header correctly");
         free(log_entry);
         object->pmem20.log.initialized = false;
         return NULL;
@@ -198,6 +222,8 @@ ambit_log_entry_t *libambit_pmem20_log_read_entry(ambit_object_t *object)
     }
     log_entry->samples_count = log_entry->header.samples_count;
 
+    LOG_INFO("Log entry got %d samples, reading", log_entry->samples_count);
+
     // OK, so we are at start of samples, get them all!
     while (sample_count < log_entry->samples_count) {
         if (PMEM20_LOG_START + buffer_offset + 2 >= object->pmem20.log.last_addr ||
@@ -251,6 +277,9 @@ ambit_log_entry_t *libambit_pmem20_log_read_entry(ambit_object_t *object)
                 altisource_index = sample_count-1;
             }
         }
+        else {
+            LOG_ERROR("Failed to parse sample %d of %d", sample_count, log_entry->samples_count);
+        }
     }
 
     // Loop through samples again and correct times etc
@@ -665,7 +694,7 @@ static int parse_sample(uint8_t *buf, size_t *offset, uint8_t **spec, ambit_log_
             log_entry->samples[*sample_count].u.position.longitude = read32inc(buf, &int_offset);
             break;
           default:
-            printf("Found unknown episodic sample type (%02x)\n", episodic_type);
+            LOG_WARNING("Found unknown episodic sample type (%02x)", episodic_type);
             log_entry->samples[*sample_count].type = ambit_log_sample_type_unknown;
             log_entry->samples[*sample_count].u.unknown.datalen = sample_len;
             log_entry->samples[*sample_count].u.unknown.data = malloc(sample_len);
@@ -675,7 +704,7 @@ static int parse_sample(uint8_t *buf, size_t *offset, uint8_t **spec, ambit_log_
         ret = 1;
         break;
       default:
-        printf("Found unknown sample type (%02x)\n", sample_type);
+        LOG_WARNING("Found unknown sample type (%02x)", sample_type);
         log_entry->samples[*sample_count].type = ambit_log_sample_type_unknown;
         log_entry->samples[*sample_count].u.unknown.datalen = sample_len;
         log_entry->samples[*sample_count].u.unknown.data = malloc(sample_len);
diff --git a/src/libambit/protocol.c b/src/libambit/protocol.c
index 078a2ca..192d29a 100644
--- a/src/libambit/protocol.c
+++ b/src/libambit/protocol.c
@@ -1,5 +1,5 @@
 /*
- * (C) Copyright 2013 Emil Ljungdahl
+ * (C) Copyright 2014 Emil Ljungdahl
  *
  * This file is part of libambit.
  *

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-running/openambit.git



More information about the Pkg-running-devel mailing list