Reputation: 4303
When I am trying to write an integer to an integer Database field I am successful:
byte[] db13buffer = new byte[buffer];
var shorty = short.Parse(valuesForPlc[i]);
S7.SetIntAt(db13buffer, 0, shorty);
int writeResult2 = client.DBWrite(dbnumber, start, size, db13buffer);
How can I write a Boolean (true) value to The database?
I have the following database structure in the plc:
Upvotes: 1
Views: 3048
Reputation: 798
To set a bit in a data block use the following helper function of Sharp7.S7:
void SetBitAt(ref byte[] Buffer, int Pos, int Bit, bool Value)
To set the bit Boolean use the following code:
S7.SetBitAt(ref db13buffer, 4, 0, true);
To set the bit Boolean at position 4.0 the size of db123buffer must be at least 6 bytes.
Upvotes: 1