Exemplo n.º 1
0
        public AsyncSerialStream(string port, uint baudrate) : base(port, System.IO.FileShare.None)
        {
            Native.COMMTIMEOUTS cto = new Native.COMMTIMEOUTS(); cto.Initialize();
            Native.DCB          dcb = new Native.DCB(); dcb.Initialize();

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

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

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

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

            Native.SetCommTimeouts(m_handle.DangerousGetHandle(), ref cto);
        }
Exemplo n.º 2
0
        public void ConfigureXonXoff(bool fEnable)
        {
            Native.DCB dcb = new Native.DCB(); dcb.Initialize();

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

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

            Native.SetCommState(m_handle.DangerousGetHandle(), ref dcb);
        }
Exemplo n.º 3
0
        public void ConfigureXonXoff( bool fEnable )
        {
            Native.DCB dcb = new Native.DCB(); dcb.Initialize();

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

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

            Native.SetCommState( m_handle.DangerousGetHandle(), ref dcb );
        }
Exemplo n.º 4
0
        public AsyncSerialStream( string port, uint baudrate ) : base( port, System.IO.FileShare.None )
        {
            Native.COMMTIMEOUTS cto = new Native.COMMTIMEOUTS(); cto.Initialize();
            Native.DCB          dcb = new Native.DCB         (); dcb.Initialize();

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

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

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

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

            Native.SetCommTimeouts( m_handle.DangerousGetHandle(), ref cto );
        }