[Bug-12230]Barcode scanner input component questions

Trying out the new barcode component. What format/language should the regex be in? Can’t figure out java vs python regex… I’m trying to capture everything between a \x02 and \x03.

The component uses Javascript’s regex. It should be easier to use the prefix/postfix for that case though. The component also requires a specific output type from the devices barcode app, so you might have to try different output options. On the device we were using it called was Keyboard Mode.

2 Likes

Ok. I tried a few more variations but no luck.

I am just trying the prefix/suffix right now. If I put standard characters in there is works fine… but the \cB and \cC don’t seem to match any content.

Here is an example of the raw output of the scanner. If i setup the barcode component to “[” and “@” it comes across fine, so I know its working. But no dice on the control characters.

u'\x02[)>@O6@PA5931KESTR-1-J-DE-00@1P10795TR@12VALLEGRO@10VUSA-MANCHESTER@20P@9D1832@6D20181115@14D20231114@Z2@Q1500NAR000@20T1@1T1832967HNAA@2TN/A@1Q1500@2Q0@1Z7B2AEC8F0BB7490389517A21118CDB@@\x03'

Have you tried \\cB or \\cC? This might be a Java string handling -> Javascript string handling issue.

I think one way Python has to write things like regexes is use

r'\x02[)>@O6@PA5931KESTR-1-J-DE-00@1P10795TR@12VALLEGRO@10VUSA-MANCHESTER@20P@9D1832@6D20181115@14D20231114@Z2@Q1500NAR000@20T1@1T1832967HNAA@2TN/A@1Q1500@2Q0@1Z7B2AEC8F0BB7490389517A21118CDB@@\x03'

instead of the u prefix. The r is for raw, and I believe its use is to handle the backslash issue - see the third line/paragraph here.

No luck with that. I’ll try a few more things. I’m wondering if there is some reason the control character keystrokes are not getting into Chrome…

Maybe try something like this for the regex (javascript). I did a little testing in the browser and it worked. Also make sure the window property is at least large enough to capture the longest expected scan plus start/end control characters.

\x02(.*)\x03

Hum, still no luck, I’ll have to try a few more things.

Is there any way to be able to print “all” incoming keyboard data to the browser for debugging? I’d like to try to see if the input data is coming across from the scanner into the browser.

You can try a debug page like this one: https://unixpapa.com/js/testkey.html

Looks like the events come into JS as two keypresses… would I still be able handle this somehow?

I’m not seeing a way currently - it would definitely rely on constructing the regex. \cB(.*)\cC seems like it would be the right format. I’ll make a ticket so someone with more frontend/JS knowledge can investigate.

For (my own) future sake - https://w3c.github.io/uievents/tools/key-event-viewer.html is a much better event logger than the one I first linked.

Hi again! So this had been working ok after some scanner reconfiguration, however I got a new model to setup and having issues again.

I was able to get around the issue before by putting the scanner into “keypad mode” which forces it to type all the data using alt codes in their native characters, so instead of CtrlC it will type ALT+0002.

I think I might have found a problem in the Barcode Component or in Zebra’s scanner firmware. If you look at the above, you see a keypress event for ETX however in may last post when the scanner types CtrlC, there is no keypress event. I wonder if this is why the barcode input component regex is not working?

However, if I check a few different javascript key testers, the scanner does still correctly throw Keycode 67, which should be the same thing.

Is there any updated logic in the barcode component, or some more technical details of how it is listening for events so I can craft a regex to work for all my scanners? Thanks!

Edit: Found some more info here, might not be the Zebra scanner which is why it works fine in Vision… Looks like Chrome/Android does not always send keypress events for ASCII controler characters, so you need to listen for keydown or similar. Developer Portal | Listening for KeyPress events with DataWedge (zebra.com)