Commit 3fdd3752819eebd83bcef61001a977c41c93dd9e

Authored by Brice Colombier
1 parent 7883623b28
Exists in master

Added board commands

Showing 1 changed file with 34 additions and 7 deletions

Boards_management/board_commands.py View file @ 3fdd375
... ... @@ -26,16 +26,26 @@
26 26  
27 27 def reset_boards(self):
28 28 command = "softReset $dev\n\
29   - sendDaughterReset $dev\n\
30   - sendFabricReset $dev"
  29 +sendDaughterReset $dev\n\
  30 +sendFabricReset $dev"
31 31 return command
32 32  
33   - def select_DB_connection(self):
34   - command = "selectDaughterBoard $dev 2\n"
35   - return command
  33 + def select_DB_connection(self, port):
  34 + if port not in [1, 2]:
  35 + raise Exception ("Invalid port")
  36 + else:
  37 + command = "selectDaughterBoard $dev "+str(port)+"\n"
  38 + return command
36 39  
37   - def get_response(self):
38   - command = "sendFabricCommand $dev 4 7\n"
  40 + def generate_and_offload_response(self):
  41 + command = "sendFabricCommand $dev 4 7\n\
  42 +sendFabricCommand $dev 4 3\n\
  43 +set rep \"[sendFabricCommand $dev 5 3]\
  44 +[sendFabricCommand $dev 5 2]\
  45 +[sendFabricCommand $dev 5 1]\
  46 +[sendFabricCommand $dev 5 0]\"\n\
  47 +regsub -all { } $rep {} rep\n\
  48 +return $rep"
39 49 return command
40 50  
41 51 def poll_board(self):
... ... @@ -43,6 +53,18 @@
43 53 command = "getStatus $dev\n"
44 54 return command
45 55  
  56 + def get_parity_from_indices(self, indices):
  57 +
  58 + command = "sendFabricCommand $dev 4 5\n\
  59 +sendFabricCommand $dev 4 "+str(len(indices))+"\n"
  60 + indices_command = "\n".join(["sendFabricCommand $dev 4 "+str(i) for i in indices])+"\n"
  61 + final_command = "sendFabricCommand $dev 4 6\n\
  62 +return [expr [lindex [sendFabricCommand $dev 4 0] 1] & 1]"
  63 + return command+indices_command+final_command
  64 +
  65 + def disconnect(self):
  66 + command = "disconnect $dev\n"
  67 + return command
46 68  
47 69  
48 70 if __name__ == "__main__":
... ... @@ -51,4 +73,9 @@
51 73 Boardm = Board_manager()
52 74 r.eval(Boardm.source_tcl_package())
53 75 r.eval(Boardm.connect("COM3"))
  76 + r.eval(Boardm.select_DB_connection(2))
  77 + r.eval(Boardm.reset_boards())
  78 + print(r.eval(Boardm.generate_and_offload_response()))
  79 + r.eval(Boardm.get_parity_from_indices([0, 1, 2, 3]))
  80 + r.eval(Boardm.disconnect())