コード例 #1
0
        /// <summary>
        /// Pre-configures settings for most modern devices: 8 databits, 1 stop bit, no parity and
        /// one of the common handshake protocols. Change individual settings later if necessary.
        /// </summary>
        /// <param name="Port">The port to use (i.e. "COM1:")</param>
        /// <param name="Baud">The baud rate</param>
        /// <param name="Hs">The handshake protocol</param>
        public void SetStandard(string Port, int Baud, Handshake Hs)
        {
            dataBits = 8; stopBits = StopBits.one; parity = Parity.none;
            port     = Port; baudRate = Baud;
            switch (Hs)
            {
            case Handshake.none:
                txFlowCTS    = false; txFlowDSR = false; txFlowX = false;
                rxFlowX      = false; useRTS = HSOutput.online; useDTR = HSOutput.online;
                txWhenRxXoff = true; rxGateDSR = false;
                break;

            case Handshake.XonXoff:
                txFlowCTS    = false; txFlowDSR = false; txFlowX = true;
                rxFlowX      = true; useRTS = HSOutput.online; useDTR = HSOutput.online;
                txWhenRxXoff = true; rxGateDSR = false;
                XonChar      = ASCII.DC1; XoffChar = ASCII.DC3;
                break;

            case Handshake.CtsRts:
                txFlowCTS    = true; txFlowDSR = false; txFlowX = false;
                rxFlowX      = false; useRTS = HSOutput.handshake; useDTR = HSOutput.online;
                txWhenRxXoff = true; rxGateDSR = false;
                break;

            case Handshake.DsrDtr:
                txFlowCTS    = false; txFlowDSR = true; txFlowX = false;
                rxFlowX      = false; useRTS = HSOutput.online; useDTR = HSOutput.handshake;
                txWhenRxXoff = true; rxGateDSR = false;
                break;
            }
        }
コード例 #2
0
        public void SetStandard(string Port, int Baud, Handshake Hs)
        {
            this.dataBits = 8;
            this.stopBits = StopBits.one;
            this.parity   = Parity.none;
            this.port     = Port;
            this.baudRate = Baud;
            switch (Hs)
            {
            case Handshake.none:
                this.txFlowCTS    = false;
                this.txFlowDSR    = false;
                this.txFlowX      = false;
                this.rxFlowX      = false;
                this.useRTS       = HSOutput.online;
                this.useDTR       = HSOutput.online;
                this.txWhenRxXoff = true;
                this.rxGateDSR    = false;
                return;

            case Handshake.XonXoff:
                this.txFlowCTS    = false;
                this.txFlowDSR    = false;
                this.txFlowX      = true;
                this.rxFlowX      = true;
                this.useRTS       = HSOutput.online;
                this.useDTR       = HSOutput.online;
                this.txWhenRxXoff = true;
                this.rxGateDSR    = false;
                this.XonChar      = ASCII.DC1;
                this.XoffChar     = ASCII.DC3;
                return;

            case Handshake.CtsRts:
                this.txFlowCTS    = true;
                this.txFlowDSR    = false;
                this.txFlowX      = false;
                this.rxFlowX      = false;
                this.useRTS       = HSOutput.handshake;
                this.useDTR       = HSOutput.online;
                this.txWhenRxXoff = true;
                this.rxGateDSR    = false;
                return;

            case Handshake.DsrDtr:
                this.txFlowCTS    = false;
                this.txFlowDSR    = true;
                this.txFlowX      = false;
                this.rxFlowX      = false;
                this.useRTS       = HSOutput.online;
                this.useDTR       = HSOutput.handshake;
                this.txWhenRxXoff = true;
                this.rxGateDSR    = false;
                return;

            default:
                return;
            }
        }
コード例 #3
0
ファイル: NativeMethods.cs プロジェクト: sntcz/SnT.IO.Ports
            internal static DCB Create(IntPtr hPort, Parity parity, bool txFlowCTS, bool txFlowDSR,
                                       HSOutput useDTR, bool rxGateDSR, bool txWhenRxXoff, bool txFlowX,
                                       bool rxFlowX, HSOutput useRTS,
                                       int baudRate, int dataBits, StopBits stopBits, ASCII xoffChar, ASCII xonChar)
            {
                NativeMethods.DCB portDCB = new NativeMethods.DCB();

                portDCB.init(hPort, ((parity == Ports.Parity.Odd) || (parity == Ports.Parity.Even)),
                             txFlowCTS, txFlowDSR,
                             (int)useDTR, rxGateDSR, !txWhenRxXoff, txFlowX, rxFlowX, (int)useRTS);
                portDCB.BaudRate = baudRate;
                portDCB.ByteSize = (byte)dataBits;
                portDCB.Parity   = (byte)parity;
                portDCB.StopBits = (byte)stopBits;
                portDCB.XoffChar = (byte)xoffChar;
                portDCB.XonChar  = (byte)xonChar;

                return(portDCB);
            }
コード例 #4
0
ファイル: CommBase.cs プロジェクト: testdoron/pansoft
 /// <summary>
 /// Pre-configures settings for most modern devices: 8 databits, 1 stop bit, no parity and
 /// one of the common handshake protocols. Change individual settings later if necessary.
 /// </summary>
 /// <param name="Port">The port to use (i.e. "COM1:")</param>
 /// <param name="Baud">The baud rate</param>
 /// <param name="Hs">The handshake protocol</param>
 public void SetStandard(string Port, int Baud, Handshake Hs)
 {
     dataBits = 8; stopBits = StopBits.one; parity = Parity.none;
     port = Port; baudRate = Baud;
     switch (Hs)
     {
         case Handshake.none:
             txFlowCTS = false; txFlowDSR = false; txFlowX = false;
             rxFlowX = false; useRTS = HSOutput.online; useDTR = HSOutput.online;
             txWhenRxXoff = true; rxGateDSR = false;
             break;
         case Handshake.XonXoff:
             txFlowCTS = false; txFlowDSR = false; txFlowX = true;
             rxFlowX = true; useRTS = HSOutput.online; useDTR = HSOutput.online;
             txWhenRxXoff = true; rxGateDSR = false;
             XonChar = ASCII.DC1; XoffChar = ASCII.DC3;
             break;
         case Handshake.CtsRts:
             txFlowCTS = true; txFlowDSR = false; txFlowX = false;
             rxFlowX = false; useRTS = HSOutput.handshake; useDTR = HSOutput.online;
             txWhenRxXoff = true; rxGateDSR = false;
             break;
         case Handshake.DsrDtr:
             txFlowCTS = false; txFlowDSR = true; txFlowX = false;
             rxFlowX = false; useRTS = HSOutput.online; useDTR = HSOutput.handshake;
             txWhenRxXoff = true; rxGateDSR = false;
             break;
     }
 }