예제 #1
0
파일: CommBase.cs 프로젝트: Rain-Time/test
        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
파일: CommBase.cs 프로젝트: Rain-Time/test
        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;
            }
        }