Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Professional Discussion / Capturing Barcodes from LS2208

Author
Message
GIDustin
18
Years of Service
User Offline
Joined: 30th May 2008
Location:
Posted: 2nd May 2013 23:22 Edited at: 2nd May 2013 23:24
I am trying to connect an LS2208 barcode scanner to my program so that I can scan typical UPCs. It is working great, but not in DBPro. The scanner can be set so that is sends keystrokes with the data. Currently I have it set to:

Send F12 Key
Send Barcode
Send F7 Key

It works fine in other applications that use a keypress buffer. When I scan a barcode, it does whatever is tied to F12, then types out the barcode, then does whatever is tied to F7. Meaning, if I scan a barcode with Paint Shop Pro focused, it opens the "Save As" dialog.

The problem is that it sends these in a manner that I am not sure DBPro can handle. The barcode itself is added to the keyboard buffer, so I can get that with ENTRY$(). The "F" keys are just simulated, so it sends a KEY_DN, then a KEY_UP immediately after. With DBPro's KEYSTATE command, unless you are running thousands of checks per second, you will completely miss the keystate changing to 1 and back, and it will seem as if it was never pressed.

Does anyone have any ideas on how to capture these micro-keypresses?

Edit: I have read through the 300 page programming manual for the scanner. You can increase the delay between each keypress, but not the duration of each keypress, as best I can tell.
James H
19
Years of Service
User Offline
Joined: 21st Apr 2007
Location: St Helens
Posted: 3rd May 2013 00:39
I`ll probably be of no help here, but out of curiosity are you saying that comparing keystate of any two frames isnt fast enough?
GIDustin
18
Years of Service
User Offline
Joined: 30th May 2008
Location:
Posted: 3rd May 2013 00:41
Quote: "are you saying that comparing keystate of any two frames isnt fast enough?"


That is exactly what I am saying. I am thinking I will have to do something like collect windows messages and create my own "keystate" system...
sladeiw
17
Years of Service
User Offline
Joined: 16th May 2009
Location: UK
Posted: 4th May 2013 00:55 Edited at: 4th May 2013 00:56
Can you use GetAsyncKeyState? You can test if the key was pressed since the last call, so it doesn't matter how long since the last check.


Phaelax
DBPro Master
23
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 4th May 2013 07:56
Why can't you just grab the entire string it returns then parse out the function keys later? The barcode scanners I've worked with before will send a return key press at the end of the string so you know it's done.

"You're all wrong. You're all idiots." ~Fluffy Rabbit
GIDustin
18
Years of Service
User Offline
Joined: 30th May 2008
Location:
Posted: 4th May 2013 07:57
You can program what keys it sends before and after, but unless it is something that shows up in the keyboard buffer using entry$(), you are likely to miss it.

I will look into the GetAsyncKeyState. That might be what I need.
Phaelax
DBPro Master
23
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 4th May 2013 08:00
I thought the character codes were still present in the string returned by entry$ even if they don't have a visible character.

"You're all wrong. You're all idiots." ~Fluffy Rabbit
sladeiw
17
Years of Service
User Offline
Joined: 16th May 2009
Location: UK
Posted: 4th May 2013 11:07
Quote: "I thought the character codes were still present in the string returned by entry$ even if they don't have a visible character."


A quick check testing the len() of entry$ showed F-keys don't register.

I used a serial barcode reader for my app because keyboard-input ones are a nightmare seperating barcode and keyboard input. Especially if you want to scan barcodes at ANY time, without having to have a certain edit field active or even visible. They are old now, but I can't find a way of getting a USB scanner to work in the same fashion. (ie. directly query the driver)
Van B
Moderator
23
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
Posted: 4th May 2013 13:42
We use the keyboard USB ones at work, but they are fairly straightforward, just alphanumeric strings inbetween '*' - so it's easy with those to decipher what has been scanned. Could you change those F-key's for a rarely used ascii character, which would be picked up by entry$()?

I got a fever, and the only prescription, is more memes.
GIDustin
18
Years of Service
User Offline
Joined: 30th May 2008
Location:
Posted: 6th May 2013 16:12 Edited at: 6th May 2013 16:13
Quote: "I used a serial barcode reader for my app because keyboard-input ones are a nightmare seperating barcode and keyboard input. Especially if you want to scan barcodes at ANY time, without having to have a certain edit field active or even visible. "


This is why I have programmed the scanner to send F12 before the code, and F7 afterwards. The F12 key moves the input to the UPC field, and the F7 displays the results.

I went through to try to find a rarely used character, and could not. We apparently use almost every character for one reason or another. Slade got me thinking about windows commands. All of my apps keep track of keyboard input using something like this:


Whenever KEY_PRESSED is true, it fires a "KEY_UP" event, and when KEY_PRESSED2 is true, it fires a "KEY_DOWN" event. This small piece of code is what currently could not detect the incredibly tiny key press sent by the scanner. So using IanMs set message callback "WndProc", I put this together


This sets the current state of the key to 1, which then means the next loop my keyboard loop above will think the key was just released, and fire the KEY_UP event as usual.

So far it hasn't missed a scan, so I think we got this one covered. Thanks for everyone's help!

Login to post a reply

Server time is: 2026-07-06 18:33:31
Your offset time is: 2026-07-06 18:33:31