]> jspc29.x-matter.uni-frankfurt.de Git - trbnettools.git/commitdiff
ctr
authorhadaq <hadaq>
Wed, 21 Oct 2009 13:39:43 +0000 (13:39 +0000)
committerhadaq <hadaq>
Wed, 21 Oct 2009 13:39:43 +0000 (13:39 +0000)
libtrbnet/trbcmd.c

index 1cbccc90b8275363265db530bb45261a1687ac84..b45ed0ef071a5de597064bdd6e2350d6e328ff30 100644 (file)
@@ -16,7 +16,7 @@
 
 static int hexMode = HEXMODE;
 
-static const char trbcmd_version[] = "$Revision: 2.32 $";
+static const char trbcmd_version[] = "$Revision: 2.33 $";
 
 /* ---- User Buffer Size ----------------------------------------------- */
 
@@ -44,29 +44,36 @@ void usage(const char *progName)
          "as hexadecimal-numbers\n");
   printf("  -V    Version number\n");
   printf("\nCommands:\n");
-  printf("   r <trbaddress> <register>                  -> read register\n");
-  printf("   w <trbaddress> <register> <data>           -> write register\n");
-  printf("   rm <trbaddress> <register> <size> <mode>   -> read "
-         "register-memory\n");
-  printf("   wm <trbaddress> <register> <mode> <file>   -> write to "
-         "register-memory from ASCII-file ('-' = stdin)\n");
-  printf("   i <trbaddress>                             -> read unique ID\n");
-  printf("   s <uid> <endpoint> <trbaddress>            -> set trb-address\n");
-  printf("   T <type> <random> <info> <number>          -> send trigger\n");
-  printf("   TR <input> <type> <random> <info> <number> -> send trigger to " 
-         "RICH only\n");
-  printf("   I <type> <random> <info> <number>          -> read IPU data\n");
-  printf("   reload <trbaddress>                        -> reload FPGA\n");
-  printf("   reset                                      -> reset "
-         "TRBNetwork\n");
-  printf("   f <channel>                                -> flush FIFO of "
-         "channel\n");
-  printf("   R <register>                               -> "
-         "read register of the FPGA"
-         "  \n");
-  printf("   W <register> <value>                       -> "
-         "write to register of the FPGA"
-         "  \n");
+  printf("   r <trbaddress> <register>                        -> "
+         "read register\n");
+  printf("   w <trbaddress> <register> <data>                 -> "
+         "write register\n");
+  printf("   rm <trbaddress> <register> <size> <mode>         -> "
+         "read register-memory\n");
+  printf("   wm <trbaddress> <register> <mode> <file>         -> "
+         "write to register-memory from ASCII-file ('-' = stdin)\n");
+  printf("   i <trbaddress>                                   -> "
+         "read unique ID\n");
+  printf("   s <uid> <endpoint> <trbaddress>                  -> "
+         "set trb-address\n");
+  printf("   T <type> <random> <info> <number|%cctr>           -> "
+         "send trigger\n", '%');
+  printf("   TR <input> <type> <random> <info> <number|%cctr>  -> "
+         "send trigger to RICH only\n", '%');
+  printf("   I <type> <random> <info> <number|%cctr>           -> "
+         "read IPU data\n", '%');
+  printf("   reload <trbaddress>                              -> "
+         "reload FPGA\n");
+  printf("   reset                                            -> "
+         "reset TRBNetwork\n");
+  printf("   f <channel>                                      -> "
+         "flush FIFO of channel\n");
+  printf("   R <register>                                     -> "
+         "read register of the FPGA\n");
+
+  printf("   W <register> <value>                             -> "
+         "write to register of the FPGA\n");
+
 }
 
 #define CMD_SIZE 256
@@ -84,6 +91,7 @@ int main(int argc, char ** argv)
   uint16_t reg_address = 0; 
   int loop = 1;
   int loopCtr = 0;
+  uint16_t trgCtr = 0;   /* counter for the %ctr option */
   int opt;
 
   /* LowMem Settings, i.e. 3 MBye maximum */
@@ -632,8 +640,16 @@ int main(int argc, char ** argv)
         type = strtoul(cmd[1], NULL, hexMode == 1 ? 16 : 0) & 0x0f;
         random = strtoul(cmd[2], NULL, hexMode == 1 ? 16 : 0);
         info = strtoul(cmd[3], NULL, hexMode == 1 ? 16 : 0);
-        number = strtoul(cmd[4], NULL, hexMode == 1 ? 16 : 0);
-    
+        if (strncmp(cmd[4], "%ctr", CMD_SIZE) == 0) {
+          if (scriptFile == NULL) {
+            usage(basename(argv[0]));
+            exit(EXIT_FAILURE);
+          }
+          number = trgCtr++;
+        } else {
+          number = strtoul(cmd[4], NULL, hexMode == 1 ? 16 : 0);
+        }
+        
         /* DEBUG Info */
         if (trb_debug > 0) {
           fprintf(stderr, 
@@ -777,8 +793,17 @@ int main(int argc, char ** argv)
         type = strtoul(cmd[2], NULL, hexMode == 1 ? 16 : 0) & 0x0f;
         random = strtoul(cmd[3], NULL, hexMode == 1 ? 16 : 0);
         info = strtoul(cmd[4], NULL, hexMode == 1 ? 16 : 0);
-        number = strtoul(cmd[5], NULL, hexMode == 1 ? 16 : 0);
-    
+        
+        if (strncmp(cmd[5], "%ctr", CMD_SIZE) == 0) {
+          if (scriptFile == NULL) {
+            usage(basename(argv[0]));
+            exit(EXIT_FAILURE);
+          }
+          number = trgCtr++;
+        } else {
+          number = strtoul(cmd[5], NULL, hexMode == 1 ? 16 : 0);
+        }
+        
         /* DEBUG Info */
         if (trb_debug > 0) {
           fprintf(stderr, 
@@ -837,8 +862,16 @@ int main(int argc, char ** argv)
         type = strtoul(cmd[1], NULL, hexMode == 1 ? 16 : 0) & 0x0f;
         random = strtoul(cmd[2], NULL, hexMode == 1 ? 16 : 0);
         info = strtoul(cmd[3], NULL, hexMode == 1 ? 16 : 0);
-        number = strtoul(cmd[4], NULL, hexMode == 1 ? 16 : 0);
-    
+        if (strncmp(cmd[4], "%ctr", CMD_SIZE) == 0) {
+          if (scriptFile == NULL) {
+            usage(basename(argv[0]));
+            exit(EXIT_FAILURE);
+          }
+          number = trgCtr;
+        } else {
+          number = strtoul(cmd[4], NULL, hexMode == 1 ? 16 : 0);
+        }
+        
         /* DEBUG Info */
         if (trb_debug > 0) {
           fprintf(stderr,