]> jspc29.x-matter.uni-frankfurt.de Git - trbnettools.git/commitdiff
*** empty log message ***
authorhadeshyp <hadeshyp>
Wed, 19 Aug 2009 10:34:07 +0000 (10:34 +0000)
committerhadeshyp <hadeshyp>
Wed, 19 Aug 2009 10:34:07 +0000 (10:34 +0000)
libtrbnet/trbcmd.c
libtrbnet/trbnet.c

index c9499f8760e59940142daf0558198c5c3887d18d..2d66cb6f8437f604c995b2f251871c4f7ff7e72e 100644 (file)
@@ -30,8 +30,8 @@ void usage(const char *progName)
   printf("  -f    execute commands given in script-file\n");
   printf("  -n    repeat COMMAND number times, -1 = endless loop\n");
   printf("  -d    turn on Debugging Information\n");
-  printf("        level 1: TRB_Package debugging\n");          
-  printf("        level 2: +FIFO debugging\n");                 
+  printf("        level 1: TRB_Package debugging\n");
+  printf("        level 2: +FIFO debugging\n");
   printf("  -D    FIFO DMA-Mode\n");
   printf("  -l    lazy-mode: skip most consistency-checks of packages\n");
   printf("  -H    hex-mode: all following arguments will be interpreted "
@@ -47,7 +47,7 @@ void usage(const char *progName)
   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 " 
+  printf("   TR <input> <type> <random> <info> <number> -> send trigger to "
          "RICH only\n");
   printf("   I <type> <random> <info> <number>          -> read IPU data\n");
   printf("   f <channel>                                -> flush FIFO of "
@@ -73,11 +73,11 @@ int main(int argc, char ** argv)
   size_t cmdLineLen = 0;
   unsigned int cmdLen = 0;
   uint16_t trb_address = 0;
-  uint16_t reg_address = 0; 
+  uint16_t reg_address = 0;
   int loop = 1;
   int loopCtr = 0;
   int opt;
-  
+
   trb_debug = 0;
   trb_lazy = 0;
   trb_semlock = 1;
@@ -117,7 +117,7 @@ int main(int argc, char ** argv)
       break;
     }
   }
-  
+
   /* Open scriptFile if requested */
   if (strlen(scriptFileName) > 0) {
     if (strncmp(scriptFileName, "-", 256) == 0) {
@@ -132,23 +132,23 @@ int main(int argc, char ** argv)
       }
     }
   }
-  
+
   /* Open ports */
-  init_ports();  
+  init_ports();
 
   /* Start repeat-loop */
   while ((loop == -1) || (loopCtr++ < loop)) {
     unsigned int lineCtr = 0;
     ssize_t scriptStatus = 0;
-    
+
     /* Start script-file-loop */
-    while (scriptStatus != -1) { 
-      if (scriptFile == NULL) {    
+    while (scriptStatus != -1) {
+      if (scriptFile == NULL) {
         /* Get command from function-call */
         unsigned int i;
         cmdLen = argc - optind;
         for (i = 0; (i < cmdLen) && (i < CMD_MAX_NUM); i++) {
-          strncpy(cmd[i], argv[optind + i], CMD_SIZE); 
+          strncpy(cmd[i], argv[optind + i], CMD_SIZE);
         }
         scriptStatus = -1;
       } else {
@@ -156,13 +156,13 @@ int main(int argc, char ** argv)
         char *c = NULL;
 
         unsigned int i;
-      
+
         lineCtr++;
         /* Initialize */
         for (i = 0; i < CMD_MAX_NUM; i++) {
           cmd[i][0] = '\0';
         }
-      
+
         if ((scriptStatus =
              getline(&cmdLine, &cmdLineLen, scriptFile)) == -1) {
           if (feof(scriptFile) != 0) {
@@ -175,7 +175,7 @@ int main(int argc, char ** argv)
             exit(EXIT_FAILURE);
           }
         }
-        
+
         /* Remove newline and comments */
         if ((c = strchr(cmdLine, '\n')) != NULL) {
           *c = '\0';
@@ -185,10 +185,10 @@ int main(int argc, char ** argv)
         }
 
         /* Split up cmdLine */
-        sscanf(cmdLine, "%s %s %s %s %s %s %s %s %s %s", 
+        sscanf(cmdLine, "%s %s %s %s %s %s %s %s %s %s",
                cmd[0], cmd[1], cmd[2], cmd[3], cmd[4],
                cmd[5], cmd[6], cmd[7], cmd[8], cmd[9]);
-      
+
         for (i = 0, cmdLen = 0; i < CMD_MAX_NUM; i++, cmdLen++) {
           if (cmd[i][0] == '\0') break;
         }
@@ -196,18 +196,17 @@ int main(int argc, char ** argv)
           /* Empty Line */
           continue;
         }
-
        fprintf(stdout, "#Line %d:  %s\n", lineCtr, cmdLine);
       }
-      
+
       if (strncmp(cmd[0], "w", CMD_SIZE) == 0) {
-    
+
         /*******************************************/
         /* Register Write                          */
         /*******************************************/
-    
+
         uint32_t value = 0;
-    
+
         if (cmdLen !=  4) {
           if (scriptFile != NULL) {
             fprintf(stderr, "Line #%d: Invalid command\n", lineCtr);
@@ -216,16 +215,16 @@ int main(int argc, char ** argv)
           }
           exit(EXIT_FAILURE);
         }
-    
+
         trb_address = strtoul(cmd[1], NULL, hexMode == 1 ? 16 : 0);
         reg_address = strtoul(cmd[2], NULL, hexMode == 1 ? 16 : 0);
         value = strtoul(cmd[3], NULL, hexMode == 1 ? 16 : 0);
-    
+
         /* DEBUG Info */
         if (trb_debug > 0) {
-          fprintf(stderr, 
+          fprintf(stderr,
                   "Command: WRITE: trb_address: 0x%04x, reg_address: 0x%04x, "
-                  "value: 0x%08x\n", 
+                  "value: 0x%08x\n",
                   trb_address, reg_address, value);
         }
 
@@ -247,7 +246,7 @@ int main(int argc, char ** argv)
         int status = 0;
         uint32_t data[256];
         int i;
-    
+
         if (cmdLen != 3) {
           if (scriptFile != NULL) {
             fprintf(stderr, "Line #%d: Invalid command\n", lineCtr);
@@ -256,18 +255,18 @@ int main(int argc, char ** argv)
           }
           exit(EXIT_FAILURE);
         }
-    
+
         trb_address = strtoul(cmd[1], NULL, hexMode == 1 ? 16 : 0);
         reg_address = strtoul(cmd[2], NULL, hexMode == 1 ? 16 : 0);
 
         /* DEBUG Info */
         if (trb_debug > 0) {
-          fprintf(stderr, 
+          fprintf(stderr,
                   "Command: READ: trb_address: 0x%04x, "
                   "reg_address: 0x%04x\n",
                   trb_address, reg_address);
         }
-    
+
         status = trb_register_read(trb_address, reg_address, data, 256);
         if (status == -1) {
           if (scriptFile != NULL) {
@@ -278,17 +277,17 @@ int main(int argc, char ** argv)
             exit(EXIT_FAILURE);
           }
         }
-        
+
         for (i = 0; i < status; i += 2) {
           fprintf(stdout, "0x%04x  0x%08x\n",
                   data[i], data[i + 1]);
         }
       } else if (strncmp(cmd[0], "rm", CMD_SIZE) == 0) {
-      
+
         /*******************************************/
         /* Register Read Memory                    */
         /*******************************************/
-    
+
         uint32_t *data = NULL;
         uint16_t size = 0;
         uint8_t option = 0;
@@ -297,7 +296,7 @@ int main(int argc, char ** argv)
         const uint32_t* end = NULL;
         unsigned int len;
         unsigned int i;
-   
+
         if (cmdLen != 5) {
           if (scriptFile != NULL) {
             fprintf(stderr, "Line #%d: Invalid command\n", lineCtr);
@@ -306,15 +305,15 @@ int main(int argc, char ** argv)
           }
           exit(EXIT_FAILURE);
         }
-    
+
         trb_address = strtoul(cmd[1], NULL, hexMode == 1 ? 16 : 0);
         reg_address = strtoul(cmd[2], NULL, hexMode == 1 ? 16 : 0);
         size = strtoul(cmd[3], NULL, hexMode == 1 ? 16 : 0);
         option = strtoul(cmd[4], NULL, hexMode == 1 ? 16 : 0);
-    
+
         /* DEBUG Info */
         if (trb_debug > 0) {
-          fprintf(stderr, 
+          fprintf(stderr,
                   "Command: READ_MEM: "
                   "trb_address: 0x%04x, "
                   "reg_address: 0x%04x, "
@@ -322,11 +321,11 @@ int main(int argc, char ** argv)
                   "option: %d\n",
                   trb_address, reg_address, size, option);
         }
-    
+
         if ((data = malloc(sizeof(uint32_t) * READ_MEM_SIZE)) == NULL) abort();
-    
-        status = 
-          trb_register_read_mem(trb_address, reg_address, option, 
+
+        status =
+          trb_register_read_mem(trb_address, reg_address, option,
                                 size, data, READ_MEM_SIZE);
         if (status == -1) {
           if (scriptFile != NULL) {
@@ -338,29 +337,29 @@ int main(int argc, char ** argv)
             exit(EXIT_FAILURE);
           }
         }
-        
+
         /* Print data-buffer */
         p = data;
         end = p + status;
         while (p < end) {
           len = (*p >> 16) & 0xffff;
           fprintf(stdout, "0x%04x  0x%04x\n", (*p++) & 0xffff, len);
-          for (i = 0; (i < len) && (p < end); i++) { 
-            fprintf(stdout, "0x%04x  0x%08x\n", 
+          for (i = 0; (i < len) && (p < end); i++) {
+            fprintf(stdout, "0x%04x  0x%08x\n",
                     reg_address + i, *p++);
           }
         }
-        
+
         if (data != NULL) free(data);
       } else if (strncmp(cmd[0], "wm", CMD_SIZE) == 0) {
-    
+
         /*******************************************/
         /* Register Write Memory                   */
         /*******************************************/
-    
+
         FILE *file = NULL;
         uint32_t *data = NULL;
-        unsigned int dataSize = 64; 
+        unsigned int dataSize = 64;
         char *line = NULL;
         size_t len = 0;
         char *fileName = NULL;
@@ -376,12 +375,12 @@ int main(int argc, char ** argv)
           }
           exit(EXIT_FAILURE);
         }
-    
+
         trb_address = strtoul(cmd[1], NULL, hexMode == 1 ? 16 : 0);
         reg_address = strtoul(cmd[2], NULL, hexMode == 1 ? 16 : 0);
         option = strtoul(cmd[3], NULL, hexMode == 1 ? 16 : 0);
         fileName = cmd[4];
-    
+
         /* Open inputFile and read Data into buffer */
         if (strncmp(fileName, "-", CMD_SIZE) == 0) {
           file = stdin;
@@ -392,7 +391,7 @@ int main(int argc, char ** argv)
             exit(EXIT_FAILURE);
           }
         }
-    
+
         if ((data = malloc(sizeof(uint32_t) * dataSize)) == NULL) abort();
         while (getline(&line, &len, file) != -1) {
           if (size >= dataSize) {
@@ -404,10 +403,10 @@ int main(int argc, char ** argv)
           data[size++] = strtoul(line, NULL, hexMode == 1 ? 16 : 0);
         }
         if (line != NULL) free(line);
-      
+
         /* DEBUG Info */
         if (trb_debug > 0) {
-          fprintf(stderr, 
+          fprintf(stderr,
                   "Command: WRITE_MEM: trb_address: 0x%04x, "
                   "reg_address: 0x%04x, "
                   "option: %d, "
@@ -415,11 +414,11 @@ int main(int argc, char ** argv)
                   "size: 0x%04x\n",
                   trb_address, reg_address, option, fileName, size);
         }
-      
-        status = trb_register_write_mem(trb_address, reg_address, option, 
+
+        status = trb_register_write_mem(trb_address, reg_address, option,
                                         data, size);
         if (data != NULL) free(data);
-    
+
         if (status == -1) {
           if (scriptFile != NULL) {
             fprintf(stderr, "Line #%d: ", lineCtr);
@@ -434,11 +433,11 @@ int main(int argc, char ** argv)
         /*******************************************/
         /* ReadUId                                 */
         /*******************************************/
-    
+
         uint32_t uidBuffer[512];
         int status;
         int i;
-        
+
         if (cmdLen != 2) {
           if (scriptFile != NULL) {
             fprintf(stderr, "Line #%d: Invalid command\n", lineCtr);
@@ -447,16 +446,16 @@ int main(int argc, char ** argv)
           }
           exit(EXIT_FAILURE);
         }
-    
+
         trb_address = strtoul(cmd[1], NULL, hexMode == 1 ? 16 : 0);
-    
+
         /* DEBUG Info */
         if (trb_debug > 0) {
-          fprintf(stderr, 
+          fprintf(stderr,
                   "Command: READ_UID: trb_address: 0x%04x\n",
                   trb_address);
         }
-    
+
         status = trb_read_uid(trb_address, uidBuffer, 128);
         if (status == -1) {
           if (scriptFile != NULL) {
@@ -467,24 +466,24 @@ int main(int argc, char ** argv)
             exit(EXIT_FAILURE);
           }
         }
-        
+
         for (i = 0; (i < status) && (i < 128); i += 4) {
           fprintf(stdout, "0x%04x  0x%08x%08x  0x%02x\n",
                   uidBuffer[i + 3],
-                  uidBuffer[i], 
-                  uidBuffer[i + 1], 
+                  uidBuffer[i],
+                  uidBuffer[i + 1],
                   uidBuffer[i + 2]);
         }
       } else if (strncmp(cmd[0], "s", CMD_SIZE) == 0) {
-    
+
         /*******************************************/
         /* SetAddress                              */
         /*******************************************/
-    
+
         uint64_t uid = 0;
         uint8_t endpoint = 0;
         uint16_t trb_address = 0;
-    
+
         if (cmdLen != 4) {
           if (scriptFile != NULL) {
             fprintf(stderr, "Line #%d: Invalid command\n", lineCtr);
@@ -493,21 +492,21 @@ int main(int argc, char ** argv)
           }
           exit(EXIT_FAILURE);
         }
-    
+
         uid = strtoull(cmd[1], NULL, hexMode == 1 ? 16 : 0);
         endpoint = strtoul(cmd[2], NULL, hexMode == 1 ? 16 : 0);
         trb_address = strtoul(cmd[3], NULL, hexMode == 1 ? 16 : 0);
-    
+
         /* DEBUG Info */
         if (trb_debug > 0) {
-          fprintf(stderr, 
+          fprintf(stderr,
                   "Command: SET_ADDRESS: "
                   "uid: 0x%016llx, "
                   "endpoint: 0x%02x, "
                   "trb_address: 0x%04x\n",
                   uid, endpoint, trb_address);
         }
-    
+
         if (trb_set_address(uid, endpoint, trb_address) == -1) {
           if (scriptFile != NULL) {
             fprintf(stderr, "Line #%d: ", lineCtr);
@@ -518,16 +517,16 @@ int main(int argc, char ** argv)
           }
         }
       } else if (strncmp(cmd[0], "T", CMD_SIZE) == 0) {
-    
+
         /*******************************************/
         /* Send Trigger                            */
         /*******************************************/
-      
+
         uint8_t type;
         uint8_t random = 0;
         uint8_t info = 0;
         uint16_t number = 0;
-    
+
         if (cmdLen != 5) {
           if (scriptFile != NULL) {
             fprintf(stderr, "Line #%d: Invalid command\n", lineCtr);
@@ -536,15 +535,15 @@ int main(int argc, char ** argv)
           }
           exit(EXIT_FAILURE);
         }
-      
+
         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);
-    
+
         /* DEBUG Info */
         if (trb_debug > 0) {
-          fprintf(stderr, 
+          fprintf(stderr,
                   "Command: SEND_TRIGGER: "
                   "type: 0x%01x, "
                   "random: 0x%02x, "
@@ -552,7 +551,7 @@ int main(int argc, char ** argv)
                   "number: 0x%04x\n",
                   type, random, info, number);
         }
-    
+
         if (trb_send_trigger(type, info, random, number) == -1) {
           if (scriptFile != NULL) {
             fprintf(stderr, "Line #%d: ", lineCtr);
@@ -561,19 +560,19 @@ int main(int argc, char ** argv)
           if (trb_errno != TRB_ENDPOINT_NOT_REACHED) {
             exit(EXIT_FAILURE);
           }
-        } 
+        }
       } else if (strncmp(cmd[0], "TR", CMD_SIZE) == 0) {
-    
+
         /*********************************************/
         /* Send Fake trigger function to RICH Subnet */
         /*********************************************/
-    
+
         uint8_t input = 0;
         uint8_t type = 0;
         uint8_t random = 0;
         uint8_t info = 0;
         uint16_t number = 0;
-      
+
         if (cmdLen != 6) {
           if (scriptFile != NULL) {
             fprintf(stderr, "Line #%d: Invalid command\n", lineCtr);
@@ -582,16 +581,16 @@ int main(int argc, char ** argv)
           }
           exit(EXIT_FAILURE);
         }
-    
+
         input = strtoul(cmd[1], NULL, hexMode == 1 ? 16 : 0) & 0x03;
         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);
-    
+
         /* DEBUG Info */
         if (trb_debug > 0) {
-          fprintf(stderr, 
+          fprintf(stderr,
                   "Command: SEND_TRIGGER: "
                   "input: 0x%01x, "
                   "type: 0x%01x, "
@@ -600,7 +599,7 @@ int main(int argc, char ** argv)
                   "number: 0x%04x\n",
                   input, type, random, info, number);
         }
-    
+
         if (trb_send_trigger_rich(input, type, info, random, number) == -1) {
           if (scriptFile != NULL) {
             fprintf(stderr, "Line #%d: ", lineCtr);
@@ -611,11 +610,11 @@ int main(int argc, char ** argv)
           }
         }
       } else if (strncmp(cmd[0], "I", CMD_SIZE) == 0) {
-    
+
         /*******************************************/
         /* IPU channel readout                     */
         /*******************************************/
-    
+
         uint32_t buffer[4096];
         uint8_t type = 0;
         uint8_t random = 0;
@@ -623,7 +622,7 @@ int main(int argc, char ** argv)
         uint16_t number = 0;
         int status = 0;
         int i;
-        
+
         if (cmdLen != 5) {
           if (scriptFile != NULL) {
             fprintf(stderr, "Line #%d: Invalid command\n", lineCtr);
@@ -632,15 +631,15 @@ int main(int argc, char ** argv)
           }
           exit(EXIT_FAILURE);
         }
-    
+
         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);
-    
+
         /* DEBUG Info */
         if (trb_debug > 0) {
-          fprintf(stderr, 
+          fprintf(stderr,
                   "Command: READ_IPU_DATA: "
                   "type: 0x%01x, "
                   "random: 0x%02x, "
@@ -658,19 +657,19 @@ int main(int argc, char ** argv)
             exit(EXIT_FAILURE);
           }
         }
-    
+
         for (i = 0; i < status; i++) {
           fprintf(stdout, "0x%08x\n", buffer[i]);
         }
       } else if (strncmp(cmd[0], "f", CMD_SIZE) == 0) {
-    
+
         /*******************************************/
         /* Flush FIFO Channel                      */
         /*******************************************/
-    
+
         int status;
         uint8_t channel = 0;
-    
+
         if (cmdLen != 2) {
           if (scriptFile != NULL) {
             fprintf(stderr, "Line #%d: Invalid command\n", lineCtr);
@@ -679,12 +678,12 @@ int main(int argc, char ** argv)
           }
           exit(EXIT_FAILURE);
         }
-    
+
         channel = strtoul(cmd[1], NULL, hexMode == 1 ? 16 : 0);
         if (trb_debug > 0) {
           fprintf(stderr, "Command: FIFO_FLUSH_CHANNEL #%d\n", channel);
         }
-    
+
         status = trb_fifo_flush(channel);
         if (status == -1) {
           if (scriptFile != NULL) {
@@ -696,14 +695,14 @@ int main(int argc, char ** argv)
           }
         }
       } else if (strncmp(cmd[0], "R", CMD_SIZE) == 0) {
-    
+
         /*******************************************/
         /* Read FIFO Register                      */
         /*******************************************/
-    
+
         uint32_t value = 0;
         uint16_t reg_address = 0;
-    
+
         if (cmdLen != 2) {
           if (scriptFile != NULL) {
             fprintf(stderr, "Line #%d: Invalid command\n", lineCtr);
@@ -716,24 +715,24 @@ int main(int argc, char ** argv)
         reg_address = strtoul(cmd[1], NULL, hexMode == 1 ? 16 : 0);
 
         if (trb_debug > 0) {
-          fprintf(stderr, 
+          fprintf(stderr,
                   "Command: READ_FIFO_REGISTER:"
                   "reg_address: 0x%04x\n",
                   reg_address);
         }
-        
+
         read32_from_FPGA(reg_address, &value);
         fprintf(stdout, "0x%04x  0x%08x\n", reg_address, value);
-      
+
       } else if (strncmp(cmd[0], "W", CMD_SIZE) == 0) {
-    
+
         /*******************************************/
         /* Write FIFO Register                     */
         /*******************************************/
-    
+
         uint32_t value = 0;
         uint16_t reg_address = 0;
-    
+
         if (cmdLen != 3) {
           if (scriptFile != NULL) {
             fprintf(stderr, "Line #%d: Invalid command\n", lineCtr);
@@ -742,18 +741,18 @@ int main(int argc, char ** argv)
           }
           exit(EXIT_FAILURE);
         }
-        
+
         reg_address = strtoul(cmd[1], NULL, hexMode == 1 ? 16 : 0);
         value = strtoul(cmd[2], NULL, hexMode == 1 ? 16 : 0);
 
         if (trb_debug > 0) {
-          fprintf(stderr, 
+          fprintf(stderr,
                   "Command: READ_FIFO_REGISTER:"
                   "reg_address: 0x%04x, "
                   "value: 0x%08x\n",
                   reg_address, value);
         }
-      
+
         write32_to_FPGA(reg_address, value);
       } else {
         if (scriptFile != NULL) {
@@ -764,14 +763,14 @@ int main(int argc, char ** argv)
         exit(EXIT_FAILURE);
      }
     } /* End script-file-loop */
-         
+
   } /* End repeat-loop */
-  
+
   /* Cleanup */
   if (scriptFile != NULL) {
     fclose(scriptFile);
   }
   if (cmdLine != 0) free(cmdLine);
-  
+
   exit(EXIT_SUCCESS);
 }
index 3ab3ed2567cd9f280f80929ee8e9fbc6566eaf05..e608a38e4b8f75946a8dce403af9a605db1d9183 100644 (file)
 /* ---------------------------------------------------------------------- */
 
 /* Used for blocking Signals SIGINT and SIGTERM */
-static sigset_t blockSet;   
+static sigset_t blockSet;
 static sigset_t blockSetOld;
 static int signalsBlocked = 0;
 
@@ -420,7 +420,7 @@ static int trb_fifo_read(uint8_t channel,
   /* Read FIFO-Buffer, copy to User-Buffer */
   while ((*tmp & MASK_FIFO_VALID) != 0) {
     fifoDebugCtr++;
-    
+
     if (((*tmp & MASK_FIFO_TYPE) >> SHIFT_FIFO_TYPE) == FIFO_TYPE_IS_HEADER) {
       /* TRBNet HEADER */
       if ((counter % 5) == 0) {
@@ -431,7 +431,7 @@ static int trb_fifo_read(uint8_t channel,
         }
         packageCtr++;
         counter = 0;
-        
+
         /* DEBUG INFO */
         if (trb_debug > 1) {
           fprintf(stderr, "FIFO_%03d:  0x%08x\n",
@@ -439,28 +439,28 @@ static int trb_fifo_read(uint8_t channel,
         }
       } 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 {
       /* 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);
@@ -849,9 +849,9 @@ static int lockPorts()
       SEM_UNDO | IPC_NOWAIT /* sem_flg: remove sem if process gets killed   */
     }
   };
-  
+
   if (trb_semlock == 0) return 0;
-  
+
   if (semop(semid, sops, 2) == -1) {
     perror("TRB_SEMAPHORE lock");
     trb_errno = TRB_SEMAPHORE;
@@ -870,15 +870,15 @@ static int unlockPorts()
       IPC_NOWAIT             /*  */
     }
   };
-  
+
   if (trb_semlock == 0) return 0;
-  
+
   if (semop(semid, sops, 1) == -1) {
     perror("TRB_SEMAPHORE unlock");
     trb_errno = TRB_SEMAPHORE;
     return -1;
   }
-  
+
   return 0;
 }
 
@@ -898,14 +898,14 @@ int init_ports()
     return -1;
   }
 
-  /* Get / Create semaphore */  
+  /* Get / Create semaphore */
   if (trb_semlock > 0) {
     if ((semid = semget(sem_key, 1, IPC_CREAT | 0666)) == -1) {
       trb_errno = TRB_SEMAPHORE;
       return -1;
     }
   }
-  
+
   return 0;
 }
 
@@ -927,15 +927,15 @@ int trb_fifo_flush(uint8_t channel)
   if (trb_debug > 1) {
     fprintf(stderr, "Flushing FIFO of channel# %d\n", channel);
   }
-  
+
   if (lockPorts() == -1) return -1;
-  
+
   blockSignals();
 
   fifo_flush(channel);
-  
+
   unblockSignals();
-  
+
   if (unlockPorts() == -1) return -1;
 
   return 0;
@@ -961,9 +961,9 @@ int trb_register_read(uint16_t trb_address,
   if (trb_debug > 0) {
     fprintf(stderr, "Init_Transfer done.\n");
   }
-  
+
   blockSignals();
-  
+
   /* Build up package and start transfer */
   write32_to_FPGA(CHANNEL_3_TARGET_ADDRESS, trb_address);
   write32_to_FPGA(CHANNEL_3_SENDER_ERROR, 0x00000000);
@@ -981,9 +981,9 @@ int trb_register_read(uint16_t trb_address,
   status = trb_fifo_read(3, FIFO_MODE_REG_READ, data, dsize);
 
   unblockSignals();
-  
+
   if (unlockPorts() == -1) return -1;
-  
+
   if ((status > 0) && (status % 2 != 0)) {
     trb_errno = TRB_INVALID_PKG_NUMBER;
     return -1;
@@ -1025,7 +1025,7 @@ int trb_register_read_mem(uint16_t trb_address,
   if (trb_debug > 0) {
     fprintf(stderr, "Init_Tranfer done.\n");
   }
-  
+
   blockSignals();
 
   /* Build up package and start transfer */
@@ -1071,11 +1071,11 @@ int trb_register_write(uint16_t trb_address,
                        uint32_t value)
 {
   int status;
-  
+
   trb_errno = TRB_NONE;
 
   if (lockPorts() == -1) return -1;
-  
+
   /* Init transfer */
   if (trb_init_transfer(3) == -1) {
     return -1;
@@ -1240,7 +1240,7 @@ int trb_set_address(uint64_t uid,
   }
 
   if (lockPorts() == -1) return -1;
-  
+
   /* Init transfer */
   if (trb_init_transfer(3) == -1) {
     return -1;
@@ -1272,9 +1272,9 @@ int trb_set_address(uint64_t uid,
   }
 
   status = trb_fifo_read(3, FIFO_MODE_SET_ADDRESS, NULL, 0);
-  
+
   unblockSignals();
-  
+
   if (unlockPorts() == -1) return -1;
 
   if (status == -1) return -1;
@@ -1300,7 +1300,7 @@ int trb_ipu_data_read(uint8_t type,
   if (data == NULL) return -1;
 
   if (lockPorts() == -1) return -1;
-  
+
   /* Init transfer IPU Channel */
   if (trb_init_transfer(1) == -1) {
     return -1;
@@ -1312,7 +1312,7 @@ int trb_ipu_data_read(uint8_t type,
   }
 
   blockSignals();
-  
+
   /* Prepare IPU channel */
   write32_to_FPGA(CHANNEL_1_SENDER_ERROR, (((uint32_t)trg_info << 24) |
                                            ((uint32_t)trg_random << 16) |
@@ -1375,11 +1375,11 @@ int trb_send_trigger(uint8_t type,
 
   /* Check for replay packets (trigger) */
   status = trb_fifo_read(0, FIFO_MODE_NONE, NULL, 0);
-  
+
   unblockSignals();
 
   if (unlockPorts() == -1) return -1;
-  
+
   if (status == -1) return -1;
 
   return 0;
@@ -1448,9 +1448,9 @@ int trb_send_trigger_rich(uint8_t trg_input,
 
   /* Check for replay packets (trigger) */
   status = trb_fifo_read(0, FIFO_MODE_NONE, NULL, 0);
-  
+
   unblockSignals();
-  
+
   if (unlockPorts() == -1) return -1;
 
   if (status == -1) return -1;