summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--apps/grab.c14
-rw-r--r--private.h22
-rw-r--r--reader.c4
3 files changed, 32 insertions, 8 deletions
diff --git a/apps/grab.c b/apps/grab.c
index 0f90e71..b891e2f 100644
--- a/apps/grab.c
+++ b/apps/grab.c
@@ -1,10 +1,22 @@
#include <stdio.h>
+#include <stdlib.h>
#include <pcilib.h>
#include <pcilib/error.h>
#include <ipecamera.h>
+void log_error(void *arg, const char *file, int line, pcilib_log_priority_t prio, const char *format, va_list ap) {
+ vprintf(format, ap);
+ printf("\n");
+
+ if (prio == PCILIB_LOG_ERROR) {
+ printf("Exiting at [%s:%u]\n\n", file, line);
+ exit(-1);
+ }
+}
+
+
int main() {
int err;
pcilib_event_id_t evid;
@@ -14,6 +26,8 @@ int main() {
void *data;
FILE *f;
+ pcilib_set_logger(PCILIB_LOG_WARNING, &log_error, NULL);
+
pcilib_t *pcilib = pcilib_open("/dev/fpga0", "ipecamera");
if (!pcilib) pcilib_error("Error opening device");
diff --git a/private.h b/private.h
index a7d39e2..46d6c1a 100644
--- a/private.h
+++ b/private.h
@@ -8,9 +8,10 @@
#define IPECAMERA_DEBUG
#ifdef IPECAMERA_DEBUG
-//# define IPECAMERA_DEBUG_RAW_FRAMES
-# define IPECAMERA_DEBUG_BROKEN_FRAMES
-# define IPECAMERA_DEBUG_RAW_PACKETS
+//# define IPECAMERA_DEBUG_RAW_FRAMES //**< Store all raw frames */
+# define IPECAMERA_DEBUG_BROKEN_FRAMES //**< Store broken frames in the specified directory */
+# define IPECAMERA_DEBUG_RAW_PACKETS //**< Store all raw packets read from DMA grouped in frames */
+# define IPECAMERA_DEBUG_HARDWARE //**< Produce various debugging information about ipecamera operation */
#endif /* IPECAMERA_DEBUG */
//#define IPECAMERA_BUG_MISSING_PAYLOAD //**< CMOSIS fails to provide a first payload for each frame, therefore the frame is 32 bit shorter */
@@ -72,13 +73,22 @@
# define IPECAMERA_DEBUG_BROKEN_FRAMES_BUFFER(function, ...)
#endif /* IPECAMERA_DEBUG_BROKEN_FRAMES */
-#ifdef IPECAMERA_IPECAMERA_DEBUG_RAW_PACKETS
+#ifdef IPECAMERA_DEBUG_RAW_PACKETS
# define IPECAMERA_DEBUG_RAW_PACKETS_MESSAGE(function, ...) pcilib_debug_message (#function, __FILE__, __LINE__, __VA_ARGS__)
# define IPECAMERA_DEBUG_RAW_PACKETS_BUFFER(function, ...) pcilib_debug_data_buffer (#function, __VA_ARGS__)
-#else /* IPECAMERA_IPECAMERA_DEBUG_RAW_PACKETS */
+#else /* IPECAMERA_DEBUG_RAW_PACKETS */
# define IPECAMERA_DEBUG_RAW_PACKETS_MESSAGE(function, ...)
# define IPECAMERA_DEBUG_RAW_PACKETS_BUFFER(function, ...)
-#endif /* IPECAMERA_IPECAMERA_DEBUG_RAW_PACKETS */
+#endif /* IPECAMERA_DEBUG_RAW_PACKETS */
+
+#ifdef IPECAMERA_DEBUG_HARDWARE
+# define IPECAMERA_DEBUG_HARDWARE_MESSAGE(function, ...) pcilib_debug_message (#function, __FILE__, __LINE__, __VA_ARGS__)
+# define IPECAMERA_DEBUG_HARDWARE_BUFFER(function, ...) pcilib_debug_data_buffer (#function, __VA_ARGS__)
+#else /* IPECAMERA_DEBUG_HARDWARE */
+# define IPECAMERA_DEBUG_HARDWARE_MESSAGE(function, ...)
+# define IPECAMERA_DEBUG_HARDWARE_BUFFER(function, ...)
+#endif /* IPECAMERA_DEBUG_HARDWARE */
+
#define ipecamera_debug(function, ...) \
IPECAMERA_DEBUG_##function##_MESSAGE(IPECAMERA_DEBUG_##function, __VA_ARGS__)
diff --git a/reader.c b/reader.c
index 0364608..2b1bc9f 100644
--- a/reader.c
+++ b/reader.c
@@ -110,7 +110,7 @@ static int ipecamera_data_callback(void *user, pcilib_dma_flags_t flags, size_t
ipecamera_debug_buffer(RAW_PACKETS, bufsize, NULL, 0, "frame%4lu/frame%9lu.invalid", ctx->event_id, packet_id);
if (invalid_frame_id != ctx->event_id) {
- pcilib_info("No frame magic in DMA packet of %u bytes, current event %lu", bufsize, ctx->event_id);
+ ipecamera_debug(HARDWARE, "No frame magic in DMA packet of %u bytes, current event %lu", bufsize, ctx->event_id);
invalid_frame_id = ctx->event_id;
}
@@ -141,7 +141,7 @@ static int ipecamera_data_callback(void *user, pcilib_dma_flags_t flags, size_t
ctx->frame[ctx->buffer_pos].event.info.offset = (((uint32_t*)buf)[7] & 0xFFFFFF) * 80;
gettimeofday(&ctx->frame[ctx->buffer_pos].event.info.timestamp, NULL);
} else {
- pcilib_info("Frame magic is not found, ignoring broken data...");
+ ipecamera_debug(HARDWARE, "Frame magic is not found, ignoring broken data...");
return PCILIB_STREAMING_CONTINUE;
}
}