[Question] Barcode scanner

I have a button that scans a barcode when i press it because of the Scan barcode event on the onclick event.

Now I have scanned a barcode I want to display this in a label.
I’ve watched a video from inductive where this was explained and where pointed too the session.props.device.barcodes wich is not available.

I saw something about that the way this was handled is changed but not how we can do it now?

have you tried self.session.props.device.barcodes? I had to do that with some of mine to get it to work

We just changed how barcodes are received. Instead of appending to session.props.device.barcodes, we’ve added a script in Perspective > Session Events for handling barcodes.

so would a scripting call for that then be perspective.session.onBarcodeDataRecieved or system.perspective.session.onBarcodeDataRecieved? (Or something else?)

Any input on when the documentation will be updated with proper calls/other info?

https://docs.inductiveautomation.com/display/DOC80/Perspective+Session+Event+Scripts

I have figured it out and set the onBarcodeDataRecieved event to return the data to a tag.
Not the way it should be, but for now it works.

Hi @joostjojo - agreed that this isn’t the way it should be but to get me going can you please provide the script you used in your event? I took a stab at system.tag.write("[client]Scanned_Barcode", data) and no luck. I’m guessing I don’t have something right with the data argument.

Thanks

Perspective doesn’t have client tags. Use session properties.

3 Likes

Thanks @pturmel

Finally got into Perspective yesterday. This is going to take longer than I thought to get my head wrapped around it.

In case it helps any other Perspective noobs out there here is that line of code: session.custom.Scanned_Barcode = data[‘text’]

Also when writing to tags in perspective you have to provide your tag provider:

system.tag.write("[yourtagprovider]Scanned_Barcode", data)