使用搜索功能查看 Kepware 的信息库,其中包含 500 多篇知识库文章。缩小搜索结果范围,或在下面的搜索字段中输入您的查询。

或者,如果您无法找到解决方案,我们还有另一个资源:我们的 PTC eSupport Portal。 如果系统提示您登录 eSupport Portal,您可以使用“我的 Kepware”凭据。需要一个“我的 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/7

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.