簡體   English   中英

藍牙條形碼掃描儀的解碼輸出

[英]Decoding output of bluetooth barcode scanner

我有一台條形碼掃描儀,向我發送原始輸出。 我試圖弄清楚該輸出是什么。

我收到一個字節數組。 如果我直接將它們顯示為字符串:

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;
    }
}

我得到這個:

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

現在,如果我將顯示代碼更改為以下內容:

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);

我得到這個:

1628405212513714915817024765139151223217614142

但是條形碼下的實際數字是:

0003001095504

那么如何正確閱讀它呢?

編輯

如果顯示字節,我得到以下信息:

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)

確保在藍牙設備上啟用了“ 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