Browse Source

Add handling of a bug when IPECamera producing a dublicate 16 bytes at 4096 offset

Suren A. Chilingaryan 8 years ago
parent
commit
ff82489cba
2 changed files with 12 additions and 1 deletions
  1. 1 0
      private.h
  2. 11 1
      reader.c

+ 1 - 0
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 */

+ 11 - 1
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;