Use the search feature to view Kepware's repository of more than 500 Knowledge Base articles. Narrow your results or type your query into the search field below.

Alternatively, if you are unable to find a solution, we have an additional resource - our PTC eSupport Portal . If you are prompted to log into the eSupport Portal, you can use your My Kepware credentials. Need a My Kepware account? Create one here .

Search Solution Results By:
View All Solutions

Kepware Knowledge Base: Solution

Siemens S5 Byte Swapping in Strings

Last Update: 11/7/2018

In KEPServerEX V5.15, the Siemens S5 driver was enhanced to support byte swapping for the String data type. Strings can be from 2 to 254 characters (bytes) in length. All strings are assumed to be in a HiLo byte order, meaning that for each register (which is 2 bytes in length) there can be 2 characters. An issue can occur if an odd string length is used or if an odd number of characters is written to the string and the incorrect byte order is used.

For example, assume that there is a tag with the address "DB1:KS0.5H" and with a value of "AFTER" written to it. If users read it from a tag with an address of "DB1:KS0.5L" they would see a value of "FAET". This is because the tag is consuming DB1 Register 0, 1, and 2. The actual value stored in the three registers is 0x414651455200. The last byte of the string is the string terminator, which is a Null (0x00). When the byte order is swapped, the registers are essentially viewed as having a value of 0x464145540052. When updating the tag value, the driver stops at the null value. This will also occur anytime a non-printable character is included in the string. PLC programmers should avoid including control characters (0x01 to 0x1F) or any extended characters (0xA0 to 0xFF) in registers that will be read as part of a string.

Related Products
Siemens S5

Related Protocols
Siemens S5 3964(R)