Re: [問題] 如何讀取條碼機所傳來的數據?

看板Perl作者 (Jason7123)時間5年前 (2018/06/12 20:57), 編輯推噓0(001)
留言1則, 1人參與, 5年前最新討論串2/2 (看更多)
我最後是用 Device::HID 來讀取條碼掃描機的輸入。 程式如下,接下來是程式收到數入的二進位碼要如何還原? barcode 的格式是使用 code 39 條碼定義: http://www.barcodeisland.com/code93.phtml use Device::HID; use Data::Hexdumper qw(hexdump); my $dev = Device::HID->new(vendor => 0x04b4, product => 0x0100) or die "No such device !\n"; $dev->timeout = 0.1; # seconds (=100 ms) my $buf; my $len=128; my $i=0; while(defined(my $in = $dev->read_data($buf, $len))){ if ($in == 0) { next; } $i++; my $hex = unpack( 'H*', $buf ); print sprintf("%02d",$i)." => $hex\n"; } 輸出: 01 => 0200040000000000 02 => 0000000000000000 03 => 00001e0000000000 04 => 0000000000000000 05 => 00001f0000000000 06 => 0000000000000000 07 => 0000200000000000 08 => 0000000000000000 09 => 0000210000000000 10 => 0000000000000000 11 => 0000280000000000 12 => 0000000000000000 -- ※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 1.34.112.98 ※ 文章網址: https://www.ptt.cc/bbs/Perl/M.1528808276.A.B8A.html

06/12 21:01, 5年前 , 1F
A1234 => [Barcode SCANNRT] => [perl] => binary => ???
06/12 21:01, 1F
文章代碼(AID): #1R7yDKkA (Perl)
文章代碼(AID): #1R7yDKkA (Perl)