• Post Reply Bookmark Topic Watch Topic
  • New Topic

Unique Barcode Scanners

 
Michael Clarke
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I have built a barcode scanner app, but I have a requirement to allow multiple barcode readers, but each barcode reader must write it's output uniquely.
So Barcode scanner A writes to Table A... Barcode scanner B writes to Table B... As soon as an ID card is scanned.

To do this I think I have to get the system to 'know' the identity of each barcode scanner connected and also get it to recognize which scanner is being used at any one time. Challenging I know, but I'm struggling and would appreciate any help.
 
Paul Clapham
Sheriff
Posts: 21881
36
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Michael, welcome to the Ranch!

I think you'd have to start by explaining how you connect one barcode scanner to your system, and also how you get your system to read from it.
 
Michael Clarke
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The barcode scanners are just connected via USB and input in the same way as a keyboard does.
For example, when I focus the cursur on a textfield and scan an ID card.. Let's say the barcode on that ID card is 123ABC. The scanner will input 123ABC into the textfield immediately after scanning the card.
 
Michael Clarke
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In other words there is no configuration needed. You just plug the reader into a USB port, scan a card, and it prints the output into whatever input field is in focus.
 
Paul Clapham
Sheriff
Posts: 21881
36
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So once you plug the reader into a USB port, it's like your computer now has two keyboards. The operating system is taking care of all of the details required to make the reader indistinguishable from the keyboard. So if my interpretation is correct, you can't even distinguish a barcode reader from somebody typing on the keyboard (except that they can't type as fast as the reader can). This makes it unlikely that you could distinguish two readers from your code.

However that's just my semi-educated guess. Maybe digging through the technical specs for the reader might unearth some technique for identifying a reader when you get input from it; I can't imagine how that would work but don't let that deter you from continuing your inquiries.
 
Tony Docherty
Saloon Keeper
Posts: 3138
72
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can you give details of the barcode scanner you are using and what initial setup you did to get it simulating a keyboard.
 
Michael Clarke
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, I'm using a Honeywell (ms9520) scanner. And there was no configuration - just plug in to a USB port.

I have come across JSSC - for identifying ports in Java. Wondered if you thought I was on the right track... Can anyone make sense of this:
http://www.codeproject.com/Tips/801262/Sending-and-receiving-strings-from-COM-port-via-jS
 
Tony Docherty
Saloon Keeper
Posts: 3138
72
 
Dave Tolls
Ranch Hand
Posts: 2279
24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Note that the linked to white paper for JavaPOS talks about setting up the CLASSPATH system environment variable.  Please don't.
Even at the time this was the wrong way to go about things.

Just add the jar files to your projects lib directory or whatever structure you're using.
If you want to run the test BAT file it mentions then I would recommend editing it to include the required jars in a classpath.
 
Tony Docherty
Saloon Keeper
Posts: 3138
72
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
To answer your question about JSSC, no I don't think it will help. Even if you do get the information on the USB ports that still isn't going to tell you which port (and hence which scanner) the input came from.

I've never used scanners via JAVAPOS but I have used JAVAPOS to interface to USB printers and was able to configure it so I had 2 USB printers attached to one computer and could send the output to the appropriate printer, so I'm guessing you can configure 2 (or more) scanners and get the input from each via separate listeners.
 
Michael Clarke
Greenhorn
Posts: 5
  • Likes 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In case anyone in future is having a similar issue. I managed to sort this by installing the relevant barcode scanner driver (downloaded from the retailer website). When you install the driver, the computer ceases to treat the scanner as just a regular keyport input, and will identify the scanner's connection via a com port (can be seen in device manager).

I then used a java class that fetches all available com ports, searches the registry for the name of the scanners, then cross checks the names with the port ID's. So "Scanner A = Com Port 1" for example.
I then used the same com class to receive input from the relevant com port and print it out in my application.

The necessary imports are:
java.io.*
java.util.*
jssc.*
 
Tony Docherty
Saloon Keeper
Posts: 3138
72
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for updating the thread with your solution.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!