为什么我会得到错误的答案/值?
它应该打印的正确值是,1, 2175, 4
但我总是得到1, 3, 0
?!
my $data = pack ('C*', map hex, split /\s+/, "01 00 00 00 7F 08 03 00 21 04 80 04 FF D7 FB 0C EC 01 44 00 61 1D 00 00 10 3B 00 00 FF D7 FB 0C 00 00 8C 64 00 00 EC 45");
($obj->{Version}, $obj->{res1}, $obj->{EARFCN}, $tmp1, $obj->{res2}, $tmp2)=unpack("C C3 v C C V", $data);
$obj->{band} = ($tmp1 & 0xfc) >> 2;
print "\n".$obj->{Version}; # Should print 1
print "\n".$obj->{EARFCN}; # Should print 2175
print "\n".$obj->{band}; # Should print 4. Note: this is the first 6 bits from MSB of $tmp1.
print "\n";