Ejemplo n.º 1
0
 public override bool PortDataRecv(CMessage sSend, CRecvBuff cRecv)
 {
     try
     {
         base.PortDataRecv(sSend, cRecv);
         string sRecv = new ASCIIEncoding().GetString(cRecv.bRecvBuff, 0, cRecv.iRecvLen);
         int    iMark = sRecv.IndexOf(Address);
         if (iMark >= 0)
         {
             int    iFF    = sRecv.IndexOf('\r', iMark);
             string sValue = sRecv.Substring(iMark + 6, iFF - iMark - 6);
             lock (this)
             {
                 cRecv.DelBuff(iFF + 3);
             }
             CommStateE         = ECommSatate.Normal;
             present_MsgFailRep = 0;
             present_DevFailNum = 0;
             present_DevFailCyc = 0;
             return(GetVarValue(sSend, sValue));
         }
         return(false);
     }
     catch (Exception ex)
     {
         return(false);
     }
 }
Ejemplo n.º 2
0
        public override bool PortDataRecv(CMessage sSend, CRecvBuff cRecv)
        {
            base.PortDataRecv(sSend, cRecv);

            for (int i = 0; i < cRecv.iRecvLen - sSend.ReLen + 1; i++)
            {
                if (cRecv.bRecvBuff[i] == sSend.sSendMsg.DataBuffer[0])
                {
                    if (cRecv.bRecvBuff[i + 1] == sSend.sSendMsg.DataBuffer[1])
                    {
                        byte[] Datebuff = new byte[sSend.ReLen];
                        Array.Copy(cRecv.bRecvBuff, i, Datebuff, 0, sSend.ReLen);
                        lock (this)
                        {
                            cRecv.DelBuff(i + sSend.ReLen);
                        }

                        if (CRC.bCheckCRC(Datebuff, sSend.ReLen))//CRC校验
                        {
                            //Debug.WriteLine(Name + " 5:" + sSend.Description);
                            CommStateE         = ECommSatate.Normal;
                            present_MsgFailRep = 0;
                            present_DevFailNum = 0;
                            present_DevFailCyc = 0;
                            GetVarValue(sSend, Datebuff);
                            //Debug.WriteLine(Name + " 6:" + sSend.Description);
                            return(true);
                        }
                        else
                        {
                            return(false);
                        }
                    }
                }
            }
            return(false);
        }