C# snap7读写DB
使用C# snap7 读写db块
int Rack = 0, Slot = 2; // default for S7300
Client = new S7Client();
while (true)
{
if (Client.Connected())
{
}
else
{
PlcConnect("127.0.0.1", Rack, Slot);
}
if (true)
{
//PerformTests();
//Client.ReadArea()
byte[] writeBuffer = new byte[1024];
S7.SetIntAt(writeBuffer, 0, 15);
S7.SetIntAt(writeBuffer, 4, 15);
Client.DBWrite(1, 0, 8, writeBuffer);
byte[] buffer = new byte[1024];
Client.DBRead(1, 0, 8, buffer);
Console.WriteLine(S7.GetIntAt(buffer, 0));
Console.WriteLine(S7.GetIntAt(buffer, 4));
//Client.Disconnect();
}
}