Gateway script returning different results than the script console

Hello all, I am somewhat ne w to ignition and am having trouble getting a gateway script to work correctly. I wrote and tested the script in the script console where it worked fine. I then copied and pasted the script into a function, then called the function from a gateway timer script. When this evaluates in the gateway script, the script returns different results then when run in the script console.

Basically I am reading in strings from a PLC tag. One set of string tags is populated by a P&F RFID read into an Allen Bradley PLC. These are referenced to in the logs and script as "on arm" tags or STAT tags. The second set of tags is written from ignition to the PLC earlier inthe process, then I read them back for a quick comparision to see if any of the informtion has been updated. In the logs and scripting they are refered to as "in database" or CMD tags.

When the gateway script runs, the tags generated from the RFID read all have multiple question marks after the data as shown in the Wrapper log attached. in the code also shown below, you can see that I have attempted 3 different methods manipulating this informtion on the read including stripping the extra characters as a seperate step. Unfortunatly this does not work and causes by compares to evaluate incorrectly.

Can anyone tell me why these extra characters show up in the gateway execution and not the script console execution? More importantly can anyone tell me how to get rid of the extra characters?

Below you should find the ignition code running, an except from the wrapper log showing one evaluation of the code and an except from the gateway log showing a different evaluation of the same code for the same event.

Thanks in advance.

                STAT_RFID ="[default]" + ASRS + "/ASRS_SystemCMD/STAT_MoldData/RFID").value"RFID on arm = " + str(STAT_RFID))
		STAT_PartNumber = str("[default]" + ASRS + "/ASRS_SystemCMD/STAT_MoldData/PartNumber").value)"Part number on arm = " + str(STAT_PartNumber))
		STAT_JobNumber = str("[default]" + ASRS + "/ASRS_SystemCMD/STAT_MoldData/JobNumber").value)
		STAT_JobNumber = STAT_JobNumber.rstrip("?")"Job number on arm = " + str(STAT_JobNumber))
		STAT_SpecialLotNumber ="[default]" + ASRS + "/ASRS_SystemCMD/STAT_MoldData/SpecialLotNumber").value.rstrip("?")"Special lot number on arm = " + str(STAT_SpecialLotNumber))"")
		CMD_RFID ="[default]" + ASRS + "/ASRS_SystemCMD/CMD_MoldData/RFID").value"RFID in database = " + str(CMD_RFID))
		CMD_PartNumber ="[default]" + ASRS + "/ASRS_SystemCMD/CMD_MoldData/PartNumber").value"Part number in datasbase = " + str(CMD_PartNumber))
		CMD_JobNumber ="[default]" + ASRS + "/ASRS_SystemCMD/CMD_MoldData/JobNumber").value"Job number in datasbase = " + str(CMD_JobNumber))
		CMD_SpecialLotNumber ="[default]" + ASRS + "/ASRS_SystemCMD/CMD_MoldData/SpecialLotNumber").value"Special lot number in datasbase = " + str(CMD_SpecialLotNumber))"")
		write = 0
			if STAT_PartNumber != CMD_PartNumber:
				write = 1
			if STAT_JobNumber != CMD_JobNumber:
				write = 1
			if STAT_SpecialLotNumber != CMD_SpecialLotNumber:
				write = 1
			#print "Write = " + str(write)
			if write == 1:
				if len(CMD_SpecialLotNumber) == 0:
					#system.tag.writeBlocking(["[default]" + ASRS + "/ASRS_SystemCMD/CMD_MoldData/SpecialDipProfile"],[0])"Special dip profile = 0")
					#system.tag.writeBlocking(["[default]" + ASRS + "/ASRS_SystemCMD/CMD_MoldData/SpecialDipProfile"],[-1])"Special dip profile = -1")
				#system.tag.writeBlocking(["[default]" + ASRS + "/ASRS_SystemCMD/CMD_RFID_Write"],[1])"Updating RFID tag")
			else:"RFID tag update not required")
		else:"Mold RFID does not match expected RFID")

Your post title betrays a failed assumption: that the script console is supposed to behave the same as a gateway event. It does not.

Look at the documentation for the script functions you are using. Each has separate syntax described based on the scope it is called from. (And keep in mind that project library scripts have no scope of their own--they run in their callers' scope.)

Designer scope is a variant of Vision Client scope.

I'm going to guess that you have null (or other unprintable) characters in your string.

What happens if you read a stat tag in the in the script console, then print it using repr()?

# String with null character
a = '123\x00'

print a 
print repr(a)



So you were correct, the string had a bunch of null characters that I was able to strip using the .rstrip("\x00") when bringing the tag data into the script before checking to see if they are equal.

Script has been tested and is runing in production.

Thanks for the help.

1 Like