public AsyncSerialStream( string port, uint baudrate ) : base( port, System.IO.FileShare.None )
        {
            NativeMethods.COMMTIMEOUTS cto = new NativeMethods.COMMTIMEOUTS(); cto.Initialize();
            NativeMethods.DCB          dcb = new NativeMethods.DCB         (); dcb.Initialize();

            NativeMethods.GetCommState( m_handle.DangerousGetHandle(), ref dcb );

            dcb.BaudRate = baudrate;
            dcb.ByteSize = 8;
            dcb.StopBits = 0;

            dcb.__BitField = 0;
            dcb.__BitField &= ~NativeMethods.DCB.mask_fDtrControl  ;
            dcb.__BitField &= ~NativeMethods.DCB.mask_fRtsControl  ;
            dcb.__BitField |=  NativeMethods.DCB.mask_fBinary      ;
            dcb.__BitField &= ~NativeMethods.DCB.mask_fParity      ;
            dcb.__BitField &= ~NativeMethods.DCB.mask_fOutX        ;
            dcb.__BitField &= ~NativeMethods.DCB.mask_fInX         ;
            dcb.__BitField &= ~NativeMethods.DCB.mask_fErrorChar   ;
            dcb.__BitField &= ~NativeMethods.DCB.mask_fNull        ;
            dcb.__BitField |=  NativeMethods.DCB.mask_fAbortOnError;

            NativeMethods.SetCommState( m_handle.DangerousGetHandle(), ref dcb );

            NativeMethods.SetCommTimeouts( m_handle.DangerousGetHandle(), ref cto );
        }
        public AsyncSerialStream(string port, uint baudrate) : base(port, System.IO.FileShare.None)
        {
            NativeMethods.COMMTIMEOUTS cto = new NativeMethods.COMMTIMEOUTS(); cto.Initialize();
            NativeMethods.DCB          dcb = new NativeMethods.DCB(); dcb.Initialize();

            NativeMethods.GetCommState(m_handle.DangerousGetHandle(), ref dcb);

            dcb.BaudRate = baudrate;
            dcb.ByteSize = 8;
            dcb.StopBits = 0;

            dcb.__BitField  = 0;
            dcb.__BitField &= ~NativeMethods.DCB.mask_fDtrControl;
            dcb.__BitField &= ~NativeMethods.DCB.mask_fRtsControl;
            dcb.__BitField |= NativeMethods.DCB.mask_fBinary;
            dcb.__BitField &= ~NativeMethods.DCB.mask_fParity;
            dcb.__BitField &= ~NativeMethods.DCB.mask_fOutX;
            dcb.__BitField &= ~NativeMethods.DCB.mask_fInX;
            dcb.__BitField &= ~NativeMethods.DCB.mask_fErrorChar;
            dcb.__BitField &= ~NativeMethods.DCB.mask_fNull;
            dcb.__BitField |= NativeMethods.DCB.mask_fAbortOnError;

            NativeMethods.SetCommState(m_handle.DangerousGetHandle(), ref dcb);

            NativeMethods.SetCommTimeouts(m_handle.DangerousGetHandle(), ref cto);
        }
        public void ConfigureXonXoff( bool fEnable )
        {
            NativeMethods.DCB dcb = new NativeMethods.DCB(); dcb.Initialize();

            NativeMethods.GetCommState( m_handle.DangerousGetHandle(), ref dcb );

            if(fEnable)
            {
                dcb.__BitField |= NativeMethods.DCB.mask_fOutX;
            }
            else
            {
                dcb.__BitField &= ~NativeMethods.DCB.mask_fOutX;
            }

            NativeMethods.SetCommState( m_handle.DangerousGetHandle(), ref dcb );
        }
        public void ConfigureXonXoff(bool fEnable)
        {
            NativeMethods.DCB dcb = new NativeMethods.DCB(); dcb.Initialize();

            NativeMethods.GetCommState(m_handle.DangerousGetHandle(), ref dcb);

            if (fEnable)
            {
                dcb.__BitField |= NativeMethods.DCB.mask_fOutX;
            }
            else
            {
                dcb.__BitField &= ~NativeMethods.DCB.mask_fOutX;
            }

            NativeMethods.SetCommState(m_handle.DangerousGetHandle(), ref dcb);
        }