Example #1
0
        private void InitializeDcb()
        {
            var lpDcb = new SerialPortFixer.Dcb();

            GetCommStateNative(ref lpDcb);
            lpDcb.Flags &= 4294950911U;
            SetCommStateNative(ref lpDcb);
        }
Example #2
0
        private void SetCommStateNative(ref SerialPortFixer.Dcb lpDcb)
        {
            var lpErrors = 0;
            var lpStat   = new SerialPortFixer.Comstat();

            for (var index = 0; index < 10; ++index)
            {
                if (!SerialPortFixer.ClearCommError(m_Handle, ref lpErrors, ref lpStat))
                {
                    SerialPortFixer.WinIoError();
                }

                if (SerialPortFixer.SetCommState(m_Handle, ref lpDcb))
                {
                    break;
                }

                if (index == 9)
                {
                    SerialPortFixer.WinIoError();
                }
            }
        }
Example #3
0
 private static extern bool SetCommState(SafeFileHandle hFile, ref SerialPortFixer.Dcb lpDcb);