Verwenden Sie die Suchfunktion, um das Kepware Repository mit mehr als 500 Wissensdatenbank-Artikeln anzuzeigen. Grenzen Sie die Ergebnisse ein, oder geben Sie Ihre Abfrage im Suchfeld unten ein.

Wenn Sie keine Lösung finden, stehen Ihnen alternativ weitere Ressourcen zur Verfügung: unser PTC eSupport Portal. Wenn Sie aufgefordert werden, sich beim eSupport Portal anzumelden, können Sie die Anmeldeinformationen für „My Kepware“ verwenden. Benötigen Sie ein Konto für „My Kepware“? Hier können Sie ein Konto erstellen.

Lösungsergebnisse durchsuchen nach:
View All Solutions

Kepware Knowledge Base: Solution


The Server Returns a String from the S7-1200 PLC with the First Two Characters Missing


Last Update: 07.11.2018

Problem:
The first two characters are missing when reading a string from a data block in a Siemens S7-1200 PLC.

Possible Cause:
A string that is created in a data block in the S7-1200 PLC will have a fixed length of 256 bytes. Its first two bytes tell the length of the current string data and the maximum length of the string. In order to be a specific length in a PLC data block, the string must be created as an array of characters. In both types of data blocks, the end of the string will be marked with a null terminator. If a tag is created as a string in the server, the driver will always treat the first two bytes as the length fields. As a result, it will not read them. For example, an array of 18 characters is created in "DB 12" and is initialized to the value of "KEPWARE". If a tag is then created in the server with an address of "DB12,STRING0,18" a value of "PWARE" will be displayed in the client. This is because the driver assumes that the first two bytes are length data. If a tag is created in the server with an address of "DB12,C0,18" and the data type is set to string, the entire string will be displayed as a value in the client.

Solution:
When reading true strings from a data block, use the String address type. Alternatively, use the character address types to ensure that the leading characters are not ignored.