Example #1
0
        /// <summary>
        /// Create a serial port class.
        /// </summary>
        /// <param name="PortName">The port to open (i.e. "COM1:")</param>
        /// <param name="InitialSettings">BasicPortSettings to apply to the new Port</param>
        public Port(string PortName, BasicPortSettings InitialSettings)
        {
            this.PortName = PortName;
            Init();

            //override default ettings
            portSettings.BasicSettings = InitialSettings;
        }
Example #2
0
        /// <summary>
        /// Create a serial port class.
        /// </summary>
        /// <param name="PortName">The port to open (i.e. "COM1:")</param>
        /// <param name="InitialSettings">BasicPortSettings to apply to the new Port</param>
        /// <param name="RxBufferSize">Receive buffer size, in bytes</param>
        /// <param name="TxBufferSize">Transmit buffer size, in bytes</param>
        public Port(string PortName, BasicPortSettings InitialSettings, int RxBufferSize, int TxBufferSize)
        {
            rxBufferSize  = RxBufferSize;
            txBufferSize  = TxBufferSize;
            this.PortName = PortName;
            Init();

            //override default ettings
            portSettings.BasicSettings = InitialSettings;
        }
Example #3
0
		public void SerialOpen(String portName, BaudRates baud)
		{
			BasicPortSettings portSettings = new BasicPortSettings();
			portSettings.BaudRate = baud;
			mPort = new Port(portName, portSettings);
			mPort.RThreshold = 1;
			mPort.SThreshold = 1;	// send 1 byte at a time
			mPort.InputLen = 0;
			mPort.Open();
			mPort.DataReceived +=new Port.CommEvent(mPort_DataReceived);
		}
Example #4
0
 public Port(string PortName, BasicPortSettings InitialSettings)
 {
     this.hPort = (IntPtr) (-1);
     this.rxBufferSize = 0x400000;
     this.rthreshold = 1;
     this.txBufferSize = 0x400000;
     this.sthreshold = 1;
     this.rxBufferBusy = new Mutex();
     this.dcb = new DCB();
     this.threadStarted = new ManualResetEvent(false);
     this.closeEventName = "CloseEvent";
     this.txOverlapped = IntPtr.Zero;
     this.rxOverlapped = IntPtr.Zero;
     this.Capabilities = new CommCapabilities();
     this.PortName = PortName;
     this.Init();
     this.portSettings.BasicSettings = InitialSettings;
 }
Example #5
0
 public Port(string PortName, BasicPortSettings InitialSettings)
 {
     this.hPort          = (IntPtr)(-1);
     this.rxBufferSize   = 0x400000;
     this.rthreshold     = 1;
     this.txBufferSize   = 0x400000;
     this.sthreshold     = 1;
     this.rxBufferBusy   = new Mutex();
     this.dcb            = new DCB();
     this.threadStarted  = new ManualResetEvent(false);
     this.closeEventName = "CloseEvent";
     this.txOverlapped   = IntPtr.Zero;
     this.rxOverlapped   = IntPtr.Zero;
     this.Capabilities   = new CommCapabilities();
     this.PortName       = PortName;
     this.Init();
     this.portSettings.BasicSettings = InitialSettings;
 }
Example #6
0
 /// <summary>
 /// Create a DetailedPortSettings class
 /// </summary>
 public DetailedPortSettings()
 {
     BasicSettings = new BasicPortSettings();
     Init();
 }
Example #7
0
		/// <summary>
		/// Create a DetailedPortSettings class
		/// </summary>
		public DetailedPortSettings()
		{
			BasicSettings = new BasicPortSettings();
			Init();
		}
Example #8
0
        /// <summary>
        /// Create a serial port class.
        /// </summary>
        /// <param name="PortName">The port to open (i.e. "COM1:")</param>
        /// <param name="InitialSettings">BasicPortSettings to apply to the new Port</param>
        /// <param name="RxBufferSize">Receive buffer size, in bytes</param>
        /// <param name="TxBufferSize">Transmit buffer size, in bytes</param>
        public Port(string PortName, BasicPortSettings InitialSettings, int RxBufferSize, int TxBufferSize)
        {
            rxBufferSize = RxBufferSize;
            txBufferSize = TxBufferSize;
            this.PortName = PortName;
            Init();

            //override default ettings
            portSettings.BasicSettings = InitialSettings;
        }
Example #9
0
        /// <summary>
        /// Create a serial port class.
        /// </summary>
        /// <param name="PortName">The port to open (i.e. "COM1:")</param>
        /// <param name="InitialSettings">BasicPortSettings to apply to the new Port</param>
        public Port(string PortName, BasicPortSettings InitialSettings)
        {
            this.PortName = PortName;
            Init();

            //override default ettings
            portSettings.BasicSettings = InitialSettings;
        }
Example #10
0
        public void SerialOpen(String portName, BaudRates baud)
        {
            if (portName.StartsWith("COM")){
                BasicPortSettings portSettings = new BasicPortSettings();
                portSettings.BaudRate = baud;
                mPort = new Port(portName+":", portSettings);
                mPort.RThreshold = 1;
                mPort.SThreshold = 1;	// send 1 byte at a time
                mPort.InputLen = 0;
                mPort.Open();
                mPort.DataReceived +=new Port.CommEvent(mPort_DataReceived);
            }else{

                try{
                    BluetoothAddress address = BluetoothAddress.Parse(portName);
                    bluetoothClient = new BluetoothClient();
                    bluetoothClient.SetPin(address, "0000");
                    BluetoothEndPoint btep = new BluetoothEndPoint(address, BluetoothService.SerialPort, 1);
                    bluetoothClient.Connect(btep);
                    stream = bluetoothClient.GetStream();
                    if (stream == null){
                        bluetoothClient.Close();
                        bluetoothClient = null;
                    }else{
                        if (stream.CanTimeout){
                            stream.WriteTimeout = 2;
                            stream.ReadTimeout = 2;
                        }
                    }
                }catch(System.IO.IOException){
                    bluetoothClient = null;
                }

            }
        }