Browse Source

Fix minor error in rarely used path

Suren A. Chilingaryan 8 years ago
parent
commit
954ffcdb0e
2 changed files with 44 additions and 4 deletions
  1. 5 4
      data.c
  2. 39 0
      tests/stimuli20.sh

+ 5 - 4
data.c

@@ -79,7 +79,7 @@ ready:
 }
 
 static int ipecamera_get_next_buffer_to_process(ipecamera_t *ctx, pcilib_event_id_t *evid) {
-    int res;
+    int err, res;
 
     if (ctx->preproc_id == ctx->event_id) return -1;
     
@@ -101,9 +101,10 @@ static int ipecamera_get_next_buffer_to_process(ipecamera_t *ctx, pcilib_event_i
 
     res = ctx->preproc_id%ctx->buffer_size;
 
-    if (pthread_rwlock_trywrlock(&ctx->frame[res].mutex)) {
-	pthread_mutex_unlock(&ctx->preproc_mutex);
-	ipecamera_debug(HARDWARE, "Can't lock buffer %i", res);
+    if ((err = pthread_rwlock_trywrlock(&ctx->frame[res].mutex)) != 0) {
+	if (ctx->preproc)
+	    pthread_mutex_unlock(&ctx->preproc_mutex);
+	ipecamera_debug(HARDWARE, "Can't lock buffer %i, errno %i", res, err);
 	return -1;
     }
     

+ 39 - 0
tests/stimuli20.sh

@@ -0,0 +1,39 @@
+#!/bin/bash
+# By Michele Caselle for UFO 6 / 20 MPixels - camera
+echo "-----------------------------"
+echo "----  S T I M U L I ---------"
+echo "-----------------------------"
+
+if [ -z "$1" ]; then
+    echo "Please specify number of frames required"
+    exit
+fi
+
+rm mult$2.out*
+rd_flag=1
+
+#Make wr higher priority than rd
+pci -w 0x9100 0x20001000
+ddr_thr=a0
+
+echo "Set Number of frames.. to $1 hex"
+pci -w 9170 $1
+
+sleep .1
+pci -w 9040 0x80000001
+sleep .1
+echo "Send mult frame request ... "
+pci -w 9040 0x80000211
+sleep .05
+
+#pci -g -s $1 -o mult$2.raw 
+#IPECAMERA_DEBUG_HARDWARE="1" pci -g -s $1 --run-time 10000000 --buffer 1024 --verbose -o mult$2.out.decoded
+IPECAMERA_DEBUG_HARDWARE="1" pci -g -s $1 --run-time 10000000 --format default --data raw --buffer 1024 --verbose -o mult$2.out 
+sleep .3
+echo "decoding..."
+sleep .1
+ipedec -r 3840 --num-columns 5120 mult$2.out -f --continue
+
+sleep .1
+pci -w 9040 0x80000201
+pci -r 9000 -s 100