PLC S7-1500 SQL-Connection - received data shifted by 1 byte --why?
Solution 1:
Sometimes weird memory stuff happens when the data type comprises an odd number of bytes.
Siemens starts each element on an even memory address. So if Length
is at address 0 and Data
is at 2-5, then address 1 may be getting the first byte that is intended for Data
Address | Data | Element |
---|---|---|
00 | 04 | Length 0 |
01 | 39 | |
02 | 30 | Data 0, byte 0 |
03 | 00 | Data 0, byte 1 |
04 | 00 | Data 0, byte 2 |
05 | 08 | Data 0, byte 3 |
06 | 47 | Length 1 |
07 | 94 | |
08 | 03 | Data 1, byte 0 |
09 | 00 | Data 1, byte 1 |
10 | 00 | Data 1, byte 2 |
11 | 00 | Data 1, byte 3 |
12 | 00 | Length 2 |
13 | 00 | |
14 | FD | Data 2, byte 0 |
15 | 10 | Data 2, byte 1 |
16 | 00 | Data 2, byte 2 |
17 | C1 | Data 2, byte 3 |