Commit c7f871dc88d988d38ed8170c46ab25e5767f979a

Authored by Brice Colombier
1 parent e49b36ce52
Exists in master

Reorganise directory

Showing 28 changed files with 1588 additions and 1624 deletions

... ... @@ -8,5 +8,5 @@
8 8 *.toc
9 9 *.xml
10 10 *.gz
11   -User_space/
  11 +user_space/
Boards_management/get_response.py View file @ c7f871d
  1 +# Author: Brice Colombier
  2 +# Laboratoire Hubert Curien
  3 +# 42000 Saint-Etienne - France
  4 +# Contact: b.colombier@univ-st-etienne.fr
  5 +# Project: Demonstrator
  6 +# File: get_parities_from_indices.py
  7 +# Date : 2016-10-12
  8 +
  9 +import Tkinter
  10 +
  11 +def get_response():
  12 +
  13 + """Get the parities of the on-board response blocks.
  14 +
  15 + Hardware-specific implementation.
  16 + >>> get_parities_from_indices([[1, 5], [7, 2], [3, 6], [4, 0]])
  17 + [0, 1, 1, 0]
  18 + """
  19 +
  20 + tclsh = Tkinter.Tcl()
  21 + parities = []
  22 + tclsh.eval("source {HECTOR_data_acq.tcl}")
  23 + tclsh.eval("set dev [openDevice COM5]")
  24 + tclsh.eval("puts \"Resetting the board\"")
  25 + tclsh.eval("softReset $dev")
  26 + tclsh.eval("sendDaughterReset $dev")
  27 + tclsh.eval("sendFabricReset $dev")
  28 + tclsh.eval("sendFabricCommand $dev 4 7") # generate response from LFSR
  29 + tclsh.eval("sendFabricCommand $dev 4 3") # offload response to MB
  30 + tclsh.eval("set rep \"[sendFabricCommand $dev 5 3] [sendFabricCommand $dev 5 2] [sendFabricCommand $dev 5 1] [sendFabricCommand $dev 5 0]\"") # Display response block 0
  31 + tclsh.eval("regsub -all { } $rep {} rep")
  32 + response = tclsh.eval("return $rep")
  33 + return response
  34 +
  35 +
  36 +if __name__ == "__main__":
  37 + print get_response()
CASCADE/get_parities_from_indices.py View file @ c7f871d
1   -# Author: Brice Colombier
2   -# Laboratoire Hubert Curien
3   -# 42000 Saint-Etienne - France
4   -# Contact: b.colombier@univ-st-etienne.fr
5   -# Project: Demonstrator
6   -# File: get_parities_from_indices.py
7   -# Date : 2016-10-12
8   -
9   -import Tkinter
10   -
11   -def get_parities_from_indices(indices, response_on_board):
12   -
13   - """Get the parities of the on-board response blocks.
14   -
15   - Hardware-specific implementation.
16   - >>> get_parities_from_indices([[1, 5], [7, 2], [3, 6], [4, 0]])
17   - [0, 1, 1, 0]
18   - """
19   -
20   - tclsh = Tkinter.Tcl()
21   - parities = []
22   - tclsh.eval("source {HECTOR_data_acq.tcl}")
23   - tclsh.eval("set dev [openDevice COM3]")
24   - tclsh.eval("puts \"Resetting the board\"")
25   - tclsh.eval("softReset $dev")
26   - tclsh.eval("sendDaughterReset $dev")
27   - tclsh.eval("sendFabricReset $dev")
28   - tclsh.eval("sendFabricCommand $dev 4 4") # generate automatic response
29   - tclsh.eval("sendFabricCommand $dev 4 3") # offload response to MB
30   - tclsh.eval("set rep \"[sendFabricCommand $dev 5 3] [sendFabricCommand $dev 5 2] [sendFabricCommand $dev 5 1] [sendFabricCommand $dev 5 0]\"") # Display response block 0
31   - tclsh.eval("regsub -all { } $rep {} rep")
32   - response = tclsh.eval("exit $rep")
33   - print response
34   -
35   -
36   -if __name__ == "__main__":
37   - print get_parities_from_indices([0, 1, 2, 3])
GUI/HECTOR_data_acq.tcl View file @ c7f871d
1   -##############################################################################
2   -#
3   -# Design unit: HECTOR TCL language extension
4   -#
5   -# File name: HECTOR_data_acq.tcl
6   -#
7   -# Description: TCL language extension providing high-level access to
8   -# communication interface with HECTOR evaluation boards.
9   -#
10   -# System: TCL v. 8.5 and higher
11   -#
12   -# Author: O. Petura - Hubert Curien Laboratory
13   -#
14   -# Copyright: Hubert Curien Laboratory, 2016
15   -#
16   -# Revision: Version 1.00, April 2016
17   -#
18   -##############################################################################
19   -
20   -
21   -# Timeout for the UART response in seconds
22   -set UART_timeout 5
23   -
24   -# Timeout between two consequent checks of UART input buffer
25   -set uart_check_timeout 100
26   -
27   -# Opens a connection to HECTOR evaluation board
28   -proc openDevice {dev {verbose 0}} {
29   -
30   - global tcl_platform
31   -
32   -# Append \\.\ to serial port number when we are running on Windows
33   - if {[string first "Win" $tcl_platform(os)] != -1} {
34   - set dev "\\\\.\\$dev"
35   - }
36   -
37   -# Open the serial device
38   - if { [catch { open $dev "r+" } fd ] } {
39   - if {$verbose != 0} {
40   - puts "Error opening device '$dev'\n Error description: $::errorInfo"
41   - }
42   - puts "Error opening device '$dev'"
43   - set ret -1
44   - } else {
45   -# Configure communication parameters
46   - fconfigure $fd -blocking 0 -buffering none -mode "115200,n,8,1" -translation binary -eofchar {}
47   -
48   -# Update the application status
49   - puts "Connection to '$dev' opened"
50   -
51   -# Create device handle
52   - set ret [list $dev $fd]
53   -
54   - }
55   -
56   - return $ret
57   -
58   -}
59   -
60   -# Disconnect from the HECTOR evaluation board
61   -proc disconnect {device} {
62   -
63   -# Close the connection to the serial device
64   - close [lindex $device 1]
65   -
66   -# Update the application status
67   - puts "Connection to '[lindex $device 0]' closed"
68   -}
69   -
70   -# Poll the serial device for input data
71   -proc pollDevice {device {verbose 0}} {
72   -
73   -# Read the input serial buffer
74   - set data [read [lindex $device 1]]
75   -
76   -# If there is something, process it
77   - if {[string length $data] != 0} {
78   - if {$verbose != 0} {
79   - puts "Received data: [toHEX $data]"
80   - }
81   -
82   -# Get the MSS status packet header offset
83   - set offset [string first "\x13\x57\x00\x00" $data]
84   - if {$offset != -1} {
85   -# Get the status fields
86   - set response [string range $data [expr $offset + 11] [expr $offset + 11]]
87   - set progress [string range $data [expr $offset + 8] [expr $offset + 8]]
88   - set aq_state [string range $data [expr $offset + 9] [expr $offset + 9]]
89   - set gpio [string range $data [expr $offset + 10] [expr $offset + 10]]
90   -
91   - binary scan $response c1 ret(response)
92   - binary scan $progress c1 ret(progress)
93   - binary scan $aq_state c1 ret(aq_state)
94   - set ret(gpio) [toHEX $gpio]
95   - return [list $ret(response) $ret(progress) $ret(aq_state) $ret(gpio)]
96   - } else {
97   -
98   -# Get the FPGA status packet header offset
99   - set offset [string first "\x13\xF5\x00\x00" $data]
100   - if {$offset != -1} {
101   -# Get the status fields
102   - set fpga_data [string range $data [expr $offset + 4] [expr $offset + 7]]
103   - set fpga_status [string range $data [expr $offset + 8] [expr $offset + 11]]
104   -
105   - set ret(fpga_data) [toHEX $fpga_data]
106   - set ret(fpga_status) [toHEX $fpga_status]
107   - return [list $ret(fpga_status) $ret(fpga_data)]
108   - }
109   - }
110   - } else {
111   - set ret(response) -1
112   - set ret(appError) 1
113   - return [list $ret(response) $ret(appError)]
114   - }
115   -
116   -}
117   -
118   -# Wait for a specified time
119   -proc wait_ms {ms} {
120   -
121   -# Create a variable name
122   - set varName finished_[clock clicks]
123   - global $varName
124   -
125   -# Set the variable after a specified timeout
126   - after $ms set $varName 1
127   -
128   -# Wait for the variable to be set
129   - vwait $varName
130   -
131   -# Clear the variable from memory
132   - unset $varName
133   -}
134   -
135   -# Convert a binary string to HEX
136   -proc toHEX {in} {
137   - set ret ""
138   - for {set i 0} {$i < [string length $in]} {incr i} {
139   - binary scan [string index $in $i] c1 byte
140   - if {$byte < 0} {set byte [expr 256 + $byte]}
141   - set HI [expr $byte >> 4]
142   - set LO [expr $byte & 15]
143   - switch $HI {
144   - 0 {append ret "0"}
145   - 1 {append ret "1"}
146   - 2 {append ret "2"}
147   - 3 {append ret "3"}
148   - 4 {append ret "4"}
149   - 5 {append ret "5"}
150   - 6 {append ret "6"}
151   - 7 {append ret "7"}
152   - 8 {append ret "8"}
153   - 9 {append ret "9"}
154   - 10 {append ret "A"}
155   - 11 {append ret "B"}
156   - 12 {append ret "C"}
157   - 13 {append ret "D"}
158   - 14 {append ret "E"}
159   - 15 {append ret "F"}
160   - }
161   - switch $LO {
162   - 0 {append ret "0"}
163   - 1 {append ret "1"}
164   - 2 {append ret "2"}
165   - 3 {append ret "3"}
166   - 4 {append ret "4"}
167   - 5 {append ret "5"}
168   - 6 {append ret "6"}
169   - 7 {append ret "7"}
170   - 8 {append ret "8"}
171   - 9 {append ret "9"}
172   - 10 {append ret "A"}
173   - 11 {append ret "B"}
174   - 12 {append ret "C"}
175   - 13 {append ret "D"}
176   - 14 {append ret "E"}
177   - 15 {append ret "F"}
178   - }
179   - }
180   - return $ret
181   -}
182   -
183   -# Function to convert HEX to DEC
184   -proc fromHEX {in} {
185   - set in_end [expr [string length $in] - 1]
186   - set ret 0
187   - for {set i $in_end} {$i >= 0} {incr i -1} {
188   - switch [string index $in $i] {
189   - "0" {set val 0}
190   - "1" {set val 1}
191   - "2" {set val 2}
192   - "3" {set val 3}
193   - "4" {set val 4}
194   - "5" {set val 5}
195   - "6" {set val 6}
196   - "7" {set val 7}
197   - "8" {set val 8}
198   - "9" {set val 9}
199   - "A" {set val 10}
200   - "B" {set val 11}
201   - "C" {set val 12}
202   - "D" {set val 13}
203   - "E" {set val 14}
204   - "F" {set val 15}
205   - }
206   - set ret [expr $ret + ($val * (16**($in_end - $i)))]
207   - }
208   - return $ret
209   -}
210   -
211   -# Function to read bit value from a specific bit field in decimal value
212   -proc getBitValue {decNumber bitFieldIndex} {
213   - return [expr ( $decNumber & (2**$bitFieldIndex) ) >> $bitFieldIndex]
214   -}
215   -
216   -# Bitwise XOR of two HEX values
217   -proc xorHEX { in1 in2 } {
218   - if { [string length $in1] != [string length $in2] } {
219   - return -1
220   - } else {
221   - set ret ""
222   - for {set i 0} {$i < [string length $in1]} {incr i} {
223   - set num1 [fromHEX [string index $in1 $i]]
224   - set num2 [fromHEX [string index $in2 $i]]
225   - set xor_val [expr $num1^$num2]
226   - if {$xor_val < 10} {
227   - set hex_val $xor_val
228   - } else {
229   - switch $xor_val {
230   - "10" {set hex_val "A"}
231   - "11" {set hex_val "B"}
232   - "12" {set hex_val "C"}
233   - "13" {set hex_val "D"}
234   - "14" {set hex_val "E"}
235   - "15" {set hex_val "F"}
236   - }
237   - }
238   - set ret "$ret$hex_val"
239   - }
240   - return $ret
241   - }
242   -}
243   -
244   -##############
245   -## COMMANDS ##
246   -##############
247   -
248   -proc getStatus {device {verbose 0}} {
249   - global UART_timeout
250   - global uart_check_timeout
251   -
252   - set data "\x13\xC0\x00\x00\x00\x00\x00\x00\x00\x00\x00\x07"
253   - puts -nonewline [lindex $device 1] $data
254   - if {$verbose != 0} {
255   - puts "Sending: [toHEX $data]"
256   - }
257   -
258   - set resp "-1 1"
259   - set start [clock seconds]
260   - while { [string match $resp "-1 1"] } {
261   - set resp [pollDevice $device $verbose]
262   - if { [clock seconds] > [expr $start + $UART_timeout] } {
263   - break
264   - }
265   - wait_ms $uart_check_timeout
266   - }
267   - set st1 $resp
268   -
269   - set data "\x13\xFB\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
270   - puts -nonewline [lindex $device 1] $data
271   - if {$verbose != 0} {
272   - puts "Sending: [toHEX $data]"
273   - }
274   -# Return the response of the command
275   - set resp "-1 1"
276   - set start [clock seconds]
277   - while { [string match $resp "-1 1"] } {
278   - set resp [pollDevice $device $verbose]
279   - if { [clock seconds] > [expr $start + $UART_timeout] } {
280   - break
281   - }
282   - wait_ms $uart_check_timeout
283   - }
284   - set st2 $resp
285   -
286   - set status [list [lindex $st1 0] [lindex $st1 1] [lindex $st1 2] [lindex $st1 3] [lindex $st2 0] [lindex $st2 1]]
287   -
288   - return $status
289   -}
290   -
291   -proc sendFabricCommand {device command data {verbose 0}} {
292   - global UART_timeout
293   - global uart_check_timeout
294   -
295   - set data "\x13\xFB\x00\x00[binary format I1 $data][binary format I1 $command]"
296   - puts -nonewline [lindex $device 1] $data
297   - if {$verbose != 0} {
298   - puts "Sending: [toHEX $data]"
299   - }
300   -# Return the response of the command
301   - set resp "-1 1"
302   - set start [clock seconds]
303   - while { [string match $resp "-1 1"] } {
304   - set resp [pollDevice $device $verbose]
305   - if { [clock seconds] > [expr $start + $UART_timeout] } {
306   - break
307   - }
308   - wait_ms $uart_check_timeout
309   - }
310   - return $resp
311   -}
312   -
313   -proc sendFabricReset {device {verbose 0}} {
314   - global UART_timeout
315   - global uart_check_timeout
316   -
317   - set data "\x13\xC0\x00\x00\x00\x00\x00\x00\x00\x00\x00\x04"
318   - puts -nonewline [lindex $device 1] $data
319   - if {$verbose != 0} {
320   - puts "Sending: [toHEX $data]"
321   - }
322   -# Return the response of the command
323   - set resp "-1 1"
324   - set start [clock seconds]
325   - while { [string match $resp "-1 1"] } {
326   - set resp [pollDevice $device $verbose]
327   - if { [clock seconds] > [expr $start + $UART_timeout] } {
328   - break
329   - }
330   - wait_ms $uart_check_timeout
331   - }
332   - return $resp
333   -}
334   -
335   -proc sendDaughterReset {device {verbose 0}} {
336   - global UART_timeout
337   - global uart_check_timeout
338   -
339   - set data "\x13\xC0\x00\x00\x00\x00\x00\x00\x00\x00\x00\x05"
340   - puts -nonewline [lindex $device 1] $data
341   - if {$verbose != 0} {
342   - puts "Sending: [toHEX $data]"
343   - }
344   -# Return the response of the command
345   - set resp "-1 1"
346   - set start [clock seconds]
347   - while { [string match $resp "-1 1"] } {
348   - set resp [pollDevice $device $verbose]
349   - if { [clock seconds] > [expr $start + $UART_timeout] } {
350   - break
351   - }
352   - wait_ms $uart_check_timeout
353   - }
354   - return $resp
355   -}
356   -
357   -proc mountDisk {device {verbose 0}} {
358   - global UART_timeout
359   - global uart_check_timeout
360   -
361   - set data "\x13\xC0\x00\x00\x00\x00\x00\x00\x00\x00\x00\x06"
362   - puts -nonewline [lindex $device 1] $data
363   - if {$verbose != 0} {
364   - puts "Sending: [toHEX $data]"
365   - }
366   -# Return the response of the command
367   - set resp "-1 1"
368   - set start [clock seconds]
369   - while { [string match $resp "-1 1"] } {
370   - set resp [pollDevice $device $verbose]
371   - if { [clock seconds] > [expr $start + $UART_timeout] } {
372   - break
373   - }
374   - wait_ms $uart_check_timeout
375   - }
376   - return $resp
377   -}
378   -
379   -proc createFileSystem {device {verbose 0}} {
380   - global UART_timeout
381   - global uart_check_timeout
382   -
383   - set data "\x13\xC0\x00\x00\x00\x00\x00\x00\x00\x00\x00\x08"
384   - puts -nonewline [lindex $device 1] $data
385   - if {$verbose != 0} {
386   - puts "Sending: [toHEX $data]"
387   - }
388   -# Return the response of the command
389   - set resp "-1 1"
390   - set start [clock seconds]
391   - while { [string match $resp "-1 1"] } {
392   - set resp [pollDevice $device $verbose]
393   - if { [clock seconds] > [expr $start + $UART_timeout] } {
394   - break
395   - }
396   - wait_ms $uart_check_timeout
397   - }
398   - return $resp
399   -}
400   -
401   -proc beginAcquisition {device filename size {verbose 0}} {
402   - global UART_timeout
403   - global uart_check_timeout
404   -
405   - set data "\x13\xFD\x00\x00$filename [binary format I1 $size]"
406   - puts -nonewline [lindex $device 1] $data
407   - if {$verbose != 0} {
408   - puts "Sending command: [toHEX $data]"
409   - }
410   -# Return the response of the command
411   - set resp "-1 1"
412   - set start [clock seconds]
413   - while { [string match $resp "-1 1"] } {
414   - set resp [pollDevice $device $verbose]
415   - if { [clock seconds] > [expr $start + $UART_timeout] } {
416   - break
417   - }
418   - wait_ms $uart_check_timeout
419   - }
420   - return $resp
421   -}
422   -
423   -proc loadInputFile {device filename size {verbose 0}} {
424   - global UART_timeout
425   - global uart_check_timeout
426   -
427   - set data "\x13\x3D\x00\x00$filename [binary format I1 $size]"
428   - puts -nonewline [lindex $device 1] $data
429   - if {$verbose != 0} {
430   - puts "Sending command: [toHEX $data]"
431   - }
432   -# Return the response of the command
433   - set resp "-1 1"
434   - set start [clock seconds]
435   - while { [string match $resp "-1 1"] } {
436   - set resp [pollDevice $device $verbose]
437   - if { [clock seconds] > [expr $start + $UART_timeout] } {
438   - break
439   - }
440   - wait_ms $uart_check_timeout
441   - }
442   - return $resp
443   -}
444   -
445   -proc configureGPIO {device GPIO {verbose 0}} {
446   - global UART_timeout
447   - global uart_check_timeout
448   -
449   - set data "\x13\xC0\x00\x00\x00\x00\x00\x00\x00\x00[binary format c1 $GPIO]\x09"
450   - puts -nonewline [lindex $device 1] $data
451   - if {$verbose != 0} {
452   - puts "Sending command: [toHEX $data]"
453   - }
454   -# Return the response of the command
455   - set resp "-1 1"
456   - set start [clock seconds]
457   - while { [string match $resp "-1 1"] } {
458   - set resp [pollDevice $device $verbose]
459   - if { [clock seconds] > [expr $start + $UART_timeout] } {
460   - break
461   - }
462   - wait_ms $uart_check_timeout
463   - }
464   - return $resp
465   -}
466   -
467   -proc setGPIO {device GPIO {verbose 0}} {
468   - global UART_timeout
469   - global uart_check_timeout
470   -
471   - set data "\x13\xC0\x00\x00\x00\x00\x00\x00\x00\x00[binary format c1 $GPIO]\x0A"
472   - puts -nonewline [lindex $device 1] $data
473   - if {$verbose != 0} {
474   - puts "Sending command: [toHEX $data]"
475   - }
476   -# Return the response of the command
477   - set resp "-1 1"
478   - set start [clock seconds]
479   - while { [string match $resp "-1 1"] } {
480   - set resp [pollDevice $device $verbose]
481   - if { [clock seconds] > [expr $start + $UART_timeout] } {
482   - break
483   - }
484   - wait_ms $uart_check_timeout
485   - }
486   - return $resp
487   -}
488   -
489   -proc softReset {device {verbose 0}} {
490   - global UART_timeout
491   - global uart_check_timeout
492   -
493   - set data "\x13\xC0\x00\x00\x00\x00\x00\x00\x00\x00\x00\x0B"
494   - puts -nonewline [lindex $device 1] $data
495   - if {$verbose != 0} {
496   - puts "Sending command: [toHEX $data]"
497   - }
498   -# Return the response of the command
499   - set resp "-1 1"
500   - set start [clock seconds]
501   - while { [string match $resp "-1 1"] } {
502   - set resp [pollDevice $device $verbose]
503   - if { [clock seconds] > [expr $start + $UART_timeout] } {
504   - break
505   - }
506   - wait_ms $uart_check_timeout
507   - }
508   - return $resp
509   -}
510   -
511   -# board =
512   -# 1 - HDMI
513   -# 2 - SATA
514   -proc selectDaughterBoard {device board {verbose 0}} {
515   - global UART_timeout
516   - global uart_check_timeout
517   -
518   - if { $board == 1 } {
519   - set command 2
520   - } elseif { $board == 2 } {
521   - set command 3
522   - } else {
523   - set command 0
524   - }
525   - set data "\x13\xFB\x00\x00\x00\x00\x00\x00[binary format I1 $command]"
526   - puts -nonewline [lindex $device 1] $data
527   - if {$verbose != 0} {
528   - puts "Sending command: [toHEX $data]"
529   - }
530   -# Return the response of the command
531   - set resp "-1 1"
532   - set start [clock seconds]
533   - while { [string match $resp "-1 1"] } {
534   - set resp [pollDevice $device $verbose]
535   - if { [clock seconds] > [expr $start + $UART_timeout] } {
536   - break
537   - }
538   - wait_ms $uart_check_timeout
539   - }
540   - return $resp
541   -}
542   -
543   -###########################
544   -## Application functions ##
545   -###########################
546   -
547   -# Find the connected disk drives
548   -proc findDiskDrives {} {
549   - global tcl_platform
550   -
551   - set drives ""
552   -
553   - if {[string match $tcl_platform(os) "Linux"]} {
554   - if { [catch {exec blkid} disks] } {
555   - puts "blkid is not available. Automatic disk recognition is impossible."
556   - return -1
557   - } else {
558   - set disks [split $disks "\n"]
559   - foreach disk $disks {
560   - set uuid_offset [string first "UUID=" $disk]
561   - set device [string range $disk 0 [expr [string first ":" $disk] - 1]]
562   -# Get the mountpoint
563   - set mountpoint ""
564   - set f [open "/proc/mounts" "r"]
565   - while { [gets $f line] >= 0} {
566   - if {[string first $device $line] != -1} {
567   - set mountpoint [lindex $line 1]
568   - break
569   - }
570   - }
571   - close $f
572   -
573   - if { $uuid_offset != -1 } {
574   - set uuidStart [expr $uuid_offset + 5]
575   - set uuidEnd [string first "\"" $disk [expr $uuidStart + 1]]
576   - set uuidString [string range $disk [expr $uuidStart + 1] [expr $uuidEnd - 1]]
577   - lappend drives [list $device $uuidString $mountpoint]
578   - }
579   - }
580   - }
581   - } elseif {[string first "Win" $tcl_platform(os)] != -1} {
582   - set disks [file volumes]
583   - foreach disk $disks {
584   - set disk [string range $disk 0 end-1]
585   - if {[catch {exec cmd /c vol $disk} resp]} {
586   - continue
587   - } else {
588   - set disk [string range $disk 0 end-1]
589   - set uuidString [string range $resp end-8 end]
590   - lappend drives [list $disk $uuidString "$disk:/"]
591   - }
592   - }
593   - } else {
594   - puts "Only linux and windows platforms are supported for the moment"
595   - return -1
596   - }
597   -
598   - return $drives
599   -}
600   -
601   -# Find HECTOR disk
602   -proc findHECTOR {{timeout 5}} {
603   - set start [clock seconds]
604   - set hectorDrive 0
605   -
606   - while { $hectorDrive == 0 && [expr [clock seconds] - $start] < $timeout} {
607   - set disks [findDiskDrives]
608   - foreach disk $disks {
609   - if { [string match "48A1-0000" [lindex $disk 1]] } {
610   - set hectorDrive $disk
611   - break
612   - }
613   - }
614   - wait_ms 100
615   - }
616   - return $hectorDrive
617   -}
618   -
619   -# Sync filesystem
620   -proc syncDrives {} {
621   - global tcl_platform
622   -
623   - if {[string match $tcl_platform(os) "Linux"]} {
624   - if { [catch {exec sync} ret] } {
625   - puts "Disk sync failed."
626   - return -1
627   - } else {
628   - return 0
629   - }
630   - } elseif {[string first "Win" $tcl_platform(os)] != -1} {
631   - if { [catch {exec "sync.exe"} ret] } {
632   - puts "Disk sync failed."
633   - return -1
634   - } else {
635   - return 0
636   - }
637   - } else {
638   - puts "Only linux and windows platforms are supported for the moment"
639   - return -1
640   - }
641   -}
642   -
643   -proc acquireData {device filename filesize {interface 0} {debug 0}} {
644   - global tcl_platform
645   -
646   -
647   -# Reset the FPGA controller
648   - set err [softReset $device $debug]
649   - if {[lindex $err 0] != 0} {
650   - puts "Soft reset failed with code $err"
651   - return $err
652   - }
653   -
654   -# Set the right interface
655   -# 0 = SATA
656   -# 1 = HDMI
657   - if { $interface == 0 } {
658   - set err [sendFabricCommand $device 3]
659   - if { [lindex $err 0] != 0 } {
660   - puts "Interface set error. Code: $err"
661   - }
662   - } elseif { $interface == 1 } {
663   - set err [sendFabricCommand $device 4]
664   - if { [lindex $err 0] != 0 } {
665   - puts "Interface set error. Code: $err"
666   - }
667   - }
668   -
669   -# Reset the daugther module
670   - set err [sendDaughterReset $device $debug]
671   - if {[lindex $err 0] != 0} {
672   - puts "Daughter reset failed with code $err"
673   - return $err
674   - }
675   -
676   -# Create filesystem
677   - set err [createFileSystem $device $debug]
678   - if {[lindex $err 0] != 0 } {
679   - puts "Filesystem creation failed with code $err"
680   - return $err
681   - }
682   -
683   -## Create a progressbar
684   -# set progressbar {[=====|=====|=====|=====]}
685   -# puts $progressbar
686   -# set progressStep [expr 100.0 / ([string length $progressbar] - 2)]
687   -
688   -# Start the measurement
689   - set err [beginAcquisition $device ACQ $filesize]
690   - if {[lindex $err 0] != 0 } {
691   - puts "Acquisition failed to start. Error code: $err"
692   - return $err
693   - }
694   -
695   -# set progress 0
696   -# puts -nonewline {[}
697   -# flush stdout
698   - while {[lindex $err 2] != 0} {
699   - set err [getStatus $device $debug]
700   - if {[lindex $err 0] != 0 } {
701   - puts "An error occured during data acquisition. Error code: $err"
702   - return $err
703   - } else {
704   - puts -nonewline "[lindex $err 1] %\r"
705   - flush stdout
706   - #if { [lindex $err 1] > $progress } {
707   - # set steps [expr ([lindex $err 1] - $progress) / $progressStep]
708   - # if { $steps >= 1 } {
709   - # set progress [expr $progress + ( floor($steps) * $progressStep)]
710   - # #puts "$progress - $steps"
711   - # for {set i 0} {$i < [expr floor($steps)]} {incr i} {
712   - # puts -nonewline "#"
713   - # flush stdout
714   - # }
715   - # }
716   - #}
717   - }
718   - }
719   - puts {}
720   - flush stdout
721   -
722   -# Mount the disk
723   - set err [mountDisk $device $debug]
724   - if {[lindex $err 0] != 0} {
725   - puts "Mounting disk failed with error code $err"
726   - return $err
727   - }
728   -
729   -# Search for the hector disk
730   - set hectorDrive [findHECTOR 5]
731   -
732   - if { $hectorDrive == 0 } {
733   - puts "Hector disk drive not found. You will have to search for it manually."
734   - return 1
735   - }
736   -
737   -# Check for the mountpoint
738   - if { [string length [lindex $hectorDrive 2]] == 0 } {
739   - puts "Hector disk drive is not mounted. Please mount the device [lindex $hectorDrive 0]."
740   - return 1
741   - }
742   -
743   -# Copy the file from hector disk to the PC
744   - if { [string match $tcl_platform(os) "Linux"] } {
745   - puts [lindex $hectorDrive 2]/ACQ
746   - file copy -force [lindex $hectorDrive 2]/ACQ $filename
747   - } elseif { [string first $tcl_platform(os) "Win"] != -1 } {
748   - file copy -force {"[lindex $hectorDrive 2]/ACQ"} $filename
749   - }
750   -
751   - puts "Acquired data are available in the file $filename"
752   -
753   - return 0
754   -}
GUI/LICENSE.txt View file @ c7f871d
1   -MIT License
2   -
3   -Copyright (c) 2016 Brice Colombier, Lilian Bossuet, David Hély
4   -
5   -Permission is hereby granted, free of charge, to any person obtaining a copy
6   -of this software and associated documentation files (the "Software"), to deal
7   -in the Software without restriction, including without limitation the rights
8   -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9   -copies of the Software, and to permit persons to whom the Software is
10   -furnished to do so, subject to the following conditions:
11   -
12   -The above copyright notice and this permission notice shall be included in all
13   -copies or substantial portions of the Software.
14   -
15   -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16   -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17   -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18   -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19   -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20   -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21   -SOFTWARE.
GUI/add_frame_elements.py View file @ c7f871d
1   -# Author: Brice Colombier
2   -# Laboratoire Hubert Curien
3   -# 42000 Saint-Etienne - France
4   -# Contact: b.colombier@univ-st-etienne.fr
5   -# Project: Demonstrator
6   -# File: add_frame_elements.py
7   -# Date: 2016-10-13
8   -
9   -from Tkinter import *
10   -from ttk import *
11   -
12   -
13   -def add_frame_elements(self):
14   -
15   - """Add elements to frames of the GUI main window"""
16   -
17   - self.com_port_text = Label(self.motherboard_frame,
18   - text="COM port (ex: COM3)")
19   - self.com_port_text.pack(side=LEFT)
20   - self.com_port_entry = Entry(self.motherboard_frame,
21   - width=10,
22   - textvariable=self.com_port)
23   - self.com_port_entry.pack(side=LEFT)
24   - self.com_port_button_connect = Button(self.motherboard_frame,
25   - text="Connect",
26   - command=self.connect)
27   - self.com_port_button_connect.pack(side=LEFT)
28   - self.com_port_button_disconnect = Button(self.motherboard_frame,
29   - text="Disconnect",
30   - state=NORMAL,
31   - command=self.disconnect)
32   - self.com_port_button_disconnect.pack(side=LEFT)
33   - # ------------------------------------------------------
34   - self.reconciliation_parameters_label = Label(self.CASCADE_frame,
35   - text="Parameters:")
36   - self.reconciliation_parameters_label.grid(row=0, column=0)
37   - self.reconciliation_parameter_initial_block_size_label = Label(self.CASCADE_frame,
38   - text="Initial block size (bits):")
39   - self.reconciliation_parameter_initial_block_size_label.grid(row=0,
40   - column=1)
41   - self.reconciliation_parameter_initial_block_size_spinbox = Spinbox(self.CASCADE_frame,
42   - values=(4, 8, 16, 32, 64),
43   - width=3,
44   - state="normal")
45   - self.reconciliation_parameter_initial_block_size_spinbox.grid(row=0,
46   - column=2)
47   - self.reconciliation_parameter_number_of_passes_label=Label(self.CASCADE_frame,
48   - text="Number of passes:")
49   - self.reconciliation_parameter_number_of_passes_label.grid(row=1,
50   - column=1,
51   - sticky=E)
52   - self.reconciliation_parameter_number_of_passes_spinbox=Spinbox(self.CASCADE_frame,
53   - from_=1,
54   - to=25,
55   - width=3,
56   - state="normal")
57   - self.reconciliation_parameter_number_of_passes_spinbox.grid(row=1,
58   - column=2)
59   - self.perform_reconciliation_button=Button(self.CASCADE_frame,
60   - text="Perform reconciliation",
61   - state="normal")
62   - self.perform_reconciliation_button.grid(row=0,
63   - column=3,
64   - rowspan=2,
65   - padx=10)
66   - self.get_reference_response_button=Button(self.get_PUF_reference_response_frame,
67   - text="Get/update reference response",
68   - command=self.get_PUF_reference_response,
69   - width=28,
70   - state="normal")
71   - self.get_reference_response_button.pack(side=LEFT)
72   - self.reference_response_label=Label(self.get_PUF_reference_response_frame,
73   - textvariable=self.PUF_reference_response_displayed,
74   - font=("Courier", 8),
75   - background="white")
76   - self.reference_response_label.pack(side=LEFT, padx=10, fill="x")
77   - self.derive_key_button=Button(self.key_derivation_frame,
78   - text="Derive a key from the response",
79   - command=self.derive_key_from_response,
80   - width=28,
81   - state="normal")
82   - self.derive_key_button.pack(side=LEFT)
83   - self.key_saved_label=Label(self.key_derivation_frame,
84   - textvariable=self.message_key_saved)
85   - self.key_saved_label.pack(side=LEFT)
86   - # ------------------------------------------------------
87   - self.design_label=Label(self.file_frame,
88   - text="Design:")
89   - self.design_label.grid(row=0, column=0, sticky=E)
90   - self.format_label=Label(self.file_frame,
91   - text="Format:")
92   - self.format_label.grid(row=1, column=0, sticky=E)
93   - self.filename_entry=Entry(self.file_frame,
94   - textvariable=self.filename, width=100)
95   - self.filename_entry.grid(row=0, column=1, columnspan=2, sticky="EW")
96   - self.button_open_design=Button(self.file_frame,
97   - text="Search...",
98   - command=self.select_file)
99   - self.button_open_design.grid(row=0, column=3)
100   - self.choose_design_format_option_menu = OptionMenu(self.file_frame, self.design_format, "BENCH", "BENCH", "BLIF", "SLIF", "EDIF", "Xilinx EDIF", "VHDL Dataflow", "VHDL Structural", "Verilog Dataflow", "Verilog Structural")
101   - self.choose_design_format_option_menu.grid(row=1, column=1, sticky=W)
102   - self.build_graph_button=Button(self.file_frame,
103   - text="Build graph",
104   - command=self.build_graph,
105   - state="normal")
106   - self.build_graph_button.grid(row=2, column=0)
107   - self.graph_info_label=Label(self.file_frame,
108   - textvariable=self.graph_info)
109   - self.graph_info_label.grid(row=2, column=1, sticky=W)
110   - # -------------------------------------------------------
111   - self.locking_button=Checkbutton(self.modify_design_frame,
112   - text="Locking with",
113   - variable=self.locking,
114   - state="normal")
115   - self.locking_button.grid(row=0, column=0, sticky=W)
116   - self.masking_button=Checkbutton(self.modify_design_frame,
117   - text="Masking with",
118   - variable=self.masking,
119   - state="normal")
120   - self.masking_button.grid(row=1, column=0, sticky=W)
121   - self.locking_overhead_spinbox=Spinbox(self.modify_design_frame,
122   - from_=1,
123   - to=100,
124   - width=4,
125   - textvariable=self.locking_overhead,
126   - state="normal")
127   - self.locking_overhead_spinbox.grid(row=0, column=1)
128   - self.masking_overhead_spinbox=Spinbox(self.modify_design_frame,
129   - from_=1,
130   - to=100,
131   - width=4,
132   - textvariable=self.masking_overhead,
133   - state="normal")
134   - self.masking_overhead_spinbox.grid(row=1, column=1)
135   - self.locking_overhead_label=Label(self.modify_design_frame,
136   - text="% area overhead")
137   - self.locking_overhead_label.grid(row=0, column=2, sticky=W)
138   - self.masking_overhead_label=Label(self.modify_design_frame,
139   - text="% area overhead using heuristic:")
140   - self.masking_overhead_label.grid(row=1, column=2)
141   - self.masking_heuristic_radio_button_random=Radiobutton(self.modify_design_frame,
142   - text="Random",
143   - variable=self.masking_heuristic,
144   - value="random")
145   - self.masking_heuristic_radio_button_random.grid(row=1,
146   - column=3,
147   - sticky=W,
148   - padx=5)
149   - self.masking_heuristic_radio_button_betweenness=Radiobutton(self.modify_design_frame,
150   - text="Betweenness",
151   - variable=self.masking_heuristic,
152   - value="betweenness")
153   - self.masking_heuristic_radio_button_betweenness.grid(row=2,
154   - column=3,
155   - sticky=W,
156   - padx=5)
157   - self.masking_heuristic_radio_button_closeness=Radiobutton(self.modify_design_frame,
158   - text="Closeness",
159   - variable=self.masking_heuristic,
160   - value="closeness")
161   - self.masking_heuristic_radio_button_closeness.grid(row=3,
162   - column=3,
163   - sticky=W,
164   - padx=5)
165   - self.masking_heuristic_radio_button_current_flow_betweenness=Radiobutton(self.modify_design_frame,
166   - text="Current-flow betweenness",
167   - variable=self.masking_heuristic,
168   - value="current_flow_betweenness")
169   - self.masking_heuristic_radio_button_current_flow_betweenness.grid(row=1,
170   - column=4,
171   - sticky=W,
172   - padx=5)
173   - self.masking_heuristic_radio_button_current_flow_closeness=Radiobutton(self.modify_design_frame,
174   - text="Current-flow closeness",
175   - variable=self.masking_heuristic,
176   - value="current_flow_loseness")
177   - self.masking_heuristic_radio_button_current_flow_closeness.grid(row=2,
178   - column=4,
179   - sticky=W,
180   - padx=5)
181   - self.masking_heuristic_radio_button_approximate_current_flow_betweenness=Radiobutton(self.modify_design_frame,
182   - text="Approximate current-flow betweenness",
183   - variable=self.masking_heuristic,
184   - value="approximate_current_flow_betweenness")
185   - self.masking_heuristic_radio_button_approximate_current_flow_betweenness.grid(row=3,
186   - column=4,
187   - sticky=W,
188   - padx=5)
189   - self.modify_design_button=Button(self.modify_design_frame,
190   - text="Modify design",
191   - state="normal",
192   - command=self.modify_design)
193   - self.modify_design_button.grid(row=2, column=0)
194   - # -------------------------------------------------------
195   - self.generated_design_format_label = Label(self.generate_modified_design_frame,
196   - text="Output format:")
197   - self.generated_design_format_label.grid(row=0,
198   - column=0,
199   - sticky=E)
200   - self.generated_design_format_bench = Radiobutton(self.generate_modified_design_frame,
201   - text=".txt",
202   - variable=self.generated_design_format,
203   - value="bench")
204   - self.generated_design_format_bench.grid(row=0,
205   - column=1,
206