#- Subtract subevent header size and devide by word size
my $nrOfWords = ($size - 16)/4;
-
my $tmp;
- my $word;
- foreach my $i (1..$nrOfWords){
- read($fh, $tmp, 4);
- if($endian){
- $word = unpack("V*", $tmp); # Little Endian
- }
- else{
- $word = unpack("N*", $tmp); # Big Endian
- }
- push(@$data_aref, $word);
- }
+
+ my @tmps;
+ read($fh, $tmp, 4*$nrOfWords);
+ if($endian){
+ @$data_aref = unpack("V*",$tmp);
+ }
+ else{
+ @$data_aref = unpack("N*",$tmp);
+ }
+
+# my $word;
+# foreach my $i (1..$nrOfWords){
+# read($fh, $tmp, 4);
+# if($endian){
+# $word = unpack("V*", $tmp); # Little Endian
+# }
+# else{
+# $word = unpack("N*", $tmp); # Big Endian
+# }
+# push(@$data_aref, $word);
+# }
}
sub padding()
my $SensorStatus = $data->[$pos++];
my $SensorError = $data->[$pos++];
my $SensorDebug = $data->[$pos++];
- my $SensorTime = sprintf("%08x%08x",$data->[$pos+1],$data->[$pos]);
+
+ 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);
+ }
+ $pos+= 2;
$PMap->{$SensorId}->[575]->[1151] = 0 unless defined $PMap->{$SensorId}->[575]->[1151];
my $matrix = $PMap->{$SensorId};
- $pos+= 2;
+
- printf("ID\t%8x\tStatus\t%08x\tError\t%08x\tDebug\t%08x\tTime\t%s\n",
- $SensorId, $SensorStatus, $SensorError, $SensorDebug, $SensorTime) if $opt_frameinfo;
#Could it be...?
if($SensorHead != 0xffffffff) {
while(1) {
#Disentangle 16 Bit words
if($i=1-$i) {$d = $data->[$pos++] & 0xffff;}
- else {$d = ($data->[$pos] >> 16) & 0xffff;}
+ else {$d = ($data->[$pos] >> 16);}
#Is new line?
if($statecnt-- == 0) {
- $ovf += $d >> 15;
+ $ovf += ($d >> 15) & 1;
$line = ($d >> 4) & 0x7FF;
$statecnt = $d & 0xF;
}
else {
- $pixels = ($d & 0x3) + 1;
+ $pixels = ($d & 0x3);
$column = ($d >> 2) & 0x7FF;
- printf("\t$line, $column x $pixels\n") if $opt_frameinfo;
+ printf("\t$line, $column x %d\n",$pixels+1) if $opt_frameinfo;
$matrix->[$line]->[$column]++;
- $matrix->[$line]->[$column+1]++ if $pixels > 1;
- $matrix->[$line]->[$column+2]++ if $pixels > 2;
- $matrix->[$line]->[$column+3]++ if $pixels > 3;
+ $matrix->[$line]->[$column+1]++ if $pixels > 0;
+ $matrix->[$line]->[$column+2]++ if $pixels > 1;
+ $matrix->[$line]->[$column+3]++ if $pixels > 2;
}
last if $pos >= $FrameEndPos;
my @matrix;
for(my $y = 0; $y < 576; $y++) {
+ my $map = $PMap->{$id}->[$y];
#Define lengths of all arrays
- $PMap->{$id}->[$y]->[1151] = 0 unless defined $PMap->{$id}->[$y]->[1151];
+ $map->[1151] = 0 unless defined $map->[1151];
#Fill undef with 0
- @matrix = map {defined $_ ? $_ : 0 } @{$PMap->{$id}->[$y]};
+ @matrix = map {defined $_ ? $_ : 0 } @{$map};
#Join lines
my $l = join(" ",@matrix);
print $fh $l."\n";