From f413dcf16a6d606afd9babb3dac759d3189d70b0 Mon Sep 17 00:00:00 2001 From: Maps Date: Sun, 24 Mar 2024 12:14:57 +0100 Subject: [PATCH] Started making a better scurve routine. --- analysis/mbs/dabc/plugins/hadaq/hldprint.cxx | 29 ++ scripts/Mimosis.pm | 478 +++++++++++++++++-- scripts/cli/mimosis | 289 ++--------- 3 files changed, 508 insertions(+), 288 deletions(-) create mode 100644 analysis/mbs/dabc/plugins/hadaq/hldprint.cxx diff --git a/analysis/mbs/dabc/plugins/hadaq/hldprint.cxx b/analysis/mbs/dabc/plugins/hadaq/hldprint.cxx new file mode 100644 index 0000000..16da414 --- /dev/null +++ b/analysis/mbs/dabc/plugins/hadaq/hldprint.cxx @@ -0,0 +1,29 @@ +#include +#include +#include "hadaq/api.h" + +int main(int argc, char* argv[]) { + + std::string src = argv[1]; + hadaq::ReadoutHandle ref = hadaq::ReadoutHandle::Connect(src.c_str()); + if (ref.null()) return 1; + hadaq::RawEvent *evnt = nullptr; + + while (true) { + evnt = ref.NextEvent(1.,-1); + if (!evnt) continue; + hadaq::RawSubevent* sub = nullptr; + + while ((sub = evnt->NextSubevent(sub)) != nullptr) { + // evnt->Dump(); + // sub->PrintRawData(); + unsigned size = sub->GetNrOfDataWords(); + for( unsigned i = 0; iData(i)); + } + } + } + + ref.Disconnect(); + return 0; +} diff --git a/scripts/Mimosis.pm b/scripts/Mimosis.pm index 5eeaab9..f28e0b6 100755 --- a/scripts/Mimosis.pm +++ b/scripts/Mimosis.pm @@ -7,6 +7,7 @@ use Time::HiRes qw(usleep); use Time::HiRes qw( time ); use Term::ANSIColor; use Data::Dump qw(dump); +use POSIX; my $adc_addr = 0x48; @@ -715,12 +716,9 @@ sub mimosis_scan_region my $fpga = $params{'fpga'}; my $pulseonly = $params{'pulseonly'}; my $region = $params{'region'}; - my $firstrow = $params{'firstrow'}; - my $lastrow = $params{'lastrow'}; - my $rowdiv = $params{'rowdiv'}; - my $firstcol = $params{'firstcol'}; - my $lastcol = $params{'lastcol'}; - my $coldiv = $params{'coldiv'}; + my $firstRow = $params{'firstRow'}; + my $lastRow = $params{'lastRow'}; + my $rowDiv = $params{'rowDiv'}; my $firstset = $params{'firstset'}; my $lastset = $params{'lastset'}; my $setdiv = $params{'setdiv'}; @@ -768,19 +766,16 @@ sub mimosis_scan_region my $regBit = $regBitHash{$region}; - $firstrow = defined $firstrow ? $firstrow : 0; - $lastrow = defined $lastrow ? $lastrow : 504; - $rowdiv = defined $rowdiv ? $rowdiv : 1; - $firstcol = defined $firstcol ? $firstcol : $collim{$region}->[0]; - $lastcol = defined $lastcol ? $lastcol : $collim{$region}->[1]; - $coldiv = defined $coldiv ? $coldiv : 1; + $firstRow = defined $firstRow ? $firstRow : 0; + $lastRow = defined $lastRow ? $lastRow : 504; + $rowDiv = defined $rowDiv ? $rowDiv : 1; $firstset = defined $firstset ? $firstset : 0x0; $lastset = defined $lastset ? $lastset : 0xff; $setdiv = defined $setdiv ? $setdiv : 1; $settime = defined $settime ? $settime : 1000; $slow = defined $slow ? $slow : 10000; $a = defined $a ? $a : 0; - $rowsatonce = defined $rowsatonce ? $rowsatonce : $rowAdd{$region}; + $rowTrain = defined $rowTrain ? $rowTrain : $rowAdd{$region}; $printset = defined $printset ? 1 : 0; $printrow = defined $printrow ? 1 : 0; $printcol = defined $printcol ? 1 : 0; @@ -816,15 +811,22 @@ sub mimosis_scan_region Mimosis::mimosis_register_write( $fpga, 0x0177, $pixpulseD_B_msb, $a ); usleep($slow); Mimosis::mimosis_register_write( $fpga, 0x007d, $modpulse, $a ); usleep($slow); #set modpulse. possible values: 1f/1, 1f/2, 1f/4, 1f/8, 1f/16, 1f/32, 1f/64, 1f/128 + my $pipeNameWr = "/tmp/scurvepipewr"; + my $pipeNameRd = "/tmp/scurvepiperd"; + my $fdPipeWr = POSIX::open($pipeNameWr, &POSIX::O_WRONLY); my $rowcounter = 0; - for ( my $yi = $firstrow; $yi+$rowsatonce-1 <= $lastrow; $yi+=$rowsatonce*$rowdiv ) - { - for ( my $y = $yi; $y < $yi+$rowsatonce*$rowdiv; $y+=1 ) - { + for ( my $yi = $firstRow; + $yi+$rowTrain-1 <= $lastRow; + $yi+=$rowTrain*$rowDiv ) { + + for ( my $y = $yi; + $y < $yi+$rowTrain*$rowDiv; + $y+=1 ) { + $rowcounter = $rowcounter + 1; - if( ($rowcounter-1)%$rowdiv != 0) { next; } + if( ($rowcounter-1)%$rowDiv != 0) { next; } my $rAddrR = $y/8; my $bitR = $y%8; @@ -837,34 +839,30 @@ sub mimosis_scan_region Mimosis::mimosis_instr_write( $fpga, 0x05 ); usleep($slow); #INSTR set mask pulse Mimosis::mimosis_register_write( $fpga, 0x4087, 0x0, $a ); usleep($slow); #unselect all pixels (register wise) Mimosis::mimosis_instr_write( $fpga, 0x3e ); usleep($slow); #INSTR unselect all pixels + } - # my $colcounter = 0; - - # for( my $x = $firstcol; $x <= $lastcol; $x+=1 ) - # { - # $colcounter = $colcounter + 1; - # if( ($colcounter-1)%$coldiv != 0) { next; } - - # my $rAddrC = $x/16; #region address - # my $bitC = ($x/2)%8; #double column in region - # my $add_regC = ($rAddrC << 8); - # if (($x%2 == 1)) { $add_regC += 0x82; } - # elsif (($x%2 == 0)) { $add_regC += 0x81; } - - # Mimosis::mimosis_register_write( $fpga, $add_regC, ( 0x1 << $bitC ), $a ); usleep($slow); - # Mimosis::mimosis_register_write( $fpga, $add_regR, ( 0x1 << $bitR ), $a ); usleep($slow); - # Mimosis::mimosis_instr_write( $fpga, 0x05 ); usleep($slow); #INSTR set mask pulse - # Mimosis::mimosis_register_write( $fpga, 0x4087, 0x0, $a ); usleep($slow); #unselect all pixels (register wise) - - # if( $printcol || $printall ) { printf("col: $x\n"); } - # } + my $frameWr = "START-" . $yi . "-" . $rowTrain . "-END"; + POSIX::write($fdPipeWr,$frameWr,length($frameWr)); + + print "Data sent.\n"; + print "Waiting for ACK\n"; + + my $fdPipeRd = POSIX::open($pipeNameRd); + my $frameRd; + my $reading = 1; + while($reading) { + my $buf; + my $bytes = POSIX::read($fdPipeRd,$buf,1); + $frameRd .= $buf; + if($frameRd =~ /ACK/) { + $reading = 0; + } } + POSIX::close($fdPipeRd); - unless($pulseonly) - { + unless($pulseonly) { my $setcounter = 0; - for my $set (reverse ($firstset .. $lastset) ) - { + for my $set (reverse ($firstset .. $lastset) ) { $setcounter = $setcounter + 1; if( ($setcounter-1)%$setdiv != 0) { next; } @@ -884,10 +882,182 @@ sub mimosis_scan_region +# sub mimosis_scan_region +# { +# my %params = @_; + +# my $fpga = $params{'fpga'}; +# my $pulseonly = $params{'pulseonly'}; +# my $region = $params{'region'}; +# my $firstrow = $params{'firstrow'}; +# my $lastrow = $params{'lastrow'}; +# my $rowdiv = $params{'rowdiv'}; +# my $firstcol = $params{'firstcol'}; +# my $lastcol = $params{'lastcol'}; +# my $coldiv = $params{'coldiv'}; +# my $firstset = $params{'firstset'}; +# my $lastset = $params{'lastset'}; +# my $setdiv = $params{'setdiv'}; +# my $settime = $params{'settime'}; +# my $slow = $params{'slow'}; +# my $a = $params{'a'}; +# my $rowsatonce = $params{'rowsatonce'}; +# my $printset = $params{'printset'}; +# my $printrow = $params{'printrow'}; +# my $printcol = $params{'printcol'}; +# my $printall = $params{'printall'}; +# my $analogAlimA = $params{'analogAlimA'}; +# my $analogAlimB = $params{'analogAlimB'}; +# my $analogDlimA = $params{'analogDlimA'}; +# my $analogDlimB = $params{'analogDlimB'}; +# my $modpulse = $params{'modpulse'}; + + +# defined $fpga or die "Mimosis::mimosis_scan_region: Must provide $fpga."; +# defined $region or die "Mimosis::mimosis_scan_region: Must provide $region."; + + +# my %collim = ( +# 'A' => [ 0, 127 ], +# 'B' => [ 128, 511 ], +# 'C' => [ 512, 895 ], +# 'D' => [ 896, 1023 ] +# ); + +# my %rowAdd = ( +# 'A' => 4, +# 'B' => 2, +# 'C' => 2, +# 'D' => 4 +# ); + +# my %regBitHash = ( +# 'A' => 0, +# 'B' => 1, +# 'C' => 2, +# 'D' => 3 +# ); + + +# my $regBit = $regBitHash{$region}; + + +# $firstrow = defined $firstrow ? $firstrow : 0; +# $lastrow = defined $lastrow ? $lastrow : 504; +# $rowdiv = defined $rowdiv ? $rowdiv : 1; +# $firstcol = defined $firstcol ? $firstcol : $collim{$region}->[0]; +# $lastcol = defined $lastcol ? $lastcol : $collim{$region}->[1]; +# $coldiv = defined $coldiv ? $coldiv : 1; +# $firstset = defined $firstset ? $firstset : 0x0; +# $lastset = defined $lastset ? $lastset : 0xff; +# $setdiv = defined $setdiv ? $setdiv : 1; +# $settime = defined $settime ? $settime : 1000; +# $slow = defined $slow ? $slow : 10000; +# $a = defined $a ? $a : 0; +# $rowsatonce = defined $rowsatonce ? $rowsatonce : $rowAdd{$region}; +# $printset = defined $printset ? 1 : 0; +# $printrow = defined $printrow ? 1 : 0; +# $printcol = defined $printcol ? 1 : 0; +# $printall = defined $printall ? 1 : 0; +# $pixpulseA_A = defined $pixpulseA_A ? $pixpulseA_A : 25; +# $pixpulseA_B = defined $pixpulseA_B ? $pixpulseA_B : 75; +# $pixpulseD_A = defined $pixpulseD_A ? $pixpulseD_A : 0; +# $pixpulseD_B = defined $pixpulseD_B ? $pixpulseD_B : 0; +# $modpulse = defined $modpulse ? $modpulse : 3; + + +# my $pixpulseA_A_msb = ( $pixpulseA_A & 0xff00 ) >> 8; +# my $pixpulseA_A_lsb = $pixpulseA_A & 0x00ff; +# my $pixpulseA_B_msb = ( $pixpulseA_B & 0xff00 ) >> 8; +# my $pixpulseA_B_lsb = $pixpulseA_B & 0x00ff; +# my $pixpulseD_A_msb = ( $pixpulseD_A & 0xff00 ) >> 8; +# my $pixpulseD_A_lsb = $pixpulseD_A & 0x00ff; +# my $pixpulseD_B_msb = ( $pixpulseD_B & 0xff00 ) >> 8; +# my $pixpulseD_B_lsb = $pixpulseD_B & 0x00ff; + + +# Mimosis::mimosis_register_write( $fpga, 0x0020, 0x40, $a ); usleep($slow); #EN_PIXELMASK to 0 for pulse +# Mimosis::mimosis_instr_write( $fpga, 0x3f ); usleep($slow); #INSTR select all pixels +# Mimosis::mimosis_instr_write( $fpga, 0x04 ); usleep($slow); #INSTR reset mask +# Mimosis::mimosis_instr_write( $fpga, 0x3e ); usleep($slow); #INSTR unselect all pixels +# Mimosis::mimosis_register_write( $fpga, 0x0066, $pixpulseA_A_lsb, $a ); usleep($slow); #analog pulsing pulse A, limit A +# Mimosis::mimosis_register_write( $fpga, 0x0166, $pixpulseA_A_msb, $a ); usleep($slow); +# Mimosis::mimosis_register_write( $fpga, 0x0076, $pixpulseA_B_lsb, $a ); usleep($slow); # analog pulsing pulse A, limit B +# Mimosis::mimosis_register_write( $fpga, 0x0176, $pixpulseA_B_msb, $a ); usleep($slow); +# Mimosis::mimosis_register_write( $fpga, 0x0067, $pixpulseD_A_lsb, $a ); usleep($slow); # analog pulsing pulse D, limit A +# Mimosis::mimosis_register_write( $fpga, 0x0167, $pixpulseD_A_msb, $a ); usleep($slow); +# Mimosis::mimosis_register_write( $fpga, 0x0077, $pixpulseD_B_lsb, $a ); usleep($slow); # analog pulsing pulse D, limit B +# Mimosis::mimosis_register_write( $fpga, 0x0177, $pixpulseD_B_msb, $a ); usleep($slow); +# Mimosis::mimosis_register_write( $fpga, 0x007d, $modpulse, $a ); usleep($slow); #set modpulse. possible values: 1f/1, 1f/2, 1f/4, 1f/8, 1f/16, 1f/32, 1f/64, 1f/128 + +# my $rowcounter = 0; + +# for ( my $yi = $firstrow; $yi+$rowsatonce-1 <= $lastrow; $yi+=$rowsatonce*$rowdiv ) { + +# for ( my $y = $yi; $y < $yi+$rowsatonce*$rowdiv; $y+=1 ) { + +# $rowcounter = $rowcounter + 1; +# if( ($rowcounter-1)%$rowdiv != 0) { next; } + +# my $rAddrR = $y/8; +# my $bitR = $y%8; +# my $add_regR = ( $rAddrR << 8 ) + 0x84; + +# if( $printrow || $printall ) { printf("row: $y\n"); } + +# Mimosis::mimosis_register_write( $fpga, $add_regR, ( 0x1 << $bitR ), $a ); usleep($slow); +# Mimosis::mimosis_instr_write( $fpga, 0x27 ); usleep($slow); #INSTR select all pixels +# Mimosis::mimosis_instr_write( $fpga, 0x05 ); usleep($slow); #INSTR set mask pulse +# Mimosis::mimosis_register_write( $fpga, 0x4087, 0x0, $a ); usleep($slow); #unselect all pixels (register wise) +# Mimosis::mimosis_instr_write( $fpga, 0x3e ); usleep($slow); #INSTR unselect all pixels + +# # my $colcounter = 0; + +# # for( my $x = $firstcol; $x <= $lastcol; $x+=1 ) +# # { +# # $colcounter = $colcounter + 1; +# # if( ($colcounter-1)%$coldiv != 0) { next; } + +# # my $rAddrC = $x/16; #region address +# # my $bitC = ($x/2)%8; #double column in region +# # my $add_regC = ($rAddrC << 8); +# # if (($x%2 == 1)) { $add_regC += 0x82; } +# # elsif (($x%2 == 0)) { $add_regC += 0x81; } + +# # Mimosis::mimosis_register_write( $fpga, $add_regC, ( 0x1 << $bitC ), $a ); usleep($slow); +# # Mimosis::mimosis_register_write( $fpga, $add_regR, ( 0x1 << $bitR ), $a ); usleep($slow); +# # Mimosis::mimosis_instr_write( $fpga, 0x05 ); usleep($slow); #INSTR set mask pulse +# # Mimosis::mimosis_register_write( $fpga, 0x4087, 0x0, $a ); usleep($slow); #unselect all pixels (register wise) + +# # if( $printcol || $printall ) { printf("col: $x\n"); } +# # } +# } + +# unless($pulseonly) { +# my $setcounter = 0; +# for my $set (reverse ($firstset .. $lastset) ) { +# $setcounter = $setcounter + 1; +# if( ($setcounter-1)%$setdiv != 0) { next; } + +# my $pulseNumber = ($set << 24) + 0x00c00000 + ($regBit << 20) + $yi; +# trb_register_write_mem( $fpga, 0xa209, 0, [ $pulseNumber ], 1 ); usleep($slow); +# Mimosis::mimosis_register_write( $fpga, 0x0046, $set, $a ); usleep($settime); + +# if( $printset || $printall ) { printf("set: $set\n"); } +# } + +# Mimosis::mimosis_instr_write( $fpga, 0x3f ); usleep($slow); +# Mimosis::mimosis_instr_write( $fpga, 0x04 ); usleep($slow); #INSTR set mask pulse +# Mimosis::mimosis_instr_write( $fpga, 0x3e ); usleep($slow); #INSTR set mask pulse +# } +# } +# } + + + sub mimosis_scan_pixel { my %params = @_; - my $fpga = $params{'fpga'}; my $colpix = $params{'colpix'}; my $rowpix = $params{'rowpix'}; @@ -1292,6 +1462,228 @@ sub mimosis_mask +sub help_global { + my $message = <<'END_MESSAGE'; + =+- =*= + +*==: :##=- + -::::-:. .-:::=:. =+@*. .+@+- .-::::::::--:. + .= .*-. .=. :#=. .*%- .:-----------=%%=----*+. .:--. + .:- .*-..=: =*:..:%%==-::::::::::-#%-::==*- -----: ==.. + .....=. :*--: ++-==+#+::::::::::::+#*==-.:- +#+--==++. :*:.. + .......+ - :#= .- .-=+-:::--:::::::::::=*#-....= :%+:.....:=: -*:.. + ......:- .%+ . .#%+=--=*====##==========#%=....=- *#-.......:+ #=... + .......=. =#+= :#*=+ *+:..*@#========*@#======+*+-+#=:........= +*:.. + .......= **--= :#*-.-- :#+==-#%=::::::-%%-::-=+-. .#*:.........+ **:.. + .....:= :%+:.-= :#*-...+::-==-:::-=-::::::-=--==-=- *#-.........-- :%+.. + ...-: =#-...-+#*-..:=*#+===+=====++=====++=-...= =%+:........-- *#-. + .= #*:....:-:......:+ :#-..:#%:..:%%:....=. :#*=--------:. .##=. + .= :%=. . .-: ++:. -%*..+@= :- :+#+-. + :+:::+#-. .=:::-#-. +@--%*. .+-::::::::::::::--=*#*=:. + :++++=. .-++++-. .%%%%: :=+++++++++++++++==-:. + =@@+ + ##. + +usage: mimosis [GLOBAL OPTIONS] [COMMAND OPTIONS] + +GLOBAL OPTIONS are: + -f, --fpga=HEX -> Hex address of the FPGA. Defaults to 0xa000. + -s, --slow=NUM -> Execute I2C commands with a pause of NUM microseconds in between. + -a, --singleaccess -> Select single access mode. + -h, --help -> Print this or specific help. + + are: + load Load a configuration file for mimosis. + dacscan Make a DAC scan. + scurves Make a S-Curve scan of mimosis or some parts of it. + mask Mask some pixels. + instr Send an instruction to mimosis. + reg Write into a register. + vnc Open a vncviewer with the setup. + +For every a short description is accessible with the -h option. +END_MESSAGE + + print $message; + exit 0; +} + + + +sub help_load { + my $message = <<'END_MESSAGE'; + +usage: mimosis [GLOBAL OPTIONS] load [COMMAND OPTIONS] PATH + +GLOBAL OPTIONS are: + -f, --fpga=HEX -> Hex address of the FPGA. Defaults to 0xa000. + -s, --slow=NUM -> Execute I2C commands with a pause of NUM microseconds in between. + -a, --singleaccess -> Select single access mode. + -h, --help -> Print this or specific help. + +COMMAND OPTIONS are: + -p, --printall -> Print all settings from file to stdout. + -w, --printwrong -> Print all settings, that were not loaded to mimosis correctly stdout. + -h, --help -> Print this help. +END_MESSAGE + + print $message; + exit 0; +} + + + +sub help_dacscan { + my $message = <<'END_MESSAGE'; + +usage: mimosis [GLOBAL OPTIONS] dacscan [COMMAND OPTIONS] + +GLOBAL OPTIONS are: + -f, --fpga=HEX -> Hex address of the FPGA. Defaults to 0xa000. + -s, --slow=NUM -> Execute I2C commands with a pause of NUM microseconds in between. + -a, --singleaccess -> Select single access mode. + -h, --help -> Print this or specific help. + +COMMAND OPTIONS are: + -i, --ikf -> Use this flag for scans on the IKFv2 proxy. + -m, --imagefile-only -> Print only image files, don't open gnuplot terminal. + -n, --name=NAME -> Sensor name. If defined, images and data files will be marked with this name. + -c, --cleanup -> Delete data and image files afterwards. + -h, --help -> Print this help. +END_MESSAGE + + print $message; + exit 0; +} + + + +sub help_scurves { + my $message = <<'END_MESSAGE'; + +usage: mimosis [GLOBAL OPTIONS] scurves [COMMAND OPTIONS] + +GLOBAL OPTIONS are: + -f, --fpga=HEX -> Hex address of the FPGA. Defaults to 0xa000. + -s, --slow=NUM -> Execute I2C commands with a pause of NUM microseconds in between. + -a, --singleaccess -> Select single access mode. + -h, --help -> Print this or specific help. + +COMMAND OPTIONS are: + --colpix X -> x value of a single pixel to pulse. + --rowpix Y -> y value of a single pixel to pulse. + --pulseonly -> if set, mark specified pixels only for pulsing and dont do a scan. + -r, --region A|B|C|D -> Region to pulse. + --firstrow Y -> First row to scan. + --lastrow Y -> Last row to scan. + --rowdiv ROWDIV -> Just pulse every ROWDIV row. + --firstcol X -> First column to scan. + --lastcol X -> Last column to scan. + --coldiv COLDIV -> Just pulse every COLDIV column. + --firstset S -> Start s-curve scan at VPH_FINE=S + --lastset S -> Stop s-curve scan at VPH_FINE=S + --setdiv SETDIV -> Just use every SETDIV value of VPH_FINE. + --settime T -> Take data for each VPH_FINE for T milliseconds. + --vcasn A|B|C|D -> VACSN to vary. Default is the same as specified with --region. + --firstvcasn V -> Start s-curve taking with VCASN=V. + --lastvcasn V -> Stop s-curve taking at VCASN=V. + --vcasndiv V -> Take s-curve every V steps. + --nrows N -> How many rows to pulse at once. Default depends on region. For A,D: N = 4, for B,D: N = 2. + --printset -> Print the current VPH_FINE setting. + --printrow -> Print current row to set. + --printcol -> Print current column to set. + -p, --printall -> Print all informations available. + --analogAlimA -> Not implemented yet. + --analogAlimB -> Not implemented yet. + --analogDlimA -> Not implemented yet. + --analogDlimB -> Not implemented yet. + --modpulse MOD -> Exponent of the power of two, which gives the divider of the frames to pulse. + -h, --help -> Print this help. +END_MESSAGE + + print $message; + exit 0; +} + + +sub help_mask { + my $message = <<'END_MESSAGE'; + +usage: mimosis [GLOBAL OPTIONS] mask [COMMAND OPTIONS] + +GLOBAL OPTIONS are: + -f, --fpga=HEX -> Hex address of the FPGA. Defaults to 0xa000. + -s, --slow=NUM -> Execute I2C commands with a pause of NUM microseconds in between. + -a, --singleaccess -> Select single access mode. + -h, --help -> Print this or specific help. + +COMMAND OPTIONS are: + --region A|B|C|D -> Region to pulse. If provided, ignores --collow, --colhig, --rowlow and --rowhig + -x, --column INT -> Select column of the Pixel to mask. If not specified, but --region is given, all columns in this region are selected. If neither --region nor --column are given, all columns are selected. + -y, --row INT -> Select Rows of the Pixel to mask. If not specified, all rows are selected. Pixels whos rows and columns are selected will be masked. + --mask-all -> Mask all pixels with via an instructions. + --unmask-all -> Unmask all pixels with via an instructions. + --hline -> Mask a horizontal line. + --vline -> Mask a vertical line. + --square -> Mask a square. + -h, --help -> Print this help. +END_MESSAGE + + print $message; + exit 0; +} + + + + +sub help_instr { + my $message = <<'END_MESSAGE'; + +usage: mimosis [GLOBAL OPTIONS] instr INSTR + +GLOBAL OPTIONS are: + -f, --fpga=HEX -> Hex address of the FPGA. Defaults to 0xa000. + -s, --slow=NUM -> Execute I2C commands with a pause of NUM microseconds in between. + -a, --singleaccess -> Select single access mode. + -h, --help -> Print this or specific help. +END_MESSAGE + + print $message; + exit 0; +} + + + +sub help_reg { + my $message = <<'END_MESSAGE'; + +usage: mimosis [GLOBAL OPTIONS] reg REGISTER VALUE + +GLOBAL OPTIONS are: + -f, --fpga=HEX -> Hex address of the FPGA. Defaults to 0xa000. + -s, --slow=NUM -> Execute I2C commands with a pause of NUM microseconds in between. + -a, --singleaccess -> Select single access mode. + -h, --help -> Print this or specific help. +END_MESSAGE + + print $message; + exit 0; +} + + + +sub help_vnc { + my $message = <<'END_MESSAGE'; + +usage: mimosis vnc + +END_MESSAGE + + print $message; + exit 0; +} + + + 1; __END__ diff --git a/scripts/cli/mimosis b/scripts/cli/mimosis index faca1ac..9dab756 100755 --- a/scripts/cli/mimosis +++ b/scripts/cli/mimosis @@ -39,49 +39,38 @@ my ( $region_mask, $row_mask, $col_mask, my @ARGV_bak = @ARGV; -my $res = GetOptions( - - options => - { - 'help|h|?' => - { - handler => \&help_global, - }, +my $res = GetOptions ( + options => { 'fpga|f=s' => \$fpga, 'singleaccess|a' => \$a, 'slow|s=s' => \$slow, }, - default_subcommand => 'default', - - subcommands => - { - default => - { - }, - load => - { - options => - { + subcommands => { + default => {}, + load => { + options => { 'printall|p' => \$printall_load, 'printwrong|w' => \$printwrong_load, + 'help|h' => { + handler => \&Mimosis::help_load, + } }, }, - dacscan => - { - options => - { + dacscan => { + options => { "ikf|i" => \$ikf, "imagefile-only|m" => \$imagefileonly, "name|n=s" => \$name, "cleanup|c" => \$cleanup_dacscan, 'printall|p' => \$printall_dacscan, + 'help|h' => { + handler => \&Mimosis::help_dacscan, + } }, }, - scurves => - { - options => - { + scurves => { + options => { "colpix=s" => \$colpix_scurves, "rowpix=s" => \$rowpix_scurves, "pulseonly" => \$pulseonly_scurves, @@ -110,12 +99,13 @@ my $res = GetOptions( "analogDlimA=s" => \$analogDlimA_scurves, "analogDlimB=s" => \$analogDlimB_scurves, "modpulse=s" => \$modpulse_scurves, + 'help|h' => { + handler => \&Mimosis::help_scurves, + } }, }, - mask => - { - options => - { + mask => { + options => { "region|r=s" => \$region_mask, "row|y=s" => \$row_mask, "column|x=s" => \$col_mask, @@ -127,235 +117,44 @@ my $res = GetOptions( "vline" => \$vline_mask, "square" => \$square_mask, "printall|p" => \$printall_mask, + 'help|h' => { + handler => \&Mimosis::help_mask, + } }, }, - instr => - { - options => {}, + instr => { + options => { + 'help|h' => { + handler => \&Mimosis::help_instr, + } + }, }, - reg => - { - options => {}, + reg => { + options => { + 'help|h' => { + handler => \&Mimosis::help_reg, + } + }, }, - vnc => - { - options => {}, + vnc => { + options => { + 'help|h' => { + handler => \&Mimosis::help_vnc, + } + }, }, }, - - completion => sub - { + completion => sub { my %args = @_; }, ); die "GetOptions failed!\n" unless $res->{success}; -sub help_global -{ - if( !defined $_[0] ) - { - my $message = <<'END_MESSAGE'; - -usage: mimosis [GLOBAL OPTIONS] [COMMAND OPTIONS] - -GLOBAL OPTIONS are: - -f, --fpga=HEX -> Hex address of the FPGA. Defaults to 0xa000. - -s, --slow=NUM -> Execute I2C commands with a pause of NUM microseconds in between. - -a, --singleaccess -> Select single access mode. - -h, --help -> Print this or specific help. - - are: - load Load a configuration file for mimosis. - dacscan Make a DAC scan. - scurves Make a S-Curve scan of mimosis or some parts of it. - mask Mask some pixels. - instr Send an instruction to mimosis. - reg Write into a register. - vnc Open a vncviewer with the setup. - -For every a short description is accessible with the -h option. -END_MESSAGE - print $message; - exit 0; - } - elsif( $_[2]->{_non_options_argv}[0] eq '') - { - my $message = <<'END_MESSAGE'; - -usage: mimosis [GLOBAL OPTIONS] [COMMAND OPTIONS] - -GLOBAL OPTIONS are: - -f, --fpga=HEX -> Hex address of the FPGA. Defaults to 0xa000. - -s, --slow=NUM -> Execute I2C commands with a pause of NUM microseconds in between. - -a, --singleaccess -> Select single access mode. - -h, --help -> Print this or specific help. - - are: - load Load a configuration file for mimosis. - dacscan Make a DAC scan. - scurves Make a S-Curve scan of mimosis or some parts of it. - mask Mask some pixels. - instr Send an instruction to mimosis. - reg Write into a register. - vnc Open a vncviewer with the setup. - -For every a short description is accessible with the -h option. -END_MESSAGE - print $message; - exit 0; - } - elsif ( $_[2]->{_non_options_argv}[0] eq 'load' ) - { - my $message = <<'END_MESSAGE'; - -usage: mimosis [GLOBAL OPTIONS] load [COMMAND OPTIONS] PATH - -GLOBAL OPTIONS are: - -f, --fpga=HEX -> Hex address of the FPGA. Defaults to 0xa000. - -s, --slow=NUM -> Execute I2C commands with a pause of NUM microseconds in between. - -a, --singleaccess -> Select single access mode. - -h, --help -> Print this or specific help. - -COMMAND OPTIONS are: - -p, --printall -> Print all settings from file to stdout. - -w, --printwrong -> Print all settings, that were not loaded to mimosis correctly stdout. - -h, --help -> Print this help. -END_MESSAGE - print $message; - exit 0; - } - elsif ( $_[2]->{_non_options_argv}[0] eq 'dacscan' ) - { - my $message = <<'END_MESSAGE'; - -usage: mimosis [GLOBAL OPTIONS] dacscan [COMMAND OPTIONS] - -GLOBAL OPTIONS are: - -f, --fpga=HEX -> Hex address of the FPGA. Defaults to 0xa000. - -s, --slow=NUM -> Execute I2C commands with a pause of NUM microseconds in between. - -a, --singleaccess -> Select single access mode. - -h, --help -> Print this or specific help. - -COMMAND OPTIONS are: - -i, --ikf -> Use this flag for scans on the IKFv2 proxy. - -m, --imagefile-only -> Print only image files, don't open gnuplot terminal. - -n, --name=NAME -> Sensor name. If defined, images and data files will be marked with this name. - -c, --cleanup -> Delete data and image files afterwards. - -h, --help -> Print this help. -END_MESSAGE - print $message; - exit 0; - } - elsif ( $_[2]->{_non_options_argv}[0] eq 'scurves' ) - { - my $message = <<'END_MESSAGE'; - -usage: mimosis [GLOBAL OPTIONS] scurves [COMMAND OPTIONS] - -GLOBAL OPTIONS are: - -f, --fpga=HEX -> Hex address of the FPGA. Defaults to 0xa000. - -s, --slow=NUM -> Execute I2C commands with a pause of NUM microseconds in between. - -a, --singleaccess -> Select single access mode. - -h, --help -> Print this or specific help. - -COMMAND OPTIONS are: - --colpix X -> x value of a single pixel to pulse. - --rowpix Y -> y value of a single pixel to pulse. - --pulseonly -> if set, mark specified pixels only for pulsing and dont do a scan. - -r, --region A|B|C|D -> Region to pulse. - --firstrow Y -> First row to scan. - --lastrow Y -> Last row to scan. - --rowdiv ROWDIV -> Just pulse every ROWDIV row. - --firstcol X -> First column to scan. - --lastcol X -> Last column to scan. - --coldiv COLDIV -> Just pulse every COLDIV column. - --firstset S -> Start s-curve scan at VPH_FINE=S - --lastset S -> Stop s-curve scan at VPH_FINE=S - --setdiv SETDIV -> Just use every SETDIV value of VPH_FINE. - --settime T -> Take data for each VPH_FINE for T milliseconds. - --vcasn A|B|C|D -> VACSN to vary. Default is the same as specified with --region. - --firstvcasn V -> Start s-curve taking with VCASN=V. - --lastvcasn V -> Stop s-curve taking at VCASN=V. - --vcasndiv V -> Take s-curve every V steps. - --nrows N -> How many rows to pulse at once. Default depends on region. For A,D: N = 4, for B,D: N = 2. - --printset -> Print the current VPH_FINE setting. - --printrow -> Print current row to set. - --printcol -> Print current column to set. - -p, --printall -> Print all informations available. - --analogAlimA -> Not implemented yet. - --analogAlimB -> Not implemented yet. - --analogDlimA -> Not implemented yet. - --analogDlimB -> Not implemented yet. - --modpulse MOD -> Exponent of the power of two, which gives the divider of the frames to pulse. - -h, --help -> Print this help. -END_MESSAGE - print $message; - exit 0; - } - elsif ( $_[2]->{_non_options_argv}[0] eq 'mask' ) - { - my $message = <<'END_MESSAGE'; - -usage: mimosis [GLOBAL OPTIONS] mask [COMMAND OPTIONS] - -GLOBAL OPTIONS are: - -f, --fpga=HEX -> Hex address of the FPGA. Defaults to 0xa000. - -s, --slow=NUM -> Execute I2C commands with a pause of NUM microseconds in between. - -a, --singleaccess -> Select single access mode. - -h, --help -> Print this or specific help. - -COMMAND OPTIONS are: - --region A|B|C|D -> Region to pulse. If provided, ignores --collow, --colhig, --rowlow and --rowhig - -x, --column INT -> Select column of the Pixel to mask. If not specified, but --region is given, all columns in this region are selected. If neither --region nor --column are given, all columns are selected. - -y, --row INT -> Select Rows of the Pixel to mask. If not specified, all rows are selected. Pixels whos rows and columns are selected will be masked. - --mask-all -> Mask all pixels with via an instructions. - --unmask-all -> Unmask all pixels with via an instructions. - --hline -> Mask a horizontal line. - --vline -> Mask a vertical line. - --square -> Mask a square. - -h, --help -> Print this help. -END_MESSAGE - print $message; - exit 0; - } - elsif ( $_[2]->{_non_options_argv}[0] eq 'instr' ) - { - my $message = <<'END_MESSAGE'; - -usage: mimosis [GLOBAL OPTIONS] instr INSTR - -GLOBAL OPTIONS are: - -f, --fpga=HEX -> Hex address of the FPGA. Defaults to 0xa000. - -s, --slow=NUM -> Execute I2C commands with a pause of NUM microseconds in between. - -a, --singleaccess -> Select single access mode. - -h, --help -> Print this or specific help. -END_MESSAGE - print $message; - exit 0; - } - elsif ( $_[2]->{_non_options_argv}[0] eq 'reg' ) - { - my $message = <<'END_MESSAGE'; - -usage: mimosis [GLOBAL OPTIONS] reg REGISTER VALUE - -GLOBAL OPTIONS are: - -f, --fpga=HEX -> Hex address of the FPGA. Defaults to 0xa000. - -s, --slow=NUM -> Execute I2C commands with a pause of NUM microseconds in between. - -a, --singleaccess -> Select single access mode. - -h, --help -> Print this or specific help. -END_MESSAGE - print $message; - exit 0; - } - exit 0; -} - if( $res->{subcommand}[0] eq 'default' ) { - help_global(); + Mimosis::help_global(); exit; } -- 2.43.0