简体   繁体   English

蓝牙条形码扫描仪的解码输出

[英]Decoding output of bluetooth barcode scanner

I have a barcode scanner which is sending me raw output. 我有一台条形码扫描仪,向我发送原始输出。 I am trying to figure out what that output is. 我试图弄清楚该输出是什么。

I receive an array of bytes. 我收到一个字节数组。 If I display them directly as a string: 如果我直接将它们显示为字符串:

byte[] buffer = new byte[1024];  // buffer store for the stream
int bytes; // bytes returned from read()

// Keep listening to the InputStream until an exception occurs
while (true) {
    try {
        // Read from the InputStream
        bytes = mmInStream.read(buffer);

        mDisplayer.display(new String(buffer));
    } catch (IOException e) {
        break;
    }
}

I get this: 我得到这个:

(4}�����A���L�*��������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������

Now if I change the display code to the following: 现在,如果我将显示代码更改为以下内容:

String numberToDisplay = "";
// Read from the InputStream
bytes = mmInStream.read(buffer);
for (int i=0; i<bytes; i++ ) {
    numberToDisplay = numberToDisplay.concat(Integer.toString((int)buffer[i] & 0xff));
}
mDisplayer.display(numberToDisplay);

I get this: 我得到这个:

1628405212513714915817024765139151223217614142

But the actual number under the barcode is: 但是条形码下的实际数字是:

0003001095504

So how can I get it to read it properly? 那么如何正确阅读它呢?

EDIT : 编辑

If I display the bytes I get this: 如果显示字节,我得到以下信息:

00010000 (10)
00011100 (1C)
00101000 (28)
00110100 (34)
01111101 (7D)
10001001 (89)
10010101 (95)
10011110 (9E)
10101010 (AA)
11110111 (F7)
01000001 (41)
10001011 (8B)
10010111 (97)
11011111 (DF)
00010101 (15)
01001100 (4C)
10001101 (8D)
00101010 (2A)

Make sure you enabled "SPP" on the Bluetooth Device. 确保在蓝牙设备上启用了“ SPP”。

/** For this data to be *right* you must enable SPP mode on the barcode scanner. */
numberToDisplay = new String(buffer, 0 , bytes);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM