]> jspc29.x-matter.uni-frankfurt.de Git - trbnettools.git/commitdiff
Makefile remove deprecated RCS calls, trbflash improved debugging
authorLudwig Maier <lmaier@bia.e12.ph.tum.de>
Tue, 6 Aug 2013 19:21:40 +0000 (21:21 +0200)
committerLudwig Maier <lmaier@bia.e12.ph.tum.de>
Tue, 6 Aug 2013 19:21:40 +0000 (21:21 +0200)
libtrbnet/Makefile
libtrbnet/trbflash.c
libtrbnet/trbnet.c
pexor/kernel-module/100-pexor-udev.rules [new file with mode: 0644]
trbnetd/server/Makefile
trbrich/Makefile

index 01ce38c30321b272565b6c56ef734960fd3590f8..971237546ef47719b1249bf12de9d69fa4a6d140 100644 (file)
@@ -87,13 +87,11 @@ all: $(LIB_TARGETS) $(TARGETS)
 .PHONY: clean 
 clean:
        rm -f *.o core core.*
-       rcsclean
 
 .PHONY: distclean
 distclean: clean
        rm -f $(TARGETS) $(LIB_TARGETS)
        find . -type l -exec rm {} \;
-       rcsclean -u
 
 .PHONY: depend
 depend:
index b505943ef3a12a77fdb2b97fdabe137a2149a6bd..5d5572871048f89eeb473076502f32baa4c24fc6 100644 (file)
@@ -344,14 +344,17 @@ static int writeSetupRegister(uint16_t trb_address, uint8_t value)
   do {
     if ((status = trb_register_write(trb_address, SetupReg,
                                      (uint32_t) (value << 24))) == -1) {
-      fprintf(logFile, "Error > writeSetupRegister: TRBNet %s\n",
-              trb_strerror());
+      fprintf(logFile, 
+              "Error line %d > writeSetupRegister: TRBNet %s\n",
+              __LINE__, trb_strerror());
       return -1;
     }
 
     /* Check timeout */
     if (ctr >= timeout) {
-      fprintf(logFile, "Error > writeSetupRegister: timeout\n");
+      fprintf(logFile, 
+              "Error line %d > __LINE__ writeSetupRegister: timeout\n",
+              __LINE__);
       return -1;
     }
     ctr++;
@@ -361,8 +364,8 @@ static int writeSetupRegister(uint16_t trb_address, uint8_t value)
 
   if (trb_term.status_channel != 0) {
     fprintf(logFile,
-            "Error > writeSetupRegister: invalid Status returned %s\n",
-            trb_strerror());
+            "Error line %d > writeSetupRegister: invalid Status returned %s\n",
+            __LINE__, trb_strerror());
     return -1;
   }
 
@@ -381,21 +384,22 @@ static int readCtrlRegister(uint16_t trb_address,
   do {
     if ((status = trb_register_read(trb_address, CtrlReg,
                                     trbBuffer, TRB_BUFFER_SIZE)) == -1) {
-      fprintf(logFile, "Error > readCtrlRegister: TRBNet %s\n",
-              trb_strerror());
+      fprintf(logFile, "Error line %d > readCtrlRegister: TRBNet %s\n",
+              __LINE__, trb_strerror());
       return -1;
     }
 
     /* Check timeout */
     if (ctr >= timeout) {
-      fprintf(logFile, "Error > readCtrlRegister: timeout\n");
+      fprintf(logFile, "Error line %d > readCtrlRegister: timeout\n", __LINE__);
       return -1;
     }
     ctr++;
   } while (trb_term.status_channel != 0);
 
   if (status <= 0) {
-    fprintf(logFile, "Error > readCtrlRegister: %s\n", trb_strerror());
+    fprintf(logFile, "Error line %d > readCtrlRegister: %s\n",
+            __LINE__, trb_strerror());
     return -1;
   }
 
@@ -417,14 +421,15 @@ static int writeCtrlRegister(uint16_t trb_address, uint32_t value)
   /* Wait until NoMoreData is withdrawn */
   do {
     if ((status = trb_register_write(trb_address, CtrlReg, value)) == -1) {
-      fprintf(logFile, "Error > writeCtrlRegister: TRBNet %s\n",
-              trb_strerror());
+      fprintf(logFile, "Error line %d > writeCtrlRegister: TRBNet %s\n",
+              __LINE__, trb_strerror());
       return -1;
     }
 
     /* Check timeout */
     if (ctr >= timeout) {
-      fprintf(logFile, "Error writeCtrlRegister, timeout\n");
+      fprintf(logFile,
+              "Error line %d > Error writeCtrlRegister, timeout\n", __LINE__);
       return -1;
     }
     ctr++;
@@ -464,7 +469,9 @@ static int checkStatus(uint16_t trb_address)
   if ((status =
        trb_register_read(trb_address, BlockRam, trbBuffer,
                          TRB_BUFFER_SIZE)) == -1) {
-    fprintf(logFile, "Error > checkStatus: TRBNet %s\n", trb_strerror());
+    fprintf(logFile, 
+            "Error line %d > checkStatus: TRBNet %s\n",
+            __LINE__, trb_strerror());
     return -1;
   }
 
@@ -478,8 +485,10 @@ static int checkStatus(uint16_t trb_address)
         (flashParamRef.manId == 0x00471f)) {
       /* Check EPE Bit (ADCM and SHOWER) */
       if (((trbBuffer[i + 1] >> 5) & 0x01) == 1) {
-        fprintf(logFile, "Error > checkStatus: Erase or program error on "
-                "EndPoint 0x%04x\n", trbBuffer[i] & 0xffff);
+        fprintf(logFile, 
+                "Error line %d > checkStatus: Erase or program error on "
+                "EndPoint 0x%04x\n",
+                __LINE__, trbBuffer[i] & 0xffff);
         return -1;              /* Fatal Error */
       }
     }
@@ -497,17 +506,20 @@ static int writeStatusRegister(uint16_t trb_address, uint8_t value)
 
   /* Enable writing */
   if (sendCommand(trb_address, 0x06 << 24, 0) == -1) {
-    fprintf(logFile, "Error > writeStatusRegister: write enable\n");
+    fprintf(logFile,
+            "Error line %d > writeStatusRegister: write enable\n", __LINE__);
     return -1;
   }
 
   if (trb_register_write(trb_address, BlockRam, (uint32_t) value) == -1) {
-    fprintf(logFile, "Error > writeStatusRegister: TRBNet %s\n",
-            trb_strerror());
+    fprintf(logFile,
+            "Error line %d > writeStatusRegister: TRBNet %s\n",
+            __LINE__, trb_strerror());
     return -1;
   }
   if (sendCommand(trb_address, 0x01 << 24, 0) == -1) {
-    fprintf(logFile, "Error > writeStatusRegister: sendCommand\n");
+    fprintf(logFile,
+            "Error line %d > writeStatusRegister: sendCommand\n", __LINE__);
     return -1;
   }
 
@@ -516,7 +528,8 @@ static int writeStatusRegister(uint16_t trb_address, uint8_t value)
   }
 
   if (status != 0) {
-    fprintf(logFile, "Error > writeStatusRegister: invalid status\n");
+    fprintf(logFile,
+            "Error line %d > writeStatusRegister: invalid status\n", __LINE__);
     return -1;
   }
 
@@ -536,8 +549,9 @@ static int initTransfer(uint16_t trb_address)
   if ((status =
        trb_register_read(trb_address, HardwareId, trbBuffer,
                          TRB_BUFFER_SIZE)) == -1) {
-    fprintf(logFile, "Error > initTransfer, read HardwareIds: TRBNet %s\n",
-            trb_strerror());
+    fprintf(logFile,
+            "Error line %d > initTransfer, read HardwareIds: TRBNet %s\n",
+            __LINE__, trb_strerror());
     return -1;
   }
   
@@ -591,8 +605,8 @@ static int initTransfer(uint16_t trb_address)
   if ((status =
        trb_register_read(trb_address, BlockRam, trbBuffer,
                          TRB_BUFFER_SIZE)) == -1) {
-    fprintf(logFile, "Error > initTransfer, read ManIds: TRBNet %s\n",
-            trb_strerror());
+    fprintf(logFile, "Error line %d > initTransfer, read ManIds: TRBNet %s\n",
+            __LINE__, trb_strerror());
     return -1;
   }
   
@@ -663,7 +677,8 @@ static int readPage(uint16_t trb_address, uint32_t pageNumber,
   if ((status = trb_register_read_mem(trb_address, BlockRam, 0, size,
                                       trbBuffer, TRB_BUFFER_SIZE))
       == -1) {
-    fprintf(logFile, "Error > readPage: TRBNet %s\n", trb_strerror());
+    fprintf(logFile, "Error line %d > readPage: TRBNet %s\n",
+            __LINE__, trb_strerror());
     return -1;
   }
 
@@ -682,8 +697,8 @@ static int readPage(uint16_t trb_address, uint32_t pageNumber,
 
     if (len != size) {
       fprintf(logFile,
-              "Error > readPage: Invalid len %d returned by endpoint 0x%04x\n",
-              len, address);
+              "Error line %d > readPage: Invalid len %d returned by "
+              "endpoint 0x%04x\n", __LINE__, len, address);
     }
 
     /* read one page */
@@ -731,20 +746,21 @@ static int writePage(uint16_t trb_address, uint32_t pageNumber,
   if ((status = trb_register_write_mem(trb_address, BlockRam, 0,
                                        trbBuffer, size))
       == -1) {
-    fprintf(logFile, "Error > writePage: TRBNet %s\n", trb_strerror());
+    fprintf(logFile, "Error line %d > writePage: TRBNet %s\n",
+            __LINE__, trb_strerror());
     return -1;
   }
 
   /* Enable writing */
   if (sendCommand(trb_address, 0x06 << 24, 0) == -1) {
-    fprintf(logFile, "Error > writePage: write enable\n");
+    fprintf(logFile, "Error line %d > writePage: write enable\n", __LINE__);
     return -1;
   }
 
   /* Write page */
   trbcmd = (0x02 << 24) | ((pageNumber * PAGE_SIZE) & 0xffffff);
   if (sendCommand(trb_address, trbcmd, numBytes - 1) == -1) {
-    fprintf(logFile, "Error > writePage: write page\n");
+    fprintf(logFile, "Error line %d > writePage: write page\n", __LINE__);
     return -1;
   }
 
@@ -754,7 +770,7 @@ static int writePage(uint16_t trb_address, uint32_t pageNumber,
   }
 
   if (status != 0) {
-    fprintf(logFile, "Error > pageWrite: invalid status\n");
+    fprintf(logFile, "Error line %d > pageWrite: invalid status\n", __LINE__);
     return -1;
   }
 
@@ -968,7 +984,7 @@ static int programImageBuffer(uint16_t trb_address,
               error = -1;
               errorCtr++;
               fprintf(logFile,
-                      "verify failed page #%d, byte #%d "
+                      "Error > verify failed page #%d, byte #%d "
                       "(exp: 0x%02x rec: 0x%02x), EndPoint: 0x%04x\n",
                       page, c,
                       imageBuffer[page * PAGE_SIZE + c],
@@ -997,7 +1013,7 @@ static int programImageBuffer(uint16_t trb_address,
               error = -1;
               errorCtr++;
               fprintf(logFile,
-                      "verify failed InfoPage, byte #%d "
+                      "Error > verify failed InfoPage, byte #%d "
                       "(exp: 0x%02x rec: 0x%02x), EndPoint: 0x%04x\n",
                       c,
                       imageBuffer[(NUM_PAGES - 1) * PAGE_SIZE + c],
@@ -1068,7 +1084,8 @@ static int readImageFile(const char *imageFileName)
 
   if (imageSize > (PAGE_SIZE * NUM_PAGES)) {
     fprintf(logFile,
-            "Error > readImageFile: Imagefile '%s' is too large (%d bytes)\n",
+            "Error > readImageFile: Imagefile '%s' is too large" 
+            " (%d bytes)\n",
             imageFileName, imageSize);
     return -1;
   }
@@ -1137,8 +1154,9 @@ static int createInfoPage(const char *fileName, const char *userString)
   }
 
   if (stat(fileName, &statBuf) == -1) {
-    fprintf(logFile, "Error > prepareInfoPage: statCall failed: %s\n",
-            strerror(errno));
+    fprintf(logFile, 
+            "Error line %d > prepareInfoPage: statCall failed: %s\n",
+            __LINE__, strerror(errno));
     return -1;
   }
   snprintf(buffer + 0, 63, "NAME: %s", basename((char *)fileName));
@@ -1160,7 +1178,8 @@ static int openLog()
   /* Open LogFile */
   logFile = fopen(logFileName, "w+");
   if (logFile == NULL) {
-    fprintf(stderr, "Could not open logFile %s: %s\n",
+    fprintf(stderr,
+            "Error > Could not open logFile %s: %s\n",
             logFileName, strerror(errno));
     return -1;
   }
@@ -1179,8 +1198,8 @@ static int selectMdcFlashRom(uint16_t trb_address, uint8_t number)
   /* Select MDC-FlashRom */
   if (trb_register_write(trb_address, MDCFlashRomSelect,
                          (uint32_t) number) == -1) {
-    fprintf(logFile, "\nError > selcetMdcFlashRom: TRBNet %s\n",
-            trb_strerror());
+    fprintf(logFile, "\nError line %d > selectMdcFlashRom: TRBNet %s\n",
+            __LINE__, trb_strerror());
     return -1;
   }
 
index 06c5b10437bf945b136b7e76311897c30de45821..37e7d3363025732df08d558ab3130608fb927213 100644 (file)
@@ -63,7 +63,7 @@ static const struct timespec tv = {
   .tv_nsec = 0
 };
 static uint16_t trb3_port = 25000; 
-uint16_t sender_address = 0x5555;
+uint16_t sender_address = 0x4455;
 
 #endif
 
@@ -1465,13 +1465,9 @@ static int unlockPorts(int masterLock)
   return 0;
 }
 
-
+#ifndef TRB3
 static int init_semaphore()
 {
-#ifdef TRB3
-  return 0;
-#else
-
   /* Set signal mask to block ALL signals */
   sigfillset(&blockSet);
   sigemptyset(&blockSetOld);
@@ -1502,8 +1498,8 @@ static int init_semaphore()
   }
 
   return 0;
-#endif
 }
+#endif
 
 static int trb_register_modify(uint16_t trb_address,
                                uint16_t reg_address,
@@ -1686,6 +1682,9 @@ int init_ports()
 void close_ports()
 {
   /* Close FileHandler */
+  if (trb3_sockfd >= 0) {
+    close(trb3_sockfd);
+  }
   return;
 }
 
@@ -1723,11 +1722,7 @@ int init_ports()
   trb3_addr.sin_port = htons(trb3_port);  
   trb3_addr.sin_addr = *((struct in_addr*)host->h_addr);
   memset(&(trb3_addr.sin_zero), 0, 8);
-  
     
-  /* Init semaphore and signal handling */
-  if (init_semaphore() == -1) return -1;
-  
   return 0;
 }
 
diff --git a/pexor/kernel-module/100-pexor-udev.rules b/pexor/kernel-module/100-pexor-udev.rules
new file mode 100644 (file)
index 0000000..a8fa22f
--- /dev/null
@@ -0,0 +1 @@
+KERNEL=="pexor-*",      NAME="%k", MODE="0666", OPTIONS="last_rule"
index 5fb5d135fc21007ab41e6bb5c45c48516e7a93c6..967b7caf6603a5048109b0699ea932269f385905 100644 (file)
@@ -87,13 +87,11 @@ all: $(LIB_TARGETS) $(TARGETS)
 .PHONY: clean 
 clean:
        rm -f *.o core core.*
-       rcsclean
 
 .PHONY: distclean
 distclean: clean
        rm -f $(TARGETS) $(LIB_TARGETS)
        find . -type l -exec rm {} \;
-       rcsclean -u
 
 .PHONY: cleanrpc
 cleanrpc:
index e70d401639569ee8729d53b6ba50e45a8343b066..afdfae9a00e9d44e24c6160e2c02b2996d058e08 100644 (file)
@@ -81,12 +81,10 @@ all: $(LIB_TARGETS) $(TARGETS)
 .PHONY: clean 
 clean:
        rm -f *.o core core.*
-       rcsclean
 
 .PHONY: distclean
 distclean: clean
        rm -f $(TARGETS) $(LIB_TARGETS)
-       rcsclean -u
 
 .PHONY: depend
 depend: