Example #1
0
        protected InterruptPort _busy; // An input port which can be used to pause the sending of data.

        #endregion Fields

        #region Constructors

        /// <summary>
        /// Creates a new instance of SerialInterruptPort class, allowing to specify buffer sizes and blocking input port.
        /// </summary>
        /// <param name="config">An object that contains the configuration information for the serial port.</param>
        /// <param name="busySignal">A <see cref="Cpu.Pin"/> to use as a output hardware flow control. Can be <see cref="Cpu.Pin.GPIO_NONE"/> if none used.</param>
        /// <param name="writeBufferSize">The size of output buffer in bytes. Data output is paused for <see cref="AfterWriteDelay"/> milliseconds every time this amount of data is sent. Can be zero to disable pausing.</param>
        /// <param name="readBufferSize">The size of input buffer in bytes. DataReceived event will fire only after this amount of data is received. Default is 1.</param>
        /// <param name="readTimeout">Timeout of port reading.</param>
        public SerialInterruptPort(SerialPortConfiguration config, Cpu.Pin busySignal, int writeBufferSize, int readBufferSize, int readTimeout = Timeout.Infinite)
            : base(config, writeBufferSize, readBufferSize, readTimeout)
        {
            if (busySignal == Cpu.Pin.GPIO_NONE)        // user does not want to use the output hardware flow control
                _busy = null;
            else
            {                                           // start monitoring the flow control pin for both edges
                _busy = new InterruptPort(busySignal, false, Port.ResistorMode.PullDown, Port.InterruptMode.InterruptEdgeBoth);
                _busy.OnInterrupt += new NativeEventHandler(OnBusyChanged);
            }
        }
Example #2
0
        protected SerialPort _port; // The actual serial port we are wrapping.

        #endregion Fields

        #region Constructors

        /// <summary>
        /// Creates a new instance of SerialInterruptPort class, allowing to specify buffer sizes.
        /// </summary>
        /// <param name="config">An object that contains the configuration information for the serial port.</param>
        /// <param name="writeBufferSize">The size of output buffer in bytes. Data output is paused for <see cref="AfterWriteDelay"/> milliseconds every time this amount of data is sent. Can be zero to disable pausing.</param>
        /// <param name="readBufferSize">The size of input buffer in bytes. DataReceived event will fire only after this amount of data is received. Default is 1.</param>
        /// <param name="readTimeout">Timeout of port reading.</param>
        public SerialInterruptPortBase(SerialPortConfiguration config, int writeBufferSize, int readBufferSize, int readTimeout = Timeout.Infinite)
            : base(writeBufferSize, readBufferSize)
        {
            _port = new SerialPort(config.PortName, (int)config.BaudRate, config.Parity, config.DataBits, config.StopBits)
            {
                Handshake = config.HardwareFlowControl ? Handshake.RequestToSend : Handshake.None
            };

            AfterWriteDelay = 33;
            ReadTimeout = readTimeout;

            _port.Open();
        }
Example #3
0
        protected InterruptPort _busy;              // An input port which can be used to pause the sending of data.

        /// <summary>
        /// Creates a new instance of SerialInterruptPort class, allowing to specify buffer sizes and blocking input port.
        /// </summary>
        /// <param name="config">An object that contains the configuration information for the serial port.</param>
        /// <param name="busySignal">A <see cref="Cpu.Pin"/> to use as a output hardware flow control. Can be <see cref="Cpu.Pin.GPIO_NONE"/> if none used.</param>
        /// <param name="writeBufferSize">The size of output buffer in bytes. Data output is paused for <see cref="AfterWriteDelay"/> milliseconds every time this amount of data is sent. Can be zero to disable pausing.</param>
        /// <param name="readBufferSize">The size of input buffer in bytes. DataReceived event will fire only after this amount of data is received. Default is 1.</param>
        /// <param name="readTimeout">Timeout of port reading.</param>
        public SerialInterruptPort(SerialPortConfiguration config, Cpu.Pin busySignal, int writeBufferSize, int readBufferSize, int readTimeout = Timeout.Infinite)
            : base(config, writeBufferSize, readBufferSize, readTimeout)
        {
            if (busySignal == Cpu.Pin.GPIO_NONE)        // user does not want to use the output hardware flow control
            {
                _busy = null;
            }
            else
            {                                           // start monitoring the flow control pin for both edges
                _busy              = new InterruptPort(busySignal, false, Port.ResistorMode.PullDown, Port.InterruptMode.InterruptEdgeBoth);
                _busy.OnInterrupt += new NativeEventHandler(OnBusyChanged);
            }
        }
Example #4
0
        protected SerialPort _port; // The actual serial port we are wrapping.

        /// <summary>
        /// Creates a new instance of SerialInterruptPort class, allowing to specify buffer sizes.
        /// </summary>
        /// <param name="config">An object that contains the configuration information for the serial port.</param>
        /// <param name="writeBufferSize">The size of output buffer in bytes. Data output is paused for <see cref="AfterWriteDelay"/> milliseconds every time this amount of data is sent. Can be zero to disable pausing.</param>
        /// <param name="readBufferSize">The size of input buffer in bytes. DataReceived event will fire only after this amount of data is received. Default is 1.</param>
        /// <param name="readTimeout">Timeout of port reading.</param>
        public SerialInterruptPortBase(SerialPortConfiguration config, int writeBufferSize, int readBufferSize, int readTimeout = Timeout.Infinite)
            : base(writeBufferSize, readBufferSize)
        {
            _port = new SerialPort(config.PortName, (int)config.BaudRate, config.Parity, config.DataBits, config.StopBits)
            {
                Handshake = config.HardwareFlowControl ? Handshake.RequestToSend : Handshake.None
            };

            AfterWriteDelay = 33;
            ReadTimeout     = readTimeout;

            _port.Open();
        }
Example #5
0
        protected SerialPort _port; // The actual serial port we are wrapping.

        /// <summary>
        /// Creates a new instance of SerialInterruptPort class, allowing to specify buffer sizes.
        /// </summary>
        /// <param name="config">An object that contains the configuration information for the serial port.</param>
        /// <param name="writeBufferSize">The size of output buffer in bytes. Data output is paused for <see cref="AfterWriteDelay"/> milliseconds every time this amount of data is sent. Can be zero to disable pausing.</param>
        /// <param name="readBufferSize">The size of input buffer in bytes. DataReceived event will fire only after this amount of data is received. Default is 1.</param>
        /// <param name="readTimeout">Timeout of port reading.</param>
        public SerialInterruptPortBase(SerialPortConfiguration config, int writeBufferSize, int readBufferSize, int readTimeout = Timeout.Infinite)
            : base(writeBufferSize, readBufferSize)
        {
            _port = new SerialPort(config.PortName, (int)config.BaudRate, config.Parity, config.DataBits, config.StopBits)
            {
                Handshake = config.HardwareFlowControl ? Handshake.RequestToSend : Handshake.None
            };

            AfterWriteDelay = 33;
            ReadTimeout     = readTimeout;

#if NETMF
            _port.Open();
#else
// in this case, need to open port manually in code(e.g. ActivateScreen.cs as link in OnBoardMonitorEmulator)
#endif
        }
 /// <summary>
 /// Creates a new instance of SerialInterruptPort class, with hardware flow control and output pausing disabled. This corresponds to standard <see cref="SerialPort"/> class behavior.
 /// </summary>
 /// <param name="config">An object that contains the configuration information for the serial port.</param>
 public SerialInterruptPortBase(SerialPortConfiguration config) : this(config, 0, 1)
 {
 }
Example #7
0
 /// <summary>
 /// Creates a new instance of SerialInterruptPort class, with hardware flow control and output pausing disabled. This corresponds to standard <see cref="SerialPort"/> class behavior.
 /// </summary>
 /// <param name="config">An object that contains the configuration information for the serial port.</param>
 /// <param name="afterReadDelay">The value of milliseconds to wait after reading before writing.</param>
 public SerialTimerInterruptPort(SerialPortConfiguration config, int afterReadDelay) : this(config, afterReadDelay, 0, 1)
 {
 }
Example #8
0
 /// <summary>
 /// Creates a new instance of SerialInterruptPort class, allowing to specify buffer sizes and blocking input port.
 /// </summary>
 /// <param name="config">An object that contains the configuration information for the serial port.</param>
 /// <param name="afterReadDelay">The value of milliseconds to wait after reading before writing.</param>
 /// <param name="writeBufferSize">The size of output buffer in bytes. Data output is paused for <see cref="AfterWriteDelay"/> milliseconds every time this amount of data is sent. Can be zero to disable pausing.</param>
 /// <param name="readBufferSize">The size of input buffer in bytes. DataReceived event will fire only after this amount of data is received. Default is 1.</param>
 /// <param name="readTimeout">Timeout of port reading.</param>
 public SerialTimerInterruptPort(SerialPortConfiguration config, int afterReadDelay, int writeBufferSize, int readBufferSize, int readTimeout = Timeout.Infinite)
     : base(config, writeBufferSize, readBufferSize, readTimeout)
 {
     AfterReadDelay = afterReadDelay;
 }
 internal SerialPortProxyListener(SerialPortConfiguration config)
 {
     _config = config;
 }
Example #10
0
 /// <summary>
 /// Creates a new instance of SerialInterruptPort class, with hardware flow control and output pausing disabled. This corresponds to standard <see cref="SerialPort"/> class behavior.
 /// </summary>
 /// <param name="config">An object that contains the configuration information for the serial port.</param>
 public SerialInterruptPortBase(SerialPortConfiguration config)
     : this(config, 0, 1)
 {
 }
Example #11
0
 /// <summary>
 /// Creates a new instance of SerialInterruptPort class, with hardware flow control and output pausing disabled. This corresponds to standard <see cref="SerialPort"/> class behavior.
 /// </summary>
 /// <param name="config">An object that contains the configuration information for the serial port.</param>
 public SerialInterruptPort(SerialPortConfiguration config)
     : this(config, Cpu.Pin.GPIO_NONE, 0, 1)
 {
 }
Example #12
0
 /// <summary>
 /// Creates a new instance of SerialInterruptPort class, with hardware flow control and output pausing disabled. This corresponds to standard <see cref="SerialPort"/> class behavior.
 /// </summary>
 /// <param name="config">An object that contains the configuration information for the serial port.</param>
 public SerialInterruptPort(SerialPortConfiguration config) : this(config, Cpu.Pin.GPIO_NONE, 0, 1)
 {
 }