Ejemplo n.º 1
0
        public int GetOrderCode(S7OrderCode Code)
        {
            S7Szl SZL = new S7Szl(1024);

            LastError = ReadSZL(0x0011, 0x0000, SZL);
            if (LastError == 0)
            {
                Code.Update(SZL.Data, 0, SZL.DataSize);
            }
            return(LastError);
        }
Ejemplo n.º 2
0
        public int GetProtection(S7Protection Protection)
        {
            S7Szl SZL = new S7Szl(256);

            LastError = ReadSZL(0x0232, 0x0004, SZL);
            if (LastError == 0)
            {
                Protection.Update(SZL.Data);
            }
            return(LastError);
        }
Ejemplo n.º 3
0
        public int GetCpInfo(S7CpInfo Info)
        {
            S7Szl SZL = new S7Szl(1024);

            LastError = ReadSZL(0x0131, 0x0001, SZL);
            if (LastError == 0)
            {
                Info.Update(SZL.Data, 0);
            }
            return(LastError);
        }
Ejemplo n.º 4
0
        public int ReadSZL(int ID, int Index, S7Szl SZL)
        {
            int     Length;
            int     DataSZL;
            int     Offset  = 0;
            Boolean Done    = false;
            Boolean First   = true;
            byte    Seq_in  = 0x00;
            int     Seq_out = 0x0000;

            LastError    = 0;
            SZL.DataSize = 0;
            do
            {
                if (First)
                {
                    S7.SetWordAt(S7_SZL_FIRST, 11, ++Seq_out);
                    S7.SetWordAt(S7_SZL_FIRST, 29, ID);
                    S7.SetWordAt(S7_SZL_FIRST, 31, Index);
                    SendPacket(S7_SZL_FIRST);
                }
                else
                {
                    S7.SetWordAt(S7_SZL_NEXT, 11, ++Seq_out);
                    PDU[24] = (byte)Seq_in;
                    SendPacket(S7_SZL_NEXT);
                }
                if (LastError != 0)
                {
                    return(LastError);
                }

                Length = RecvIsoPacket();
                if (LastError == 0)
                {
                    if (First)
                    {
                        if (Length > 32) // the minimum expected
                        {
                            if ((S7.GetWordAt(PDU, 27) == 0) && (PDU[29] == (byte)0xFF))
                            {
                                // Gets Amount of this slice
                                DataSZL = S7.GetWordAt(PDU, 31) - 8; // Skips extra params (ID, Index ...)
                                Done    = PDU[26] == 0x00;
                                Seq_in  = (byte)PDU[24];             // Slice sequence

                                SZL.LENTHDR = S7.GetWordAt(PDU, 37);
                                SZL.N_DR    = S7.GetWordAt(PDU, 39);
                                SZL.Copy(PDU, 41, Offset, DataSZL);
                                Offset       += DataSZL;
                                SZL.DataSize += DataSZL;
                            }
                            else
                            {
                                LastError = errS7FunctionError;
                            }
                        }
                        else
                        {
                            LastError = errS7InvalidPDU;
                        }
                    }
                    else
                    {
                        if (Length > 32) // the minimum expected
                        {
                            if ((S7.GetWordAt(PDU, 27) == 0) && (PDU[29] == (byte)0xFF))
                            {
                                // Gets Amount of this slice
                                DataSZL = S7.GetWordAt(PDU, 31);
                                Done    = PDU[26] == 0x00;
                                Seq_in  = (byte)PDU[24]; // Slice sequence
                                SZL.Copy(PDU, 37, Offset, DataSZL);
                                Offset       += DataSZL;
                                SZL.DataSize += DataSZL;
                            }
                            else
                            {
                                LastError = errS7FunctionError;
                            }
                        }
                        else
                        {
                            LastError = errS7InvalidPDU;
                        }
                    }
                }
                First = false;
            }while (!Done && (LastError == 0));

            return(LastError);
        }