问题
I am trying to use a Datalogic barcode scanner (Gryphon 44xx model) on a Mac, from an application (i.e. I am not writing a device driver).
Instead of using the scanner's keyboard emulation I'd like to use the special USB HID scanner protocol, called "USB-OEM" mode by Datalogic.
I've already successfully managed to use a different scanner in this mode (a GoDEX model), which sends me HID packets whenever it scans a code.
However, the Datalog scanner doesn't attempt to scan nor sends scanning data to the Mac.
I then learned that the Datalogic scanner expects to get additional configuration data from the host before it starts scanning. I was told that I need to send a HID datagram with the following contents: {0, 17, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
or {1, 17, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
(the person had figured that out by using a USB packet sniffer). (See German forum article).
However, I have no clue how to accomplish that on OS X. Or rather, whatever I've tried, it doesn't work. At best, I get a response with the values 81 00 00 00 00 00 00 00 00
, but have no idea what that means, either.
I've tried using the USB Prober (on OS X 10.7.5) to see what data actually gets transmitted to the scanner but the tool doesn't seem to be able to show me the transferred packets, either: When using its logging feature at level 6, I see nothing, while at 7 I get 1000s of lines of output per second and have no way of finding any packet data related to my communication in it - sadly, there's also no docs for this tool, or are there?.
I've also had a look at some of the USB HID and POS (Point Of Sale) specs, but I do not understand any of it, despite looking at it for hours.
Can anyone give me some pointers on how to interpret the POS specs, how to find that option to enable the scanner in it, and how it relates to the IOKit (user level) functions for configuring it? I mean, there's all that talk about reports and such, but I cannot connect the dots between the specs and the OS X API.
回答1:
Turns out that I had interpreted the logged data incorrectly.
The scanner needs to be send a message with only 11 bytes: {17, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
That will enable it.
The scanner then responds with datagram of 64 byte length in this format:
Byte 0: length of payload
Byte 1: status byte 0
Byte 2: status byte 2
Byte 3: status byte 2
Byte 4 to <length minus 4>: barcode data and type code
Byte <length of payload> to 63: zero
The type code is one to three bytes that identify the label type, e.g. it's 00h 33h 0Bh for QR Code and 00h 18h 0Bh for Code 128.
来源:https://stackoverflow.com/questions/35526928/enable-usb-oem-hid-pos-mode-in-a-datalogic-barcode-scanner-on-os-x