Read byte to ascii characters

A more ‘pythonic’ way, along with reading the tags in reverse order.

# generate tag list
tagPath = '[default]Test/PartNumber'
tagList = []

for i in range(15,0,-1):
  tagList.append(tagPath+'/PartNo_Char'+str(i))

# read all the tags
tagValues = system.tag.readAll(tagList)

stringOut = ''.join(chr(tag.value) for tag in tagValues if 32 <= tag.value < 127)

system.tag.write(tagPath+'/PartNo', stringOut)
1 Like