SilverThings / silverspoon

Portable IoT Platform
http://www.silverspoon.io
Apache License 2.0
15 stars 5 forks source link

Implement camel-barcode component #16

Open sbunciak opened 9 years ago

ghost commented 9 years ago

I'd like to work on this one, but I'm still waiting on barcode scanner to be delivered.

ghost commented 9 years ago

Finally, I'm proud owner of barcode scanner :).
It's this POS Handheld USB Laser Barcode scanner from ebay, with price about US $15 - basically cheapest one, I could find.

It turned out, that this scanner works as HID/keyboard device. It has USB cable and it can't be easily configured to act as serial device. I tested this scanner with Windows, Linux and MAC OS X and it works out of the box with all of them.
There is one thing to keep in mind, and thats keyboard layout. Scanner sends keypress events and depends on current keyboard layout, how are they interpreted. For instance code 8594156270087 is read as:

This is easy to use with some desktop application, where you simply type (or scan) the code and hit enter, but it's not usable for camel component.

Some devices (generaly more expensive ones, like Voyager 95X0 Single-Line Laser Scanner for aproximatelly US $130) can work as HID device, but they can also be configured to connect as serial device.
As a serial device, they are typically visible as COMx on windows (somewhere in /dev/... on linux) and application can simply read from this device.

I have very limited access to Honeywell/Metrologic scanners, so current focus is on barcode scanner as HID/keyboard device.
At this point, I own big thanks to Daniel Vratil, who put together simple C program for reading from input device, even when the program doesn't have focus, and it can also prevent key events from being propagated to the system. Program source code is available here.

Next goal would be to get this working from Java. I believe that it can easily run on any linux (maybe even on windows) and also on Raspberry, and other ARM devices. For this reason, I don't think Bulldog is best fit, becuase it would be limited to small ARM devices.
Maybe it could be done with JNA library.
Does anyone have experience with it, or better suggestions?

sbunciak commented 9 years ago

Finally, I'm proud owner of barcode scanner :).

Good news :-)

For this reason, I don't think Bulldog is best fit, becuase it would be limited to small ARM devices.

Makes sense, put it directly to silverspoon, along with its native part, as another sub-module (as camel-temperature).

Maybe it could be done with JNA library.

Generally speaking, JNA has worse performance than JNI, however performance is not a big priority here I'd say (I don't expect the component to process any large number of requests, etc.). You might also want to have a look at BridJ