tags:

views:

220

answers:

3

I am working on reading the barcode using a scanner and I have the following questions:

  • Is there a way to distinguish between the input from the keyboard and input from the scanner ? This is required for me because the barcode reader will include a preamble, terminator and a prefix to the barcode value. For ex, if the value is 12345 the barcode will have \pre12345\ where \ and \ indicate the start and end and pre identifies the type of data. If I know that the data is being typed from keyboard and not from a scanner then I would show whatever the user types. If I know that the data is from a scanner then I will strip of the \pre and \ and show only the data.

Thanks,

A: 

well yes! input from the barcode scanner should have first initialized itself through a COM port or serial connection. I know that many apps restrict input to certain field through specific ports, but beyond that I'm not sure.

Joseph Silvashy
I want to implement a generic solution which is not dependent on the type of the scanner.
Ragha J
+1  A: 

My answer assumes that you are using a barcode scanner in "keyboard wedge" mode where it simply emulates a keyboard and does not have some special connection. These devices are often USB and work this way out of the box without any further configuration.

Would the user ever have occasion to actually type your \pre text? Often the prefix is chosen specifically to be a set of characters that the user will never enter or will at least very rarely want to enter. Thus, the mere presence of the prefix indicates a scanned barcode.

Another option would be to time the input. For example, the input from the barcode scanner will probably all be complete within a very short time (e.g. 50ms). If a user were typing the value via the keyboard, it would be impossible for him/her to type the prefix, the data and the postfix all within 50ms. (Of course, assumption here is that input will be made by an actual human and not by automated tools)

Scott W
Yes there is a possibility that the user may enter \pre as text and at that time I should not treat it as scanner input. In case where there is not pre and only \ and the user enters \ I should be able to recognize that it is coming from keyboard and show it.Also if the user enters \ and waits before entering any more text, if I dont know that it is coming from keyboard I will be showing the text to the user after a delay (the timeout) and this may confuse the user.
Ragha J
Can you choose a different \pre that the user is unlikely to enter manually? As for the delay, a delay of 50ms will be hardly noticeable to the user. Another option would be to display everything immediately, just go back and strip off the \pre if the full data is entered before the timeout expires.
Scott W
A: 

One solution that I came up with was to start all of our barcodes with a unique sequence of characters not known to the user. I check for this sequence on the input to tell me how the data was entered.