]> jspc29.x-matter.uni-frankfurt.de Git - trbnettools.git/commitdiff
added TRB_DEBUGGER variable, removed lazy option
authorhadaq <hadaq>
Mon, 12 Apr 2010 01:06:14 +0000 (01:06 +0000)
committerhadaq <hadaq>
Mon, 12 Apr 2010 01:06:14 +0000 (01:06 +0000)
libtrbnet/Makefile
libtrbnet/trbcmd.c
libtrbnet/trbnet.c
libtrbnet/trbnet.h

index 8f02f83ec8154a2e3a1518844c65031f38544aac..696e97f7a1558b4cd8cefec2535bdee2c7799186 100644 (file)
@@ -4,7 +4,7 @@ AXIS_USABLE_LIBS = UCLIBC GLIBC
 include $(AXIS_TOP_DIR)/tools/build/Rules.axis
 
 INCDIR = -I.
-CPPFLAGS = #-DHEXMODE
+CPPFLAGS = #-DTRB_DEBUGGER  #-DHEXMODE 
 
 CFLAGS = -pipe -g -Wall  -Winline -O3 -fPIC -finline-functions -finline-limit=600000
 
index 4ea0483c380b96f6a84d1bfbc3b41697d14698ca..306131a33e2e4596c36d708b32bbfc1dc250766c 100644 (file)
@@ -35,7 +35,7 @@
 
 static int hexMode = HEXMODE;
 
-static const char trbcmd_version[] = "$Revision: 2.45 $";
+static const char trbcmd_version[] = "$Revision: 2.46 $";
 
 #define BACKLOG 10
 static uint16_t tcp_port = 55555;
@@ -66,8 +66,6 @@ void usage(const char *progName)
   fprintf(STDOUT, "        level 1: TRB_Package debugging\n");
   fprintf(STDOUT, "        level 2: +FIFO debugging\n");
   fprintf(STDOUT, "  -D    FIFO DMA-Mode\n");
-  fprintf(STDOUT,
-          "  -l    lazy-mode: skip most consistency-checks of packages\n");
   fprintf(STDOUT,
           "  -H    hex-mode: all arguments will be interpreted "
           "as hexadecimal-numbers\n");
@@ -152,11 +150,10 @@ int start(int argc, char **argv)
   USER_BUFFER_SIZE = 786432;    /* 0xc000  * 4 Byte */
 
   trb_debug = 0;
-  trb_lazy = 0;
   
   /* Parse Arguments */
   optind = 1;
-  while ((opt = getopt(argc, argv, "+hf:n:d:DlHMV")) != -1) {
+  while ((opt = getopt(argc, argv, "+hf:n:d:DHMV")) != -1) {
     switch (opt) {
     case '?':
       usage(basename(argv[0]));
@@ -176,9 +173,6 @@ int start(int argc, char **argv)
     case 'D':
       trb_dma = 1;
       break;
-    case 'l':
-      trb_lazy = 1;
-      break;
     case 'H':
       hexMode = 1;
       break;
@@ -385,7 +379,7 @@ int start(int argc, char **argv)
           }
         }
         free(data);
-
+        
       } else if (strncmp(cmd[0], "rm", CMD_SIZE) == 0) {
 
         /*******************************************/
index e86417883533c349669ed184f9025f6c7d033964..66ffcce0b0b2f36fb815a4a8da585e0665cfa760 100644 (file)
@@ -1,4 +1,4 @@
-const char trbnet_version[] = "$Revision: 2.59 $";
+const char trbnet_version[] = "$Revision: 2.60 $";
 
 #include <stdlib.h>
 #include <signal.h>
@@ -142,7 +142,6 @@ static int semid = -1;
 static const key_t sem_key = 0x545242;
 
 unsigned int trb_debug = 0;
-unsigned int trb_lazy = 0;
 unsigned int trb_dma = 0;
 FILE* trb_stderr = NULL;
 
@@ -551,9 +550,8 @@ static int trb_fifo_read(uint8_t channel,
                 fifoDebugCtr, *tmp);
       }
 
-      if ((trb_lazy == 0) &&
-          (((*tmp & MASK_FIFO_TYPE) >> SHIFT_FIFO_TYPE) !=
-           (counter - 1) % 2)) {
+      if (((*tmp & MASK_FIFO_TYPE) >> SHIFT_FIFO_TYPE) !=
+           (counter - 1) % 2) {
         /* Error: invalid sequence (not 0, 1, .), flush FIFO-BUFFER and exit */
         fifo_flush(channel);
         trb_errno = TRB_FIFO_SEQUENZ;
@@ -592,19 +590,18 @@ static int trb_fifo_read(uint8_t channel,
       /* DEBUG INFO */
       if (trb_debug > 0) {
         TRB_Package_dump(&package);
-        fprintf(trb_stderr, "-------------------------------------------------\n");
+        fprintf(trb_stderr,
+                "-------------------------------------------------\n");
       }
 
-      if (trb_lazy == 0) {
-        /* First package: headerType must be HDR or TRM */
-        if (packageCtr == 0) {
-          if (!((headerType == HEADER_HDR) || (headerType == HEADER_TRM))) {
-            fifo_flush(channel);
-            trb_errno = TRB_FIFO_INVALID_HEADER;
-            return -1;
-          }
+      /* First package: headerType must be HDR or TRM */
+      if (packageCtr == 0) {
+        if (!((headerType == HEADER_HDR) || (headerType == HEADER_TRM))) {
+          fifo_flush(channel);
+          trb_errno = TRB_FIFO_INVALID_HEADER;
+          return -1;
         }
-
+      
         /* Check Header H0 */
         if (((package.H0 & MASK_HEADER_REPLY) >> SHIFT_HEADER_REPLY
              != 0x01) ||
@@ -645,6 +642,9 @@ static int trb_fifo_read(uint8_t channel,
           }
           if (dataCtr < dsize) {
             data[dataCtr++] = (uint32_t)package.F0;
+#ifdef TRB_DEBUGGER
+            fprintf(trb_stderr, "D: 0x%04x  ", data[dataCtr - 1]);
+#endif
           } else {
             fifo_flush(channel);
             trb_errno = TRB_USER_BUFFER_OVF;
@@ -661,6 +661,9 @@ static int trb_fifo_read(uint8_t channel,
           if (dataCtr < dsize) {
             data[dataCtr++] = (((uint32_t)package.F1 << 16) |
                                ((uint32_t)package.F2));
+#ifdef TRB_DEBUGGER
+            fprintf(trb_stderr, "0x%08x\n", data[dataCtr - 1]); 
+#endif
             endPointCtr++;
           } else {
             fifo_flush(channel);
@@ -694,6 +697,9 @@ static int trb_fifo_read(uint8_t channel,
               memLen = 0;
               lastHeader = &data[dataCtr];
               data[dataCtr++] = (uint32_t)package.F0;
+#ifdef TRB_DEBUGGER
+              fprintf(trb_stderr, "D: H: 0x%04x\n", data[dataCtr - 1]);
+#endif
             } else {
               fifo_flush(channel);
               trb_errno = TRB_USER_BUFFER_OVF;
@@ -706,6 +712,10 @@ static int trb_fifo_read(uint8_t channel,
               if (package.F0 == 0x0000) break; /* it a hack, ask Jan */
               data[dataCtr++] = (((uint32_t)package.F1 << 16) |
                                  ((uint32_t)package.F2));
+#ifdef TRB_DEBUGGER
+              fprintf(trb_stderr,
+                      "D: 0x%04x  0x%08x\n", memLen, data[dataCtr - 1]); 
+#endif
               memLen++;
             } else {
               fifo_flush(channel);
@@ -765,6 +775,9 @@ static int trb_fifo_read(uint8_t channel,
                      ((uint32_t)package.F1))
                   : (((uint32_t)package.F2 << 16) |
                      ((uint32_t)package.F3));
+#ifdef TRB_DEBUGGER   
+                fprintf(trb_stderr, "D: 0x%08x\n", data[dataCtr - 1]);
+#endif
               } else {
                 fifo_flush(channel);
                 trb_errno = TRB_USER_BUFFER_OVF;
@@ -814,6 +827,12 @@ static int trb_fifo_read(uint8_t channel,
                 data[dataCtr++] = (uint32_t)package.F0;
                 data[dataCtr++] = (uint32_t)sourceAddress;
                 endPointCtr++;
+#ifdef TRB_DEBUGGER
+                fprintf(trb_stderr, "D: 0x%04x  0x%08x%08x  0x%02x\n",
+                        (uint32_t)sourceAddress,
+                        uidLow, uidHigh, 
+                        (uint32_t)package.F0);
+#endif
               } else {
                 fifo_flush(channel);
                 trb_errno = TRB_USER_BUFFER_OVF;
@@ -884,36 +903,34 @@ static int trb_fifo_read(uint8_t channel,
   trb_term.sequence = package.F3;
   trb_term.channel = channel;
 
-  if (trb_lazy == 0) {
-    /* Check whether last package is complete */
-    if ((packageCtr >= 0) && (counter != 5)) {
-      trb_errno = TRB_FIFO_INCOMPLETE_PACKAGE;
-      return -1;
-    }
-
-    /* Check whether last package is a TERMINATION Package */
-    if (headerType != HEADER_TRM) {
-      trb_errno = TRB_FIFO_MISSING_TERM_HEADER;
-      return -1;
-    }
-
-    /* Check StatusBits of TerminationPackage */
-    if ((trb_term.status_common == 0) && (trb_term.status_channel == 0)) {
-      trb_errno = TRB_ENDPOINT_NOT_REACHED;
-      return -1;
-    }
-
-    if ((trb_term.status_common & 0x007e) != 0) {
-      trb_errno = TRB_STATUS_ERROR;
-      return -1;
-    }
+  /* Check whether last package is complete */
+  if ((packageCtr >= 0) && (counter != 5)) {
+    trb_errno = TRB_FIFO_INCOMPLETE_PACKAGE;
+    return -1;
+  }
 
-    if ((channel == 3) && ((trb_term.status_channel & 0x0002) != 0)) {
-      trb_errno = TRB_STATUS_ERROR;
-      return -1;
-    }
+  /* Check whether last package is a TERMINATION Package */
+  if (headerType != HEADER_TRM) {
+    trb_errno = TRB_FIFO_MISSING_TERM_HEADER;
+    return -1;
+  }
+  
+  /* Check StatusBits of TerminationPackage */
+  if ((trb_term.status_common == 0) && (trb_term.status_channel == 0)) {
+    trb_errno = TRB_ENDPOINT_NOT_REACHED;
+    return -1;
+  }
+  
+  if ((trb_term.status_common & 0x007e) != 0) {
+    trb_errno = TRB_STATUS_ERROR;
+    return -1;
   }
 
+  if ((channel == 3) && ((trb_term.status_channel & 0x0002) != 0)) {
+    trb_errno = TRB_STATUS_ERROR;
+    return -1;
+  }
+  
   return dataCtr;
 }
 
index a514654cecd8b0edbdb7c67aee6b2ccf391e0d54..82062aa0d087914409aa6f6f7c21a06cade687c8 100644 (file)
@@ -7,7 +7,6 @@ extern const char trbnet_version[];
 #include <stdio.h>
 
 extern unsigned int trb_debug;
-extern unsigned int trb_lazy;
 extern unsigned int trb_dma;
 extern FILE* trb_stderr;