Browse Source

Fixed incorrect passing of value instead of string to PCI methods
Fixed wrong bitmasks

kapture2 2 years ago
parent
commit
83be798533
1 changed files with 27 additions and 25 deletions
  1. 27 25
      KCG/base/ModeButtonsToolbar.py

+ 27 - 25
KCG/base/ModeButtonsToolbar.py

@@ -56,50 +56,52 @@ class ModeSelectToolbar(QtGui.QToolBar):
         #Pre-Calculate the mask to switch "Equivalent Sampling" off
         #since the sampling modes are supposed to be mutually 
         #exlusive. Set bit [23] to 0 (Zero-Indexed)
-        current = board.pci.read(BOARD_ID, 0x9040)[0]
-        mask = 0xF7FFFFFF
-        new = current & mask
+        current = int(board.pci.read(BOARD_ID, reg="0x9040", decimal=True)[0])
+        mask = 0xFF7FFFFF
+        new = str(hex(current & mask))
 
         if mode == 0:
             #normal mode
-            board.pci.write(BOARD_ID, 30000, 0x9044) 
-            board.pci.write(BOARD_ID, 402000, 0x9064) 
-            board.pci.write(BOARD_ID, 0000, 0x9044) 
-            board.pci.write(BOARD_ID, new, 0x9040) 
+            board.pci.write(BOARD_ID, "30000", "0x9044") 
+            board.pci.write(BOARD_ID, "402000", "0x9064") 
+            board.pci.write(BOARD_ID, "0000", "0x9044") 
+            board.pci.write(BOARD_ID, new, "0x9040") 
             #print("Sampling Mode Changed to 'Normal Mode'")
         elif mode == 1:
             #Equivalent Sampling mode
             #print("Sampling Mode Changed to 'Equivalent Timesampling'")
             #mask = 0b00000000100000000000000000000000
             #Set bits [23] (Zero-Indexed)
-            mask = 0x8000000
-            new = current | mask
-            board.pci.write(BOARD_ID, new, 0x9040) 
+            mask = 0x800000
+            new = str(hex(current | mask))
+            board.pci.write(BOARD_ID, new, "0x9040") 
         elif mode == 2:
             #Test Pattern
-            board.pci.write(BOARD_ID, 30000, 0x9044) 
-            board.pci.write(BOARD_ID, 403000, 0x9064) 
-            board.pci.write(BOARD_ID, 0000, 0x9044) 
-            board.pci.write(BOARD_ID, new, 0x9040) 
+            board.pci.write(BOARD_ID, "30000", "0x9044") 
+            board.pci.write(BOARD_ID, "403000", "0x9064") 
+            board.pci.write(BOARD_ID, "0000", "0x9044") 
+            board.pci.write(BOARD_ID, new, "0x9040") 
             #print("Sampling Mode Changed to 'Test Pattern'")
 
 
 
     def _activateDummyData(self):
-        current = board.pci.read(BOARD_ID, 0x9040)[0]
+        current = int(board.pci.read(BOARD_ID, reg="0x9040", decimal=True)[0])
         if self.dummyDataCheckbox.isChecked():
-            #mask = 0b00001010000000000000000000000000
-            #Set bits [25] and [27] (Zero-Indexed)
-            mask = 0xa000000
-            new = current | mask
-            board.pci.write(BOARD_ID, new, 0x9040) 
+            self.modeDropdown.setEnabled(False)
+            #mask = 0b00000010000000000000000000000000
+            #Set bits [25] (Zero-Indexed)
+            mask = 0x2000000
+            new = str(hex(current | mask))
+            board.pci.write(BOARD_ID, new, "0x9040") 
             #print("Activate Dummy Data")
         else:
-            #mask = 0b00001010000000000000000000000000
-            #Remove bits [25] and [27] (Zero-Indexed)
-            mask = 0xF5FFFFFF
-            new = current & mask
-            board.pci.write(BOARD_ID, new, 0x9040) 
+            self.modeDropdown.setEnabled(True)
+            #mask = 0b00000010000000000000000000000000
+            #Remove bits [25] (Zero-Indexed)
+            mask = 0xFDFFFFFF
+            new = str(hex(current & mask))
+            board.pci.write(BOARD_ID, new, "0x9040") 
             #print("Deactivate Dummy Data")