System.tag.read breaking in update 8.1.36

I have string tag value I am reading from a PLC in Ignition that broke in all my scripts when I updated to 8.1.36 from 8.1.32 I am using this string in HTTP requests and all my requests suddenly started to fail after the update. It seems like python didn't recognize it as a string anymore. I have been running these scripts for about a year now, so I know it was the update that changed things.

To fix I had to explicitly tell Python it was a string. I have all my scripts fixed, but I am wondering what would cause this and why?

Thanks

Example
`myBarcode=system.tag.read('[.]RAW_BARCODE').value

Working
myBarcode=str(system.tag.read('[.]RAW_BARCODE').value)

Update:
Scripts are failing in the HTTP Request

conn = httplib.HTTPConnection(myConnection)	
conn.request("GET", "path=path" + myClient + "&service=service" + myBarcode)
res = conn.getresponse()
data = res.read()

system.tag.read has been deprecated (as of Ignition 8.0), so I wouldn't expect and action from IA on this.

You should be using system.tag.readBlocking() instead.

Try:

myBarcode = system.tag.readBlocking(['[.]RAW_BARCODE'])[0].value

and see if that works, if not, then I suspect there is something else happening.

For any newer scripts I have been using system.tag.readBlocking. I did update one to readBlocking when I was still tracking down the issue, it had the same effect, I needed to explicitly cast to a string to use it.

These older scripts sometime rear their head when we go through updates. I do plan on going through all our scripts and updating them to system.tag.readBlocking though.

What is the error that you are getting? If you log the type of the value prior to converting it, what type does it report having?

2 Likes

Look like the type is unicode when i do a type(tag) in the Script Console

type(system.tag.read('tag path').value) unicode

Unicode is a type of string. How did this break your scripts? Were you explicitly checking for the str type instead of basestring ?

2 Likes

The script broke in the HTTP request where I was building a string to do a GET request from a local webservice.

I know I should be using Ignition's HTTP Client vs httplib but these scripts were written along time ago and have been running with no issue. I have learned a lot of what not to do reading these forms and the documentation. I am just curious what made this break in the new update.

conn = httplib.HTTPConnection(myConnection)	
conn.request("GET", "path=path" + myClient + "&service=service" + myBarcode)
res = conn.getresponse()
data = res.read()

Ah, simple. You are using jython's stdlib for your network requests. Highly recommended you ditch all of that broken stuff. (Anything involving character encodings is likely to break in jython libraries.) Convert to Ignition's httpClient before the technical debt gets worse.

Thanks. I'm thinking I might as well bite the bullet and get all of our old scripts updated to Ignition's httpClient to avoid more instances like this. Sound like a good weekend project when everything is down.

A .format may (no promises with httplib) get you out of immediate trouble, but httpClient is going to be your best bet.

"path=path{}&service=service{}".format(myClient, myBarcode)