]> jspc29.x-matter.uni-frankfurt.de Git - trbnettools.git/commitdiff
update
authorhadaq <hadaq>
Mon, 10 Oct 2011 22:28:15 +0000 (22:28 +0000)
committerhadaq <hadaq>
Mon, 10 Oct 2011 22:28:15 +0000 (22:28 +0000)
libtrbnet/trbnet.c

index d16af8e6902b5f7abdb8321e8fcd65543126131b..7ee4df9fe3659bce8188c9fb2602655d5d3a930a 100644 (file)
@@ -15,7 +15,7 @@
 #endif
 
 
-const char trbnet_version[] = "$Revision: 4.8 $";
+const char trbnet_version[] = "$Revision: 4.9 $";
 
 #include <stdlib.h>
 #include <signal.h>
@@ -564,11 +564,13 @@ static int trb_fifo_read(uint8_t channel,
 #ifdef PEXOR
   if (dataBufferSize == 0) {
     trb_errno = TRB_PEXOR_DMA_ERROR;
+    fprintf(stderr, "DMA: err 0\n");
     return -1;
   }
   if (read(pexorFileHandle,
            (void*)dataBuffer, dataBufferSize * 4) != dataBufferSize * 4) {
     trb_errno = TRB_PEXOR_DMA_ERROR;
+    fprintf(stderr, "DMA: err 1\n");
     return -1;
   }
 #else
@@ -1120,6 +1122,7 @@ static int trb_fifo_read(uint8_t channel,
 #ifdef PEXOR
     if (tmp - dataBuffer >= dataBufferSize) {
       trb_errno = TRB_PEXOR_DMA_ERROR;
+    fprintf(stderr, "DMA: err 2\n");
       return -1;
     }
     tmp++;
@@ -1854,6 +1857,14 @@ int trb_register_write_mem(uint16_t trb_address,
     write32_to_FPGA(CHANNEL_3_SENDER_CONTROL, CMD_REGISTER_WRITE_MEM);
 #else
     /* Send command to pexor driver */
+    if (write(pexorFileHandle,
+             (void*)(data + ctr), len * 4) != len * 4) {
+      trb_errno = TRB_PEXOR_DEVICE_ERROR;
+      unlockPorts(0);
+      trb_errno = TRB_PEXOR_DEVICE_ERROR;
+      return -1;
+    }
+
     pexorDescriptor.trb_address = trb_address;
     if (option == 0) {
       pexorDescriptor.reg_address = reg_address + ctr;
@@ -1861,8 +1872,7 @@ int trb_register_write_mem(uint16_t trb_address,
       pexorDescriptor.reg_address = reg_address;
     }
     pexorDescriptor.arg0 = config;
-    pexorDescriptor.arg1 = (unsigned long)(data + ctr);
-    pexorDescriptor.arg2 = len;
+    pexorDescriptor.arg1 = len;
     pexorDescriptor.command = PEXOR_TRBNETCOM_REG_WRITE_MEM;
     pexorDescriptor.dma = pexor_dma;
     
@@ -2289,13 +2299,12 @@ int fpga_register_read(uint32_t reg_address, uint32_t* value)
   int status = 0;
   
   trb_errno = TRB_NONE;
-
-  if (lockPorts(0) == -1) return -1;
-
 #ifndef PEXOR
   reg_address &= 0xffff;
 #endif
 
+  if (lockPorts(0) == -1) return -1;
+
   /* DEBUG INFO */
   if (trb_debug > 0) {
     fprintf(stderr, "fpga_register_read started.\n");
@@ -2313,13 +2322,12 @@ int fpga_register_write(uint32_t reg_address, uint32_t value)
   int status = 0;
   
   trb_errno = TRB_NONE;
-
-  if (lockPorts(0) == -1) return -1;
-
 #ifndef PEXOR
   reg_address &= 0xffff;
 #endif
 
+  if (lockPorts(0) == -1) return -1;
+
   /* DEBUG INFO */
   if (trb_debug > 0) {
     fprintf(stderr, "fpga_register_write started.\n");