'Cannot Read struct with string from PLC using s7netplus c#
im trying to read this data block from Siemens S1500 PLC using s7netplus libary
and my mapped code struct looks like this
public struct testStruct
{
public bool Campo_Bool1;
public bool Campo_Bool2;
public short Campo_Int1;
public short Campo_Int2;
public int Campo_Dint1;
public int Campo_Dint2;
public double Campo_Real1;
public double Campo_Real2;
public string Campo_String1;
public string Campo_String2;
}
I'm using this command to read the struct
teststruct = (testStruct)client.ReadStruct(typeof(testStruct), 1);
Error message is "Please add S7StringAttribute to the string field"
How can I read this Structure?
Thank you very much.
EDIT 2.0: This is my new struct
public struct testStruct
{
public bool Campo_Bool1;
public bool Campo_Bool2;
public short Campo_Int1;
public short Campo_Int2;
public int Campo_Dint1;
public int Campo_Dint2;
public float Campo_Real1;
public float Campo_Real2;
[S7String(S7StringType.S7String,8)]
public string Campo_String1;
[S7String(S7StringType.S7String,8)]
public string Campo_String2;
}
New error message is "Received error from PLC: Address out of range."
This is my DB
Solution 1:[1]
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 |