Barcode scanner input write to tag

I have a Datalogic QD2430 handheld USB barcode scanner. It currently just behaves like a keyboard and is configured with a [0D CR] suffix (the prefix and suffix are programmable).

Currently the operator clicks a text field, scans a serial #, clicks another text field, and scans a model #. My customer wants to combine these strings into a single barcode, so I’m trying to find a way to monitor the barcode scanner input in the background and when a code is scanned write the string to a tag so that I can parse the data in the PLC.

Using scripting, is it possible to use a specific prefix/suffix as a trigger to write the scanner data to a tag? Or is there some other method?

I do this:

I have a OPC tag as just raw data from BC scanner.

Looks something like this “<0D>19D03336A001<C/R>19000001905”
*the forward-slash is in <C/R> there so it displays here. < C R >

I have a tag change event on the value of this tag.

Then I split and trim it. And write it into different tags.

Hope this helps!
There are a million ways to do this but:

var = "<0D>19D03336A001<C/R>19000001905<GC>"
x = var.split(">")
y = x[1]
z = y.split("<")
print z[0]

Output: 19D03336A001

Thanks for the response!

Forgive me for my ignorance as this is my first Ignition project… How are you getting the raw barcode data into the tag? When you say you have an OPC tag as the raw data, I’m assuming that your scanner is sending the data to a PLC and the PLC tag is linked to an OPC tag. My BC scanner is connected directly to the client PC and cannot communicate directly with the PLC, this is why I’m hoping to have Ignition monitor the scanner and write the raw data to an OPC tag so I can use the data in the PLC.

No worries…

So your device is operating as a keyboard wedge. So in your page that they filling out this form or whatever you could use expressions to populate the fields. I do this as well. I don’t use the bar code scanner component I just use a regular text entry field. Then I BIND other fields to this source value and use the same methods to split it up. But, I do it with expressions. Then I have like a save or submit button. Which will take those expression values and call system.tag.writeBlocking in the script that fires when button is clicked.

For example… On one of my pages on start-up this text entry component appears and on the composition end event a scrip is called to hide the visibility. The <c/r> at the end of the string will tab to the next field in order. This fires that composition end event. This event will toggle the visibility of that component. I don’t want this janky string “<0D>19D03336A001<C/R>19000001905” where they can see it or manipulate it. (control - J) brings up the menu to attach these scripts and what not to these events…

So after that is populated I have labels with the self.props.text property expression bound to the same property of my now invisible component with the janky string…

So janky invisible string populates a couple of labels with the formatted data.

Understanding these bindings and types of bindings and transforms is key… for doing this kind o fstuff on the front.

then at the end of the day, I use these sets of formatted data, in my script that gets called when the button is clicked

var1 = self.getSibling("count").props.text
var2 = self.getSibling("part").props.text
var3 = 	self.getSibling("heat").props.text
# Specify the paths
paths = [
# Specify the values
values = [
# Send the writes off
system.tag.writeBlocking(paths, values)

I also have some scanners and scales I just use TCP driver and the telnet port. 23? I think. Alot of scanners work like this too… That is the easiest method. I am not familiar with this device…

Also, I don’t know if it’s advisable to do it this way. There are some old heads here that could weigh in. In my case I have a lot of projects that run only on one client. I also have quite a bit of hp in terms of physical server computing power. I know very little about best practices. I just get it done. Which is what is nice about ignition and perspective honestly.

OK great, thanks again.