Modbus TCP and SQLTag String

Hi,

A SQLTag, string type, 20 char. long, ex. HRS1:20. When you write it, let say ‘1234’, so less than the 20 maxi. char, the empty char are replaced by space (x20), not null (x00), causing some difficulties to my plc.
It’s the first time I see this behavior, is it normal ?

Ignition 7.6.3 (b2013090513)

Thank you

I had to check with the developers on this one, and it is supposed to write spaces. If you really need it to be nulls (0x00) then you’ll have to create the ascii string through scripting. You could even make a function out of it so you could use it all over the place. IE:[code]def padNulls(var):
# pad with 20 0x00’s
for i in range(20):
var = var+chr(0)
# return the first 20 characters
return var[:20]

print padNulls(“1234”)[/code]

Thank you. I’ll test it asap.

Best wishes for 2014.

I just ran into this issue writing string values to a Modicon device. One-liner to right pad the string with nulls (replace 12 with Modbus string length):

system.tag.writeAsync([tagPath], [value.ljust(12, chr(0))])