The first barcode scanners I worked with used RS232 8)
Hey Guys,
So a little update.
So, I got the Leonardo board and changed the VID and PID of the arduino from the boards.txt, and now when I connect it to the Square Terminal, it detects it as a Symbol Barcode Scanner.
But when I do, Keyboard.print("0938483293943\n"); or Keyboard.write("893748372\n");
The Square register doesn't detect the input or at least do anything useful with it.
So this made me wonder, if I need to change the USB_Read Descriptor in Keyboard.h and Keyboard.cpp ?
I guess all barcode scanners emulate an USB keyboard, but I could be wrong.
The Symbol Barcode Scanner uses a rj45 to USB cable to read the output from the barcode scanner.
Any suggestions ? As to what I might be doing wrong.
Also, what's a good (simple) tutorial to understand USB specifications and Read Descriptors ? I have gone through 'USB in a nutshell' but that's a lot of information.
Thanks.
Try \r instead of \n, or both, in different orders.
Tried. Didn't work.
I'm looking at reportDescriptors in Keyboard.h
Any ideas ? Am I on the right track ?
Best to determine the complete character string sent by the real scanner.
These are the output from the command
ioreg -p IOUSB -l -b
As you can see, the bcdDevice, bDevice, bDeviceSubClass is not the same.
// ARDUINO made to look like Barcode Scanner
Symbol Bar Code Scanner@14100000 <class AppleUSBDevice, id 0x10000870c, registered, matched, active, busy 0 (5 ms), retain 18>
{
"sessionID" = 125979754312651
"iManufacturer" = 1
"bNumConfigurations" = 1
"idProduct" = 4608
"bcdDevice" = 256
"Bus Power Available" = 250
"USB Address" = 41
"bMaxPacketSize0" = 64
"iProduct" = 2
"iSerialNumber" = 3
"bDeviceClass" = 239
"Built-In" = No
"locationID" = 336592896
"bDeviceSubClass" = 2
"bcdUSB" = 512
"USB Product Name" = "Symbol Bar Code Scanner"
"PortNum" = 1
"non-removable" = "no"
"IOCFPlugInTypes" = {"9dc7b780-9ec0-11d4-a54f-000a27052861"="IOUSBFamily.kext/Contents/PlugIns/IOUSBLib.bundle"}
"bDeviceProtocol" = 1
"IOUserClientClass" = "IOUSBDeviceUserClientV2"
"IOPowerManagement" = {"DevicePowerState"=0,"CurrentPowerState"=3,"CapabilityFlags"=65536,"MaxPowerState"=4,"DriverPowerState"=3}
"kUSBCurrentConfiguration" = 1
"Device Speed" = 1
"USB Vendor Name" = "Unknown"
"idVendor" = 1504
"IOGeneralInterest" = "IOCommand is not serializable"
"USB Serial Number" = "HIDPC"
"IOClassNameOverride" = "IOUSBDevice"
}
// ACTUAL Barcode Scanner
Symbol Bar Code Scanner@14100000 <class AppleUSBDevice, id 0x100008751, registered, matched, active, busy 0 (3 ms), retain 14>
{
"sessionID" = 126050231202522
"iManufacturer" = 1
"bNumConfigurations" = 1
"idProduct" = 4608
"bcdDevice" = 0
"Bus Power Available" = 250
"USB Address" = 42
"bMaxPacketSize0" = 8
"iProduct" = 2
"iSerialNumber" = 3
"bDeviceClass" = 0
"Built-In" = No
"locationID" = 336592896
"bDeviceSubClass" = 0
"bcdUSB" = 512
"USB Product Name" = "Symbol Bar Code Scanner"
"PortNum" = 1
"non-removable" = "no"
"IOCFPlugInTypes" = {"9dc7b780-9ec0-11d4-a54f-000a27052861"="IOUSBFamily.kext/Contents/PlugIns/IOUSBLib.bundle"}
"bDeviceProtocol" = 0
"IOUserClientClass" = "IOUSBDeviceUserClientV2"
"IOPowerManagement" = {"DevicePowerState"=0,"CurrentPowerState"=3,"CapabilityFlags"=65536,"MaxPowerState"=4,"DriverPowerState"=3}
"kUSBCurrentConfiguration" = 1
"Device Speed" = 1
"USB Vendor Name" = "�Symbol Technologies, Inc, 2002"
"idVendor" = 1504
"IOGeneralInterest" = "IOCommand is not serializable"
"USB Serial Number" = "S/N:387C5D8D8EE4FA43B650C40541EED47C Rev:NBRALAAMDM:20FEB133"
"IOClassNameOverride" = "IOUSBDevice"
}
Which files do do I need to edit, to override these values ?
Can anyone help me understand the USB Report Descriptor Format.
This code is taken from the Keyboard.h/Keyboard.cpp file provided by arduino.
I'm trying to understand this so that, I can understand the difference between the way, a barcode scanner sends its data versus a normal usb keyboard does.
// Keyboard
0x05, 0x01, // USAGE_PAGE (Generic Desktop) // 47
0x09, 0x06, // USAGE (Keyboard)
0xa1, 0x01, // COLLECTION (Application)
0x85, 0x02, // REPORT_ID (2)
0x05, 0x07, // USAGE_PAGE (Keyboard)
0x19, 0xe0, // USAGE_MINIMUM (Keyboard LeftControl)
0x29, 0xe7, // USAGE_MAXIMUM (Keyboard Right GUI)
0x15, 0x00, // LOGICAL_MINIMUM (0)
0x25, 0x01, // LOGICAL_MAXIMUM (1)
0x75, 0x01, // REPORT_SIZE (1)
0x95, 0x08, // REPORT_COUNT (8)
0x81, 0x02, // INPUT (Data,Var,Abs)
0x95, 0x01, // REPORT_COUNT (1)
0x75, 0x08, // REPORT_SIZE (8)
0x81, 0x03, // INPUT (Cnst,Var,Abs)
0x95, 0x06, // REPORT_COUNT (6)
0x75, 0x08, // REPORT_SIZE (8)
0x15, 0x00, // LOGICAL_MINIMUM (0)
0x25, 0x73, // LOGICAL_MAXIMUM (115)
0x05, 0x07, // USAGE_PAGE (Keyboard)
0x19, 0x00, // USAGE_MINIMUM (Reserved (no event indicated))
0x29, 0x73, // USAGE_MAXIMUM (Keyboard Application)
0x81, 0x00, // INPUT (Data,Ary,Abs)
0xc0, // END_COLLECTION
So, update:
For anyone who's following this thread.
I have finally used the tool 'usbhid-dump' to dump the Report Descriptor for the Symbol Barcode Scanner.
I replicated that in my Arduino code, specifically in the Keyboard.h file, in the uint_8 array that says hidReportDescriptor (or something like that ... >:( )
Now when I use Keyboard.print("38743987398"); it prints a bunch of garbage character.
I wonder if I have to change the Keyboard's asciiMap or the Scan codes ?
Any ideas ? Please ?
See reply #24.
I saw the stream of data being reported (using usbhid-dump --entity=all --model=VID:PID) by the Barcode Scanner, and changed the code accordingly in the arduino to mimic the output, but yet it seems that the Square terminal doesn't know what to do with the data.
One probable cause for this could be the 'Device Descriptor'
When looking at the Device Descriptor definition (structure) for the Barcode Scanner versus that of the Arduino posing to a Symbol Barcode Scanner, I see that the Descriptor structure of the Symbol Scanner is quite simple, while that of the arduino is quite large, which includes multiple interfaces, and CDC Descriptors etc.
The Symbol Scanner has a -
Device Descriptor
|
-- Configuration Descriptor
** |**
** --Interface Descriptor**
** | |**
** | -- HID Device Descriptor**
** |**
** -- Endpoint Descriptor**
On the other hand, the arduino has multiple interfaces, descriptors that I have no clue about.
I think during the USB enumeration process by the HOST, it sees the device descriptor, and gets confused and doesn't do anything with the data. Even though I output the same data as the original barcode scanner.
What do you guys think ? Any ideas ?