Esempio n. 1
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);
        }
Esempio n. 2
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; /* 0,1,2 = 1, 1.5, 2 */

            dcb.__BitField &= ~Native.DCB.mask_fDtrControl; dcb.__BitField |= Native.DCB.DTR_CONTROL_DISABLE;
            dcb.__BitField &= ~Native.DCB.mask_fRtsControl; dcb.__BitField |= Native.DCB.RTS_CONTROL_DISABLE;
            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);
        }