From: Michael Wiebusch Date: Wed, 25 Jun 2014 15:46:57 +0000 (+0200) Subject: more functionality, yet lacking help message X-Git-Url: https://jspc29.x-matter.uni-frankfurt.de/git/?a=commitdiff_plain;h=6cf0fb6c77939b7b508503bf21a753c5babb4eee;p=coral.git more functionality, yet lacking help message --- diff --git a/.analyzer.pl.swp b/.analyzer.pl.swp new file mode 100644 index 0000000..a3dd929 Binary files /dev/null and b/.analyzer.pl.swp differ diff --git a/user_interface/analyzer.pl b/user_interface/analyzer.pl index 819b28f..3a8e19a 100755 --- a/user_interface/analyzer.pl +++ b/user_interface/analyzer.pl @@ -5,6 +5,7 @@ use Device::SerialPort; use Time::HiRes; use Getopt::Long; use POSIX qw/strftime/; +use POSIX; # plot destination # check for tools @@ -15,24 +16,97 @@ use POSIX qw/strftime/; # defaults my $baudrate=115200; my $port; +my $opt_command; +my $read; +my $opt_help; +my $write; +my $clear; +my $clkdiv; +my $window; my $ser_dev = "/dev/ttyUSB0"; +GetOptions ( 'h|help' => \$opt_help, + 'c|cmd=s' => \$opt_command, + 'tty=s' => \$ser_dev, + 'baud=s' => \$baudrate, + 'r|read=s' => \$read, + 'w|write=s' => \$write, + 'c|clear' => \$clear, + 'd|divider=s' => \$clkdiv, + 'window=s' => \$window + ); + + init_port(); -for (my $i=0;$i<128;$i++){ - my $rstring = communicate("R".chr($i)); -# printf ("length of response: %d \n",length($rstring)); +if (defined ($read)) { + + my $val = communicate("R".chr($read)); + printf("response: %d\n",$val); - my $byte3 = ord(substr($rstring,0,1)); - my $byte2 = ord(substr($rstring,1,1)); - my $byte1 = ord(substr($rstring,2,1)); - my $byte0 = ord(substr($rstring,3,1)); - my $val = (($byte3<<24)|($byte2<<16)|($byte1<<8)|$byte0); + exit; +} + +if (defined($clear)){ + $write = '129_1'; +} + + +if (defined($window)){ + my $tunit=1e-3; + if($window =~ m/ms/){ + $tunit=1e-3; + } elsif($window =~ m/us/){ + $tunit=1e-6; + } elsif($window =~ m/ns/){ + $tunit=1e-9; + } elsif($window =~ m/s/){ + $tunit=1; + } + + $window =~ m/([\d\.]+)/; + my $number = $1; + printf("requested window width: %e s\n",$number*$tunit); + my $FPGAclk=133000000; + my $analyzerBins=128; + $clkdiv = floor(($number*$tunit)/$analyzerBins/(1/$FPGAclk)); + +} + +if (defined($clkdiv)){ + $write = "128_$clkdiv"; +} + +if (defined ($write)) { + + unless( $write =~ m/(\d+)_(\d+)/ ) { + die "input parameter: analyzer -w 127_1234\n"; + } + + my $addr = $1; + my $value = $2; + print "addr:$addr value:$value\n"; + + my $byte3 = chr(int($value)>>24); + my $byte2 = chr((int($value)>>16)&0xFF); + my $byte1 = chr((int($value)>>8)&0xFF); + my $byte0 = chr(int($value)&0xFF); + + my $val = communicate("W".chr($addr).$byte3.$byte2.$byte1.$byte0); + printf("response: %d\n",$val); + + exit; +} + + +for (my $i=0;$i<128;$i++){ + my $val = communicate("R".chr($i)); +# printf ("length of response: %d \n",length($rstring)); printf("%d\t%d\n",$i,$val); # printf("addr %d:\t%d.%d.%d.%d\n",$i,$byte3,$byte2,$byte1,$byte0); # Time::HiRes::sleep(.01); @@ -47,39 +121,43 @@ sub communicate { my $command = $_[0]; # print "sending command $command\n"; - my $cmd_echo; + my $rstring; - $port->are_match(chr(10)); + $port->are_match(""); + $port->read_char_time(1); + $port->read_const_time(0); $port->lookclear; + #Time::HiRes::sleep(.004); $port->write("$command\n"); my $ack = 0; + + + #Time::HiRes::sleep(.004); - - -ACK_POLLING: for (my $i = 0; ($i<$ack_timeout*100) ;$i++) { -# print $i."\n"; - while(my $a = $port->lookfor) { - if($a=~ m/R(....)/) { - $cmd_echo = $1; + my ($count, $a) = $port->read(12); + + if($a=~ m/R(.{4})/s) { + $rstring= $1; # print "padiwa sent: $cmd_echo\n\n"; - $ack=1; - last ACK_POLLING; - } - - } - Time::HiRes::sleep(.01); - + $ack=1; } + + unless($ack) { print "no answer\n"; - return "0"; + return 0; } + my $byte3 = ord(substr($rstring,0,1)); + my $byte2 = ord(substr($rstring,1,1)); + my $byte1 = ord(substr($rstring,2,1)); + my $byte0 = ord(substr($rstring,3,1)); + my $val = (($byte3<<24)|($byte2<<16)|($byte1<<8)|$byte0); - return $cmd_echo; + return $val; diff --git a/user_interface/out.dat b/user_interface/out.dat index ec215d9..07a558a 100644 --- a/user_interface/out.dat +++ b/user_interface/out.dat @@ -1,127 +1,129 @@ -0 59 -1 0 -2 0 -3 0 -4 0 -5 0 -6 0 -7 0 -8 0 -9 0 -10 742 -11 0 -12 0 -13 0 -14 0 -15 0 -16 0 -17 0 -18 0 -19 0 -20 0 -21 377 -22 0 -23 0 -24 0 -25 0 -26 0 -27 0 -28 0 -29 0 -30 0 -31 0 -32 170 -33 0 -34 0 -35 0 -36 0 -37 0 -38 0 -39 0 -40 0 -41 0 -42 0 -43 95 -44 0 -45 0 -46 0 -47 0 -48 0 -49 0 -50 0 -51 0 -52 0 -53 0 -54 49 -55 0 -56 0 -57 0 -58 0 -59 0 -60 0 -61 0 -62 0 -63 0 -64 23 -65 6 -66 0 -67 0 -68 0 -69 0 -70 0 -71 0 -72 0 +0 0 +1 2 +2 1 +3 1 +4 1 +5 4 +6 3 +7 4 +8 9 +9 3 +10 5 +11 5 +12 10 +13 10 +14 9 +15 12 +16 14 +17 21 +18 23 +19 24 +20 24 +21 10 +22 23 +23 10 +24 31 +25 35 +26 23 +27 33 +28 43 +29 32 +30 53 +31 45 +32 51 +33 42 +34 53 +35 43 +36 47 +37 60 +38 55 +39 63 +40 82 +41 67 +42 83 +43 86 +44 84 +45 80 +46 83 +47 90 +48 95 +49 104 +50 101 +51 110 +52 106 +53 100 +54 131 +55 121 +56 92 +57 114 +58 111 +59 121 +60 119 +61 140 +62 124 +63 155 +64 149 +65 128 +66 131 +67 139 +68 144 +69 149 +70 131 +71 133 +72 173 +no answer 73 0 -74 0 -76 0 -77 0 -78 0 -79 0 -80 0 -81 0 -82 0 -83 0 -84 0 -85 0 -86 6 -87 0 -88 0 -89 0 -90 0 -91 0 -92 0 -93 0 -94 0 -95 0 -96 0 -97 3 -98 0 -99 0 -100 0 -101 0 -102 0 -103 0 -104 0 -105 0 -106 0 -107 0 -108 1 -109 0 -110 0 -111 0 -112 0 -113 0 -114 0 -115 0 -116 0 -117 0 -118 0 -119 2 -120 0 -121 0 -122 0 -123 0 -124 0 -125 0 -126 0 -127 3 +74 180 +75 161 +76 209 +77 209 +78 271 +79 285 +80 348 +81 340 +82 385 +83 448 +84 428 +85 406 +86 432 +87 413 +88 487 +89 434 +90 417 +91 400 +92 325 +93 412 +94 365 +95 352 +96 266 +97 291 +98 288 +99 242 +100 229 +101 225 +102 222 +103 195 +104 161 +105 148 +106 139 +107 135 +108 136 +109 117 +110 124 +111 91 +112 89 +113 82 +114 61 +115 68 +116 47 +117 32 +118 37 +119 30 +120 20 +121 16 +122 10 +123 8 +124 6 +125 9 +126 3 +127 1022 diff --git a/user_interface/plot.png b/user_interface/plot.png new file mode 100644 index 0000000..396bf9d Binary files /dev/null and b/user_interface/plot.png differ diff --git a/user_interface/plot.sh b/user_interface/plot.sh new file mode 100755 index 0000000..0755f5b --- /dev/null +++ b/user_interface/plot.sh @@ -0,0 +1,9 @@ +#!/bin/bash + +./analyzer.pl > out.dat +cat <