Siemens string starting with different ascii char

Hi all,

I’m getting a bit confused on how Siemens strings work in Ignition.

In my Ignition project I’m correctly reading few strings from a S7 Siemens PLC.
Some of them are good, others are shown blank even if there is something at the PLC (and have no errors in Ignition).

Comparing the two strings (the one I can read and the blank one) I’ve noticed that the first two chars of both strings are different.

Below the chars at the PLC (as HEX)

The correct one has
B#16#30
B#16#0F (this can be different for other working strings)
B#16#53 - start of the string

The one showing blank has
B#16#00
B#16#12 - this char seems a bit odd
B#16#48 - start of the string

Do you know if there is any reason why the second one is blank?
Any easier solution instead of using Chars and putting together the string with a script?

Thank you!

You should be able address the whole string at once, though I’m rusty on my Siemens and don’t have a reference to boot up right now.

But I think its something along the lines of DB###,STRING53.30, where the numbers are your datablock number, the 53 is the address it starts and 30 is the length.

Added the manual for reference as well.
https://docs.inductiveautomation.com/display/DOC81/Siemens

Your second string is invalid. The Siemens String datatype has the maximum length in the first byte and the actual length in the second byte.

1 Like

Hi,

Thank you for your reply.
I’m actually able to read the strings with the correct addressing system.

Apparently every time the second char of the string has the code B#16#12 it will appear blank in Ignition.

In example at DB1101 I have the following string.
Capture

If I use [PLC]DB1101,STRING21016.48 I get back a blank string with no error in Ignition
If I try [PLC]DB1101,STRING21017.47 I get the correct string without the first character, as expected.

If I try pointing [PLC]DB1101,STRING21560.48 (where the offset has the same string lenght) I get another string correctly.

Hope t’s clear :slight_smile:
Thank you

Ok, this makes more sense.
Any reason why WinCC can read this string anyway?

As far as i know, Siemens checks the maximum length only when writing to the variable with the S7 string functions.

1 Like

Thank you chi!

I will double check how the s7 software writes the strings since I believe this information comes from an external source I don’t have access.
In any case it might be simpler to read chars and re-create the string using some scripting.

Thank you

As long as the external system does not touch the max length byte, you could try to simply write a value to that byte.