コード例 #1
0
 private void SetCommStateNative(ref Dcb lpDcb)
 {
     int     commErrors = 0;
     Comstat comStat    = new Comstat(); for (int i = 0; i < CommStateRetries; i++)
     {
         if (!NativeMethods.ClearCommError(m_Handle, ref commErrors, ref comStat))
         {
             WinIoError();
         }
         if (NativeMethods.SetCommState(m_Handle, ref lpDcb))
         {
             break;
         }
         if (i == CommStateRetries - 1)
         {
             WinIoError();
         }
     }
 }
コード例 #2
0
        private void SetCommStateNative(ref Dcb lpDcb)
        {
            var commErrors = 0;
            var comStat    = new Comstat();

            for (var i = 0; i < CommStateRetries; i++)
            {
                if (!ClearCommError(m_Handle, ref commErrors, ref comStat))
                {
                    WinIoError();
                }
                if (SetCommState(m_Handle, ref lpDcb))
                {
                    break;
                }
                if (i == CommStateRetries - 1)
                {
                    WinIoError();
                }
            }
        }
コード例 #3
0
        private void GetCommStateNative(ref Dcb lpDcb)
        {
            int     commErrors = 0;
            Comstat comStat    = new Comstat();

            for (int i = 0; i < CommStateRetries; i++)
            {
                if (!ClearCommError(_handle, ref commErrors, ref comStat))
                {
                    WinIoError();
                }
                if (GetCommState(_handle, ref lpDcb))
                {
                    break;
                }
                if (i == CommStateRetries - 1)
                {
                    WinIoError();
                }
            }
        }
コード例 #4
0
ファイル: SerialPortFixer.cs プロジェクト: skyhoshi/Arduino
        private static void MarshalCommState(SafeFileHandle handle, Func <bool> performCommState)
        {
            int commErrors = 0;
            var comStat    = new Comstat();

            for (int i = 0; i < CommStateRetries; i++)
            {
                if (!ClearCommError(handle, ref commErrors, ref comStat))
                {
                    ThrowIoException();
                }

                if (performCommState())
                {
                    return;
                }

                if (i == CommStateRetries - 1)
                {
                    ThrowIoException();
                }
            }
        }
コード例 #5
0
 private void SetCommStateNative(ref Dcb lpDcb)
 {
     int commErrors = 0;
     Comstat comStat = new Comstat(); for (int i = 0; i < CommStateRetries; i++)
     {
         if (!NativeMethods.ClearCommError(m_Handle, ref commErrors, ref comStat))
         {
             WinIoError();
         }
         if (NativeMethods.SetCommState(m_Handle, ref lpDcb))
         {
             break;
         }
         if (i == CommStateRetries - 1)
         {
             WinIoError();
         }
     }
 }
コード例 #6
0
 internal static extern bool ClearCommError(SafeFileHandle hFile, ref int lpErrors, ref Comstat lpStat);
コード例 #7
0
 private static extern bool ClearCommError(SafeFileHandle hFile, ref int lpErrors, ref Comstat lpStat);
コード例 #8
0
        private void SetCommStateNative(ref Dcb lpDcb)
        {
            var commErrors = 0;
            var comStat = new Comstat();

            for (var i = 0; i < CommStateRetries; i++)
            {
                if (!ClearCommError(m_Handle, ref commErrors, ref comStat))
                {
                    WinIoError();
                }
                if (SetCommState(m_Handle, ref lpDcb))
                {
                    break;
                }
                if (i == CommStateRetries - 1)
                {
                    WinIoError();
                }
            }
        }