検索機能を使用して 500 を上回る Kepware の知識ベース記事の中から閲覧します。結果を絞り込むか、クエリーを下部の検索フィールドに入力します。

解決策が見つからなかった場合には、当社の PTC eSupport Portal で追加資料を確認することもできます。eSupport Portal へのログインを要求された場合、My Kepware の認証情報を使用できます。My Kepware アカウントが必要ですか? こちらで作成

各種検索方法:
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: 2018/11/07

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.