From: Jan Michel Date: Sat, 3 Aug 2013 17:38:27 +0000 (+0200) Subject: changed data handling to 16 Bit X-Git-Url: https://jspc29.x-matter.uni-frankfurt.de/git/?a=commitdiff_plain;h=5bec3785b2eb446063fa2d5781644d0a11234fa6;p=mvdsensorcontrol.git changed data handling to 16 Bit --- diff --git a/layout/styles.css b/layout/styles.css index 8df33e1..cce6b84 100644 --- a/layout/styles.css +++ b/layout/styles.css @@ -3,6 +3,7 @@ body { font-size:10pt; margin:0px 0 0 25px; padding:0; + font-family:sans-serif; } diff --git a/tools/preview/unpack_hld.pl b/tools/preview/unpack_hld.pl index da06a80..42db30e 100755 --- a/tools/preview/unpack_hld.pl +++ b/tools/preview/unpack_hld.pl @@ -191,13 +191,15 @@ sub getEvtHeader() } my $decoding = unpack("V*", $tmp_list[1]); + my $endian = &getEndianess($decoding); + unless(defined $decoding) { printf "This seems to be the end\n" if $opt_verb; return -1; } if($opt_debug){ - if(&getEndianess($decoding)){ + if($endian){ printf("\n Event Decoding: %08x Byte Order: Little Endian\n", $decoding); } else{ @@ -208,7 +210,7 @@ sub getEvtHeader() foreach my $tmp (@tmp_list){ my $word; - if(&getEndianess($decoding)){ + if($endian){ $word = unpack("V*", $tmp); # Small Endian } else{ @@ -291,10 +293,10 @@ sub getSubEvtData() { my @tmps; read($fh, $tmp, 4*$nrOfWords); if($endian){ - @$data_aref = unpack("V*",$tmp); + @$data_aref = unpack("v*",$tmp); } else{ - @$data_aref = unpack("N*",$tmp); + @$data_aref = unpack("n*",$tmp); } # my $word; @@ -373,26 +375,26 @@ sub analyzeData() { SSELoop: while(1) { #Loop over SubSubEvents #Read SubSubEvent Header - my $RocId = $data->[$pos] & 0xffff; - my $RocLength = ($data->[$pos]>>16) & 0xffff; + my $RocLength = $data->[$pos++]; + my $RocId = $data->[$pos++]; if($RocId == 0x5555) {last;} - my $RocEnd = $pos + $RocLength; - $pos++; - + my $RocEnd = $pos + $RocLength*2 -1; + SensLoop: while(1) { #Loop over Sensors #Read Sensor Header - my $SensorHead = $data->[$pos++]; - my $SensorId = $data->[$pos++] & 0xffff; - my $SensorStatus = $data->[$pos++]; - my $SensorError = $data->[$pos++]; - my $SensorDebug = $data->[$pos++]; + my $SensorHead = ($data->[$pos+0] << 16) + $data->[$pos+1]; + my $SensorId = $data->[$pos+3]; + my $SensorStatus = ($data->[$pos+4] << 16) + $data->[$pos+5]; + my $SensorError = ($data->[$pos+6] << 16) + $data->[$pos+7]; + my $SensorDebug = ($data->[$pos+8] << 16) + $data->[$pos+9]; + $pos+=10; if($opt_frameinfo) { - my $SensorTime = sprintf("%08x%08x",$data->[$pos+1],$data->[$pos]) if $opt_frameinfo; - printf("ID\t%8x\tStatus\t%08x\tError\t%08x\tDebug\t%08x\tTime\t%s\n", - $SensorId, $SensorStatus, $SensorError, $SensorDebug, $SensorTime); + my $SensorTime = sprintf("%04x%04x%04x%04x",$data->[$pos+2],$data->[$pos+3],$data->[$pos],$data->[$pos+1]) if $opt_frameinfo; + printf("Head\t%8x\tID\t%8x\tStatus\t%08x\tError\t%08x\tDebug\t%08x\tTime\t%s\n", + $SensorHead, $SensorId, $SensorStatus, $SensorError, $SensorDebug, $SensorTime); } - $pos+= 2; + $pos+= 4; $PMap->{$SensorId}->[575]->[1151] = 0 unless defined $PMap->{$SensorId}->[575]->[1151]; my $matrix = $PMap->{$SensorId}; @@ -422,19 +424,18 @@ sub analyzeData() { if($SensorIsValid){ #Hey Sensor, tell me who you are! - my $SensorDummy = $data->[$pos++]; - my $SensorNumber = $data->[$pos++]; - my $SensorLength = $data->[$pos++] & 0xffff; + my $SensorDummy = ($data->[$pos+0] << 16) + $data->[$pos+1]; + my $SensorNumber = ($data->[$pos+2] << 16) + $data->[$pos+3]; + my $SensorLength = $data->[$pos+5]; + $pos+=6; printf("\t\t\tHeader\t%08x\tFrame\t%08x\tLength\t%i\n", $SensorDummy, $SensorNumber, $SensorLength) if $opt_frameinfo; - my $FrameEndPos = $pos + $SensorLength; - my ($i, $d, $line, $column, $pixels, $statecnt, $ovf) = (1,0,0,0,0,0,0); + my $FrameEndPos = $pos + $SensorLength*2; + my ($d, $line, $column, $pixels, $statecnt, $ovf) = (0,0,0,0,0,0); while(1) { - #Disentangle 16 Bit words - if($i=1-$i) {$d = $data->[$pos++] & 0xffff;} - else {$d = ($data->[$pos] >> 16);} + $d = $data->[$pos++]; #Is new line? if($statecnt-- == 0) { @@ -448,9 +449,15 @@ sub analyzeData() { printf("\t$line, $column x %d\n",$pixels+1) if $opt_frameinfo; $matrix->[$line]->[$column]++; - $matrix->[$line]->[$column+1]++ if $pixels > 0; - $matrix->[$line]->[$column+2]++ if $pixels > 1; - $matrix->[$line]->[$column+3]++ if $pixels > 2; + if ($pixels > 0) { + $matrix->[$line]->[$column+1]++; + if ($pixels > 1) { + $matrix->[$line]->[$column+2]++; + if ($pixels > 2) { + $matrix->[$line]->[$column+3]++; + } + } + } } last if $pos >= $FrameEndPos; @@ -458,7 +465,7 @@ sub analyzeData() { #Read end of frame marker without check - $pos++; + $pos+=2; } else { #TODO: handling for frames with invalid status, but data. @@ -482,7 +489,7 @@ sub WriteResults { $fh = new FileHandle ("|$fn") or die "error: no gnuplot"; $fh->autoflush(1); - print $fh "set terminal pngcairo size 576,288;\n"; + print $fh "set terminal pngcairo size 800,400;\n"; print $fh "set palette model RGB;\n"; print $fh "set xrange [0:1152];\n"; print $fh "set yrange [0:576];\n";