# Help with Zebra Barcode Scanner in Perspective

**URL:** <https://forum.inductiveautomation.com/t/help-with-zebra-barcode-scanner-in-perspective/98311>\
**Category:** Ignition\
**Tags:** ignition81, perspective\
**Created:** [November 6, 2024, 11:05pm UTC](https://forum.inductiveautomation.com/t/help-with-zebra-barcode-scanner-in-perspective/98311 "2024-11-06T23:05:12Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ryan\_Crawford](https://avatars.discourse-cdn.com/v4/letter/r/a587f6/32.png) [@Ryan\_Crawford](https://forum.inductiveautomation.com/u/Ryan_Crawford)\
**Post date:** [November 6, 2024, 11:05pm UTC](https://forum.inductiveautomation.com/t/help-with-zebra-barcode-scanner-in-perspective/98311/1 "2024-11-06T23:05:12Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![csjohnson](https://avatars.discourse-cdn.com/v4/letter/c/5f8ce5/32.png) [@csjohnson](https://forum.inductiveautomation.com/u/csjohnson)\
**Post date:** [November 7, 2024, 3:46am UTC](https://forum.inductiveautomation.com/t/help-with-zebra-barcode-scanner-in-perspective/98311/2 "2024-11-07T03:46:06Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Ryan\_Crawford](https://avatars.discourse-cdn.com/v4/letter/r/a587f6/32.png) [@Ryan\_Crawford](https://forum.inductiveautomation.com/u/Ryan_Crawford)\
**Post date:** [November 7, 2024, 1:09pm UTC](https://forum.inductiveautomation.com/t/help-with-zebra-barcode-scanner-in-perspective/98311/3 "2024-11-07T13:09:51Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![dkhayes117](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/dkhayes117/32/68344_2.png) [@dkhayes117](https://forum.inductiveautomation.com/u/dkhayes117)\
**Post date:** [November 7, 2024, 1:37pm UTC](https://forum.inductiveautomation.com/t/help-with-zebra-barcode-scanner-in-perspective/98311/4 "2024-11-07T13:37:01Z")

</div>

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:

```python
barcode = '1234'
scanner output
>>> $1234|

```

---

<div class="post-metadata">

**Author:** ![Ryan\_Crawford](https://avatars.discourse-cdn.com/v4/letter/r/a587f6/32.png) [@Ryan\_Crawford](https://forum.inductiveautomation.com/u/Ryan_Crawford)\
**Post date:** [November 7, 2024, 2:13pm UTC](https://forum.inductiveautomation.com/t/help-with-zebra-barcode-scanner-in-perspective/98311/5 "2024-11-07T14:13:03Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![dkhayes117](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/dkhayes117/32/68344_2.png) [@dkhayes117](https://forum.inductiveautomation.com/u/dkhayes117)\
**Post date:** [November 7, 2024, 2:14pm UTC](https://forum.inductiveautomation.com/t/help-with-zebra-barcode-scanner-in-perspective/98311/6 "2024-11-07T14:14:18Z")

</div>

> [@Ryan\_Crawford](#):
>
> I connect the scanner and open notepad, scan something, I should then see the result as text in notepad

Yes

> [@Ryan\_Crawford](#):
>
> 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

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

---

<div class="post-metadata">

**Author:** ![csjohnson](https://avatars.discourse-cdn.com/v4/letter/c/5f8ce5/32.png) [@csjohnson](https://forum.inductiveautomation.com/u/csjohnson)\
**Post date:** [November 7, 2024, 2:14pm UTC](https://forum.inductiveautomation.com/t/help-with-zebra-barcode-scanner-in-perspective/98311/7 "2024-11-07T14:14:34Z")

</div>

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'.

---

<div class="post-metadata">

**Author:** ![dkhayes117](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/dkhayes117/32/68344_2.png) [@dkhayes117](https://forum.inductiveautomation.com/u/dkhayes117)\
**Post date:** [November 7, 2024, 2:15pm UTC](https://forum.inductiveautomation.com/t/help-with-zebra-barcode-scanner-in-perspective/98311/8 "2024-11-07T14:15:40Z")

</div>

> [@csjohnson](#):
>
> 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.

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [November 7, 2024, 2:16pm UTC](https://forum.inductiveautomation.com/t/help-with-zebra-barcode-scanner-in-perspective/98311/9 "2024-11-07T14:16:07Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![csjohnson](https://avatars.discourse-cdn.com/v4/letter/c/5f8ce5/32.png) [@csjohnson](https://forum.inductiveautomation.com/u/csjohnson)\
**Post date:** [November 7, 2024, 2:28pm UTC](https://forum.inductiveautomation.com/t/help-with-zebra-barcode-scanner-in-perspective/98311/10 "2024-11-07T14:28:25Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Ryan\_Crawford](https://avatars.discourse-cdn.com/v4/letter/r/a587f6/32.png) [@Ryan\_Crawford](https://forum.inductiveautomation.com/u/Ryan_Crawford)\
**Post date:** [November 7, 2024, 2:45pm UTC](https://forum.inductiveautomation.com/t/help-with-zebra-barcode-scanner-in-perspective/98311/11 "2024-11-07T14:45:25Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Ryan\_Crawford](https://avatars.discourse-cdn.com/v4/letter/r/a587f6/32.png) [@Ryan\_Crawford](https://forum.inductiveautomation.com/u/Ryan_Crawford)\
**Post date:** [November 7, 2024, 7:23pm UTC](https://forum.inductiveautomation.com/t/help-with-zebra-barcode-scanner-in-perspective/98311/12 "2024-11-07T19:23:50Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![dkhayes117](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/dkhayes117/32/68344_2.png) [@dkhayes117](https://forum.inductiveautomation.com/u/dkhayes117)\
**Post date:** [November 7, 2024, 8:15pm UTC](https://forum.inductiveautomation.com/t/help-with-zebra-barcode-scanner-in-perspective/98311/13 "2024-11-07T20:15:43Z")

</div>

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

```python
$91613727|102103310777|934366602|942000!

```

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

---

<div class="post-metadata">

**Author:** ![Ryan\_Crawford](https://avatars.discourse-cdn.com/v4/letter/r/a587f6/32.png) [@Ryan\_Crawford](https://forum.inductiveautomation.com/u/Ryan_Crawford)\
**Post date:** [November 8, 2024, 12:51pm UTC](https://forum.inductiveautomation.com/t/help-with-zebra-barcode-scanner-in-perspective/98311/14 "2024-11-08T12:51:10Z")

</div>

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:

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/6/4/64c92085087406227d637560b5b55ce727618ba5.png)

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

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

```

Any suggestions?

---

<div class="post-metadata">

**Author:** ![dkhayes117](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/dkhayes117/32/68344_2.png) [@dkhayes117](https://forum.inductiveautomation.com/u/dkhayes117)\
**Post date:** [November 8, 2024, 1:04pm UTC](https://forum.inductiveautomation.com/t/help-with-zebra-barcode-scanner-in-perspective/98311/15 "2024-11-08T13:04:14Z")

</div>

> [@Ryan\_Crawford](#):
>
> !$91613727102103310777934366602942000!

~~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 `$`

---

<div class="post-metadata">

**Author:** ![dkhayes117](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/dkhayes117/32/68344_2.png) [@dkhayes117](https://forum.inductiveautomation.com/u/dkhayes117)\
**Post date:** [November 8, 2024, 1:17pm UTC](https://forum.inductiveautomation.com/t/help-with-zebra-barcode-scanner-in-perspective/98311/16 "2024-11-08T13:17:53Z")

</div>

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.

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

```

---

<div class="post-metadata">

**Author:** ![Ryan\_Crawford](https://avatars.discourse-cdn.com/v4/letter/r/a587f6/32.png) [@Ryan\_Crawford](https://forum.inductiveautomation.com/u/Ryan_Crawford)\
**Post date:** [November 8, 2024, 1:25pm UTC](https://forum.inductiveautomation.com/t/help-with-zebra-barcode-scanner-in-perspective/98311/17 "2024-11-08T13:25:02Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![dkhayes117](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/dkhayes117/32/68344_2.png) [@dkhayes117](https://forum.inductiveautomation.com/u/dkhayes117)\
**Post date:** [November 8, 2024, 1:27pm UTC](https://forum.inductiveautomation.com/t/help-with-zebra-barcode-scanner-in-perspective/98311/18 "2024-11-08T13:27:10Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Ryan\_Crawford](https://avatars.discourse-cdn.com/v4/letter/r/a587f6/32.png) [@Ryan\_Crawford](https://forum.inductiveautomation.com/u/Ryan_Crawford)\
**Post date:** [November 8, 2024, 1:32pm UTC](https://forum.inductiveautomation.com/t/help-with-zebra-barcode-scanner-in-perspective/98311/19 "2024-11-08T13:32:13Z")

</div>

Ah ha, we are in bussiness,  
 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/b/f/bf2a1d3822b8d6dc3e68eb802be17b5bf7a716ca.png)

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/1/6/16d94ab0f57ee51b7df107487c0f57636dbfde56.png)

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

---

<div class="post-metadata">

**Author:** ![dkhayes117](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/dkhayes117/32/68344_2.png) [@dkhayes117](https://forum.inductiveautomation.com/u/dkhayes117)\
**Post date:** [November 8, 2024, 1:37pm UTC](https://forum.inductiveautomation.com/t/help-with-zebra-barcode-scanner-in-perspective/98311/20 "2024-11-08T13:37:38Z")

</div>

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

[Next page](https://forum.inductiveautomation.com/t/help-with-zebra-barcode-scanner-in-perspective/98311.md?page=2)
