Answer the question
In order to leave comments, you need to log in
Error reading DB1 block: CPU: Item not available?
Good day to all!
The following code doesn't work:
Console.WriteLine("Begin");
var client = new S7Client();
client.SetConnectionType(S7Client.CONNTYPE_BASIC);
int connectionResult = client.ConnectTo("192.168.0.106", 0, 2);
if (connectionResult == 0)
{
Console.WriteLine("Connection OK");
S7Client.S7Protection levelProtect = new S7Client.S7Protection();
int errorProtected = client.GetProtection(ref levelProtect);
Console.WriteLine();
Console.WriteLine("GetErrorProtection : " + errorProtected);
Console.WriteLine("Protection level");
Console.WriteLine("sch_schal : " + levelProtect.sch_schal);
Console.WriteLine("sch_par : " + levelProtect.sch_par);
Console.WriteLine("sch_rel : " + levelProtect.sch_rel);
Console.WriteLine("bart_sch : " + levelProtect.bart_sch);
Console.WriteLine("anl_sch : " + levelProtect.anl_sch);
Console.WriteLine();
int status = -1;
client.PlcGetStatus(ref status);
Console.WriteLine("Status : " + status + "\n");
var buffer = new byte[12];
int readResult = client.DBRead(1, 0, buffer.Length, buffer);
//int readResult = client.DBRead(1, 0, 4, buffer);
if (readResult == 0)
{
Console.WriteLine("DB1 Read OK");
bool db1dbx00 = S7.GetBitAt(buffer, 0, 0);
bool db1dbx01 = S7.GetBitAt(buffer, 0, 1);
bool db1dbx02 = S7.GetBitAt(buffer, 0, 2);
bool db1dbx03 = S7.GetBitAt(buffer, 0, 3);
Console.WriteLine(db1dbx00);
Console.WriteLine(db1dbx01);
Console.WriteLine(db1dbx02);
Console.WriteLine(db1dbx03);
}
else
{
Console.WriteLine("DB1 Read Error : " + readResult + "," +client.ErrorText(readResult));
}
}
else
{
Console.WriteLine("Connection ERROR : " + connectionResult + "," + client.ErrorText(connectionResult));
}
client.Disconnect();
Console.WriteLine("Для завершения программы нажмите <Enter>");
Console.ReadLine();
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question