From ff82489cba07d124ca76ac9ce78e70c73cad9317 Mon Sep 17 00:00:00 2001 From: "Suren A. Chilingaryan" Date: Wed, 5 Aug 2015 19:39:17 +0200 Subject: Add handling of a bug when IPECamera producing a dublicate 16 bytes at 4096 offset --- private.h | 1 + reader.c | 12 +++++++++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/private.h b/private.h index 9557ad4..f15317e 100644 --- a/private.h +++ b/private.h @@ -19,6 +19,7 @@ #define IPECAMERA_BUG_MISSING_PAYLOAD //**< CMOSIS fails to provide a first payload for each frame, therefore the frame is 32 bit shorter */ #define IPECAMERA_BUG_MULTIFRAME_PACKETS //**< This is by design, start of packet comes directly after the end of last one in streaming mode */ +#define IPECAMERA_BUG_REPEATING_DATA //**< 16 bytes repeated at frame offset 4096, the problem start/stop happenning on board restart */ //#define IPECAMERA_BUG_INCOMPLETE_PACKETS //**< Support incomplete packets, i.e. check for frame magic even if full frame size is not reached yet (slow) */ //#define IPECAMERA_ANNOUNCE_READY //**< Announce new event only after the reconstruction is done */ //#define IPECAMERA_CLEAN_ON_START //**< Read all the data from DMA before starting of recording */ diff --git a/reader.c b/reader.c index 2c95b13..e293005 100644 --- a/reader.c +++ b/reader.c @@ -234,8 +234,18 @@ static int ipecamera_data_callback(void *user, pcilib_dma_flags_t flags, size_t return -PCILIB_ERROR_TOOBIG; } - if (bufsize) + if (bufsize) { +#ifdef IPECAMERA_BUG_REPEATING_DATA + if ((bufsize > 16)&&(ctx->cur_size > 16)) { + if (!memcmp(ctx->buffer + ctx->buffer_pos * ctx->padded_size + ctx->cur_size - 16, buf, 16)) { + pcilib_warning("Skipping repeating bytes at offset %zu of frame %zu", ctx->cur_size, ctx->event_id); + buf += 16; + bufsize -=16; + } + } +#endif /* IPECAMERA_BUG_REPEATING_DATA */ memcpy(ctx->buffer + ctx->buffer_pos * ctx->padded_size + ctx->cur_size, buf, bufsize); + } } ctx->cur_size += bufsize; -- cgit v1.2.1