Пример #1
0
        public bool ReadAndWrite(string strCID, string strAFN, string strFN, string strPN, string strData)
        {
            string text = string.Empty;

            try
            {
                text = ((this.OperType == 0) ? ("COM" + (this.m_IOPort as SerialPort).PortNum.ToString() + ":" + (this.m_IOPort as SerialPort).ComSettings) : (this.m_IOPort as Socket).RemoteEndPoint.ToString());
            }
            catch
            {
            }
            LogMSG.AddInfo(string.Concat(new string[]
            {
                "\r\n[",
                text,
                "] [A1=",
                this.strA1,
                ",A2=",
                this.strA2,
                ",AFN=",
                strAFN,
                ",FN=",
                strFN,
                ",PN=",
                strPN,
                "]\r\n"
            }), 1);
            this._framelists.Clear();
            byte[] sendData = this.ToBytes(0, 1, 0, 0, byte.Parse(strCID), strAFN, this.Tp, 1, 1, 0, strFN, strPN, strData);
            this.ParseData(sendData, sendData.Length, ref this.FrameData);
            this.AddFrame(true, this.FrameData);
            this.Clear();
            this.SendData(sendData);

            while (true)
            {
                byte[] array = new byte[0];
                if (!this.ReceiveData(ref array))
                {
                    break;
                }
                this.Clear();
                this.PFC = (byte)(checked (this.PFC + 1) & 255);
                this.ParseData(array, array.Length, ref this.FrameData);
                this.AddFrame(false, this.FrameData);
                if (!FrameInfo.HaveNextFrame(this.FrameData))
                {
                    return(true);
                }
            }

            return(false);
        }