How to read string from PLC from DB560 with offset 0.0 and size 12 bytes. Garbage value is coming at the output.
S7Client client = new S7Client();
client.SetConnectionType (S7.S7_BASIC);
int res = client.ConnectTo("192.168.0.1", 0, 1);
byte[] data = new byte[12];
client.ReadArea(S7.S7AreaDB, 560, 0, 12, data);
String ret = S7.GetStringAt(data,0,12);
System.out.println(ret);
The first 2 bytes of the S7 data type string are as follows:
Positon n: Maximum length
Postion n+1: Current length
Because of this the first character is not at position n but at positon n+2.
Alternative:
Or you change the moka7 code to something like this (this is the code of sharp7):