griZZZly8
griZZZly8

Reputation: 694

How to handle binary data returned from barcode scanner?

I have a 2d barcode scanner (Honeywell Xenon 1900).

Scanning 1D barcodes is easy, as the scanner emulates keyboard events and sends plain text.

But when I scan PDF417 format 2D barcodes, the scanner sends binary data. How can I capture and decode this data? Some of symbols are non-printable, so scanning into a form on a web page wouldn't work.

Upvotes: 6

Views: 3070

Answers (2)

griZZZly8
griZZZly8

Reputation: 694

My solution for this question is using COM-port.

I configure scanner, so it sends data not as keyboard events, but in virtual COM-port. Then I have Java-applet, that listens this port (using RXTX). Then COM-port is not empty, I can get data and parse it.

Upvotes: 4

cube
cube

Reputation: 1802

You have tagged this java as well as javascript. However you truly haven't given us any details of your application. Nonetheless, dealing with the transporting of binary data in javascript, can be done using the base64 protocol. Use two methods btoa() and atob().

function toBase64 () {
            return window.btoa(data);
        }
function fromBase64 (strBase64){
            data = window.atob(strBase64);
        }

I think the concept for you though, (and I'm just guessing since you haven't explained what you are doing in any detail), would be to base64 ENCODE the data before transporting it to the javascript/html/web application. You'll be doing this using java I suppose. Once you send the base64 encoded data to your web application, you can deal with it quite easily.

Upvotes: 0

Related Questions