Пример #1
0
        private void CheckResult()
        {
            uint num = 0;

            if (this.writeCount > 0)
            {
                if (!Win32Com.GetOverlappedResult(this.hPort, this.ptrUWO, out num, this.checkSends))
                {
                    if ((long)Marshal.GetLastWin32Error() != (long)0x3e4)
                    {
                        this.ThrowException("Write Error");
                    }
                }
                else
                {
                    if (this.checkSends)
                    {
                        CommBase commBase = this;
                        commBase.writeCount = commBase.writeCount - num;
                        if (this.writeCount != 0)
                        {
                            this.ThrowException("Send Timeout");
                        }
                        this.writeCount = 0;
                        return;
                    }
                }
            }
        }
Пример #2
0
        protected void Send(byte[] tosend)
        {
            uint num = 0;

            this.CheckOnline();
            this.CheckResult();
            this.writeCount = (uint)tosend.GetLength(0);
            if (!Win32Com.WriteFile(this.hPort, tosend, (uint)this.writeCount, out num, this.ptrUWO))
            {
                if ((long)Marshal.GetLastWin32Error() != (long)0x3e5)
                {
                    this.ThrowException("Send failed");
                }
                this.dataQueued = true;
                return;
            }
            else
            {
                CommBase commBase = this;
                commBase.writeCount = commBase.writeCount - num;
                return;
            }
        }