public bool TransmitData(byte[] data, AsyncOperation asyncOp)
 {
     if (this.enableFastBuffer)
     {
         if (data.Length < 0x88)
         {
             this.Set_cBufferSize((data.Length * 2) - 1);
         }
         else
         {
             this.Set_cBufferSize(data.Length);
         }
     }
     try
     {
         this._instance.SerialPortInstance.Write(data);
         DataActivityEventArgs arg = new DataActivityEventArgs(true);
         asyncOp.Post(this.onDataActivityTXDelegate, arg);
         return(true);
     }
     catch (Exception exception1)
     {
         ProjectData.SetProjectError(exception1);
         Exception exception = exception1;
         ProjectData.ClearProjectError();
     }
     return(false);
 }
        protected void OnDataActivityTX(DataActivityEventArgs e)
        {
            DataActivityEventHandler dataActivityTXEvent = this.DataActivityTXEvent;

            if (dataActivityTXEvent != null)
            {
                dataActivityTXEvent(e);
            }
        }
        public byte[] ReceiveData(byte[] data, AsyncOperation asyncOp)
        {
            int         length = data.Length;
            List <byte> list   = new List <byte>();
            int         num2   = 0;

            if (this.enableFastBuffer)
            {
                int num3 = this.Get_cBufferSize();
                if (length > num3)
                {
                    this.Set_cBufferSize(length);
                }
            }
            byte[] buffer = new byte[this.Get_cBufferSize() + 1];
            try
            {
                num2 = this._instance.SerialPortInstance.Read(buffer);
                DataActivityEventArgs arg = new DataActivityEventArgs(true);
                asyncOp.Post(this.onDataActivityRXDelegate, arg);
                if (num2 == 0)
                {
                    Thread.Sleep(150);
                    num2 = this._instance.SerialPortInstance.Read(buffer);
                    arg  = new DataActivityEventArgs(true);
                    asyncOp.Post(this.onDataActivityRXDelegate, arg);
                }
                else
                {
                    int num5 = num2 - 1;
                    for (int i = 0; i <= num5; i++)
                    {
                        list.Add(buffer[i]);
                    }
                }
            }
            catch (Exception exception1)
            {
                ProjectData.SetProjectError(exception1);
                Exception exception = exception1;
                ProjectData.ClearProjectError();
            }
            return(list.ToArray());
        }
        private void ReportDataActivityTX(object activityState)
        {
            DataActivityEventArgs e = (DataActivityEventArgs)activityState;

            this.OnDataActivityTX(e);
        }