use feature 'state';
use URI::Escape;
use Data::Dumper;
-use HADES::TrbNet;
+# use HADES::TrbNet;
use Time::HiRes qw( usleep);
use Getopt::Long;
#print '.';
}
}
- else {
- trb_register_read_mem($ser_dev,0xd600,1,100); #clear memory
- my @c = split('',$c."\n");
- my @cmd = map(ord, @c);
- trb_register_write_mem($ser_dev,0xd600,1,\@cmd,scalar @cmd);
- usleep(20000);
- my $r = trb_register_read_mem($ser_dev,0xd600,1,5);
- my $s = join('',map (chr($_ & 0xff),@{$r->{$ser_dev}}));
- if ($s =~ /^\w[a-f0-9]{3}/) {return hex(substr($s,1,3));}
- if ($s =~ /^\w[a-f0-9]{2}/) {return hex(substr($s,1,2));}
- }
+# else {
+# trb_register_read_mem($ser_dev,0xd600,1,100); #clear memory
+# my @c = split('',$c."\n");
+# my @cmd = map(ord, @c);
+# trb_register_write_mem($ser_dev,0xd600,1,\@cmd,scalar @cmd);
+# usleep(20000);
+# my $r = trb_register_read_mem($ser_dev,0xd600,1,5);
+# my $s = join('',map (chr($_ & 0xff),@{$r->{$ser_dev}}));
+# if ($s =~ /^\w[a-f0-9]{3}/) {return hex(substr($s,1,3));}
+# if ($s =~ /^\w[a-f0-9]{2}/) {return hex(substr($s,1,2));}
+# }
return ;
}
print "CHANNEL: Channel number, hex or decimal\n";
print "OPERATION: 1 (on), 0 (off), / (toggle), L (set limit)\n";
print "VALUE: A 10 Bit value, 3 hex digits or decimal\n";
- print "If the DEVICE is an hex value, it is treated as a TrbNet address. Uart must be present and is assumed to be set at right baud rate\n";
+# print "If the DEVICE is an hex value, it is treated as a TrbNet address. Uart must be present and is assumed to be set at right baud rate\n";
exit;
}
my $avg = Cmd("D$n?");
my $lim = Cmd("L$n?");
+ if($curr > 0x800) {$curr = $curr - 0x1000;}
+ if($avg > 0x800) {$avg = $avg - 0x1000;}
if(($s & 0xf0) == 0xe0) {printf(" $n\tERR\t\t (%3i)\n",$lim&0x3FF);}
if(($s & 0xff) == 0x00) {printf(" $n\t--- \t\t (%3i)\n",$lim&0x3FF);}
- if(($s & 0xff) == 0x01) {printf(" $n\t%3imA\t %3imA\t (%3i)\n",$curr&0x7ff,$avg&0x7ff,$lim&0x3FF);}
+ if(($s & 0xff) == 0x01) {printf(" $n\t%3imA\t %3imA\t (%3i)\n",$curr,$avg,$lim&0x3FF);}
}
}