Help with Zebra Barcode Scanner in Perspective

Good Afternoon,

I have a Zebra barcode scanner connected to my PC, and I would like to use it to read a production order barcode that is a Datamatrix. I am currently working within Perspective but just need a little push in the right direction.

The format of the Datamatrix code is (91)XXXXX(10)XXXX(93)XXX(94)XXXX. I understand that I need to do the following:

  1. Connect the scanner.
  2. Drag the Barcode Scanner Input component onto the view.
  3. Set the prefix and suffix.
  4. Bind an array tag to the “barcode scanner input data”.
  5. Set up a barcode scan script under session events.

Is this the right approach? Any help would be greatly appreciated.

Thanks, Ryan

You are close.
First, it will do you a lot of good to set a unique prefix and suffix on the scanner. We use the dollar sign $ and a pipe |.
The scanner must also be in wedge mode.

You won’t use the session event to get the barcode data. That is only to be used with the perspective mobile app. It uses the mobile devices built in camera to scan codes.

Instead, create an onActionPerformed event on the barcode scanner input component. In that event, you can grab the latest data from props.data[0], then write it to a string tag. Once you do that, set props.data = None to clear the barcode data from the component.

Now it’s ready for the next barcode scan.

1 Like

Thanks for the response.

So when you say [quote="csjohnson, post:2, topic:98311"]
We use the dollar sign $ and a pipe |.
[/quote] that $ and | is specific to the contents of the barcode you are reading? Because if it is, I’m my case we will use the (number). So I would you (91) and (10) for example?

Also when you mentioned [quote="csjohnson, post:2, topic:98311"]
The scanner must also be in wedge mode
[/quote] that is something specific to the scanner I will need to setup?

Most USB scanners are in wedge mode automatically, which means it acts like a keyboard. Plug it into a laptop and scan something with notepad open to check.

The prefix/suffix characters are for framing the barcode to distinguish it from regular keyboard input. It is not part of the barcode and numbers should not be used.

Once you program your scanner, it should scan like this:

barcode = '1234'
scanner output
>>> $1234|
1 Like

Got ya.

So what your saying is, if I connect the scanner and open notepad, scan something, I should then see the result as text in notepad?

When you say are talking about prefix/suffix, your saying that it’s set by the user and is used in the script to see when the message starts and stops?

Yes

No, you program the scanner to add the prefix/suffix to every scan automatically.

For those Zebras, it is easiest to configure them using Zebra's 123 Scan software (free) but may require you have admin rights on the PC. Depending on if an IT dept is managing your PC. In my case, I have to run the software in Administrator mode and enter my admin credentials. (This is because the software is accessing some system level service/driver to communicate to the scanner, approximately.)

You can also configure the prefix/suffix using their configuration manual. You would scan various Datamatix codes to enter the prefix/suffix. A bit tedious but doable.

I'm not sure if using two-character numbers as the prefix/suffix would work. I've never tried that.
If your data is '9154310, I would expect the component to return '543'.

Even if it did work, that sounds like a headache waiting to happen.

Whatever else you do, pick a prefix and suffix that never show up anywhere else in the data of a scan.

1 Like

Yes it does.
Anyone who has had the pleasure of processing barcodes that is printed by a 3rd party with segmented data that you need to extract knows the pain. You spend a lot of time writing/editing regex to pull out data you need.

@Ryan_Crawford, whoever is printing these codes, it would be wise to at least reach out to them and let them know your plans and both agree on what characters should not exist within the data. Assuming you are scanning codes from a vendor or from whom you have relation with already. In other words, don't call WalMart and ask to talk to the person printing their barcodes. lol

1 Like

Got ya, well I’ll try do what I can. The barcodes are part of a project I’m involved with at a manufacturer I work at to read production order barcodes. So it’s all internal.

So yes you are corrrect, I did scan it and this was how it appears in notepad: 91613727|102103310777|934366602|942000

You need to add the prefix and suffix to the barcode via scanner programming so it scans something like this

$91613727|102103310777|934366602|942000!

Perspective will auto remove the $ and ! when you set them as the prefix/suffix characters.

Right, so making progress.

I have setup the zebra to be in wedge mode and have added a suffix and prefix and this is the result once scanned on note pad.
$91613727102103310777934366602942000!

I will then launch a live session but still am not getting anything on the igntion side.
This is my props tab:

With "data" bound to an string array tag with a on action event with the following script:

def runAction(self, event):
	tag_value = self.props.data(0)
	tag_value = "[default]Scanned Data"
	self.props.data = None 

Any suggestions?

Look at your barcode scan closer. It does not begin with $. Both prefix and suffix are ! which doesn't match your component props.

Edit: Scratch that your code does have the $

I assume you have the binding as bi-directional? The onActionEvent doesn't make sense with the binding as you are setting it to None every scan.

Tell me what exactly you are trying to do on a scan event.

I typically take the last scan`, do something with it, then set the data to hold that last scan only.

lastScan = self.props.data[-1]
# do something with the scan
...
# hold only one scan
self.props.data = [lastScan]

At this stage all I want to do, is read the data from the scan and pass it to a string. It has been set to bi-directional

Try removing the change script completely and keep just the bi-directional binding.

Ah ha, we are in bussiness,
image

Would you have any idea why those little rectangles are appearing in the displayed string?

I think that usually means there is a non-supported character in the string, and it doesn't know how to render it.