]> jspc29.x-matter.uni-frankfurt.de Git - trbnettools.git/commitdiff
bugfix
authorhadaq <hadaq>
Thu, 13 Aug 2009 13:43:16 +0000 (13:43 +0000)
committerhadaq <hadaq>
Thu, 13 Aug 2009 13:43:16 +0000 (13:43 +0000)
.

libtrbnet/trbnet.c

index 366ee305c5811d6920641146529c52de0615c511..b39fc30cffe9b0b49fc23e26172025e85d07dd2c 100644 (file)
@@ -382,6 +382,7 @@ static int trb_fifo_read(uint8_t channel,
   unsigned int counter = 0;
   unsigned int dataCtr = 0;
   int packageCtr = -1;
+  int fifoDebugCtr = -1;
   unsigned int endPointCtr = 0;
 
   unsigned int timeout = 0;
@@ -417,14 +418,12 @@ static int trb_fifo_read(uint8_t channel,
 
   /* Read FIFO-Buffer, copy to User-Buffer */
   while ((*tmp & MASK_FIFO_VALID) != 0) {
-    
-    /* DEBUG INFO */
-    if (trb_debug > 1) {
-      fprintf(stderr, "FIFO_%03d:  0x%08x\n",
-              packageCtr * 5 + counter, *tmp);
-    }
+    fifoDebugCtr++;
     
     if (((*tmp & MASK_FIFO_TYPE) >> SHIFT_FIFO_TYPE) == FIFO_TYPE_IS_HEADER) {
+      /* TRBNet HEADER */
+      
+    
       if ((counter % 5) == 0) {
         /* New Package begins */
         if (trb_debug > 0) {
@@ -433,16 +432,36 @@ static int trb_fifo_read(uint8_t channel,
         }
         packageCtr++;
         counter = 0;
+        
+        /* DEBUG INFO */
+        if (trb_debug > 1) {
+          fprintf(stderr, "FIFO_%03d:  0x%08x\n",
+                  fifoDebugCtr, *tmp);
+        }
       } else {
         /* Error: invalid buffer content, flush FIFO-BUFFER and exit */
+        
+        /* DEBUG INFO */
+        if (trb_debug > 1) {
+          fprintf(stderr, "FIFO_%03d:  0x%08x\n",
+                  fifoDebugCtr, *tmp);
+        }
+        
         fifo_flush(channel);
         trb_errno = TRB_FIFO_INCOMPLETE_PACKAGE;
         return -1;
       }
     } else {
-      /* Data Word */
+      /* TRBNet Data Word */
+      
+      /* DEBUG INFO */
+      if (trb_debug > 1) {
+        fprintf(stderr, "FIFO_%03d:  0x%08x\n",
+                fifoDebugCtr, *tmp);
+      }
+      
       if ((trb_lazy == 0) &&
-          (((*tmp & MASK_FIFO_TYPE) >> SHIFT_FIFO_TYPE) !=
+          (((*tmp & MASK_FIFO_TYPE) >> SHIFT_FIFO_TYPE) != 
            (counter - 1) % 2)) {
         /* Error: invalid sequence (not 0, 1, .), flush FIFO-BUFFER and exit */
         fifo_flush(channel);