添加链接
link管理
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接

Barcode ComponentComponent that allows users to input barcodes using their own scanners. Uses prefix/postfix settings to capture barcode, or a regex pattern.

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.

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'
              

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.

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

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

image.png1093×765 56.3 KB

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.

image1192×419 55.1 KB

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)