if ($device eq undef) { die "Usage: /dev/hidrawN"; exit; } #### @ARGV or die "Usage: /dev/hidrawN"; #### my $report = ord(substr($data, 1, 1)); my $status = ord(substr($data, 2, 1)); my $unit = ord(substr($data, 3, 1)); my $exp = ord(substr($data, 4, 1)); my $lsb = ord(substr($data, 5, 1)); my $msb = ord(substr($data, 6, 1)); my $weight = ($msb * 255 + $lsb) / 10; if($exp != 255 && $exp != 0) { $weight ^= $exp; } #### my ( $report, $status, $unit, $exp, $weight ) = unpack 'xCCCCS', $data $weight /= 10; if ( $exp != 255 && $exp != 0 ) { $weight ^= $exp; }