private void InitializeDcb() { var lpDcb = new SerialPortFixer.Dcb(); GetCommStateNative(ref lpDcb); lpDcb.Flags &= 4294950911U; SetCommStateNative(ref lpDcb); }
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(); } } }
private static extern bool SetCommState(SafeFileHandle hFile, ref SerialPortFixer.Dcb lpDcb);