M
M
MutexMan2021-12-01 14:32:47
C++ / C#
MutexMan, 2021-12-01 14:32:47

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();

I connect via NetToPLCsim to S7-PLCSIM1 from STEP7 (V 5.6)
The following is displayed in the console:
Begin
Connection OK

GetErrorProtection : 0
Protection level
sch_schal : 1
sch_par : 1
sch_rel : 1
bart_sch : 3
anl_sch : 0

Status : 4

DB1 Read Error : 12582912, CPU : Item not available
Click to end the program

I don't understand why the error! It turns out that the connection goes. Data exchange goes on too, since the machine receives PLC statuses. But block DB1 cannot be read. Created test PLC in Step7. The configuration only has a DB1 block of 12 bytes. The CPU in the STEP7 project is CPU 315-2 PN/DP.

Can someone explain what's wrong?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question