Example #1
0
        // Note: A constructor summary is auto-generated by the doc builder.
        /// <summary></summary>
        /// <param name="socketNumber">The socket that this module is plugged in to.</param>
        /// <param name="baud">The baud rate to communicate with the module with.</param>
        public Bluetooth(int socketNumber, long baud)
        {
            // This finds the Socket instance from the user-specified socket number.
            // This will generate user-friendly error messages if the socket is invalid.
            // If there is more than one socket on this module, then instead of "null" for the last parameter,
            // put text that identifies the socket to the user (e.g. "S" if there is a socket type S)
            Socket socket = Socket.GetSocket(socketNumber, true, this, null);

            this.reset      = new GTI.DigitalOutput(socket, Socket.Pin.Six, false, this);
            this.statusInt  = new GTI.InterruptInput(socket, Socket.Pin.Three, GTI.GlitchFilterMode.Off, GTI.ResistorMode.Disabled, GTI.InterruptMode.RisingAndFallingEdge, this);
            this.serialPort = new GTI.Serial(socket, 38400, GTI.Serial.SerialParity.None, GTI.Serial.SerialStopBits.One, 8, GTI.Serial.HardwareFlowControl.NotRequired, this);

            //this.statusInt.Interrupt += new GTI.InterruptInput.InterruptEventHandler(statusInt_Interrupt);
            this.serialPort.ReadTimeout = Timeout.Infinite;
            this.serialPort.Open();

            Thread.Sleep(5);
            this.reset.Write(true);

            // Poundy added:
            Thread.Sleep(5);
            this.SetDeviceBaud(baud);
            this.serialPort.Flush();
            this.serialPort.Close();
            this.serialPort.BaudRate = (int)baud;
            this.serialPort.Open();
            // Poundy

            readerThread = new Thread(new ThreadStart(runReaderThread));
            readerThread.Start();
            Thread.Sleep(500);
        }
Example #2
0
 /// <summary>
 /// Configures this serial line.  This should be called at most once.
 /// </summary>
 /// <param name="baudRate">The baud rate.</param>
 /// <param name="parity">A value from the <see cref="T:Microsoft.Gadgeteer.Interfaces.Serial.SerialParity"/> enumeration that specifies the parity.</param>
 /// <param name="stopBits">A value from the <see cref="T:Microsoft.Gadgeteer.Interfaces.Serial.SerialStopBits"/> enumeration that specifies the number of stop bits.</param>
 /// <param name="dataBits">The number of data bits.</param>
 public void Configure(int baudRate, GTI.Serial.SerialParity parity, GTI.Serial.SerialStopBits stopBits, int dataBits)
 {
     if (_SerialLine != null)
     {
         throw new Exception("UsbSerial.Configure can only be called once");
     }
     // TODO: check if HW flow control should be used
     _SerialLine = new GTI.Serial(socket, baudRate, parity, stopBits, dataBits, GTI.Serial.HardwareFlowControl.NotRequired, this);
 }
Example #3
0
        /// <summary>
        /// Initializes the serial port to the passed in parameters. If no parameters are passed, the defaults are used.
        /// </summary>
        /// <param name="baudRate">The baud rate for the serail port. Defaulted to 38400.</param>
        /// <param name="parity">Specifies the parity bit for the serial port. Defaulted to none.</param>
        /// <param name="stopBits">Specifies the number of stop bits used on the serial port. Defaulted to one.</param>
        /// <param name="dataBits">The number of data bits. Defaulted to 8.</param>
        /// <param name="flowControl">Specifies if the serial port should use flow control. Defaulted to not use.</param>
        public void Initialize(int baudRate = 38400, GTI.Serial.SerialParity parity = GTI.Serial.SerialParity.None,
                               GTI.Serial.SerialStopBits stopBits = GTI.Serial.SerialStopBits.One, int dataBits = 8, GTI.Serial.HardwareFlowControl flowControl = GTI.Serial.HardwareFlowControl.NotRequired)
        {
            // Set up serial port.
            serialPort = new GTI.Serial(socket, baudRate, parity, stopBits, dataBits, flowControl, this);

            serialPort.Open();

            // Subscribe to events.
            //serialPort.DataReceived += new GTI.Serial.DataReceivedEventHandler(serialPort_DataReceived);
            //serialPort.LineReceived += new GTI.Serial.LineReceivedEventHandler(serialPort_LineReceived);
        }
Example #4
0
        // Note: A constructor summary is auto-generated by the doc builder.
        /// <summary></summary>
        /// <param name="socketNumber">The socket that this module is plugged in to.</param>
        public RFIDReader(int socketNumber)
        {
            Socket socket = Socket.GetSocket(socketNumber, true, this, null);

            socket.EnsureTypeIsSupported('U', this);

            serialPort = new GTI.Serial(socket, 9600, GTI.Serial.SerialParity.None, GTI.Serial.SerialStopBits.Two, 8, GTI.Serial.HardwareFlowControl.NotRequired, this);
            serialPort.Open();

            System.Threading.Thread readThread = new System.Threading.Thread(_readThreadStart);

            readThread.Start();
        }
Example #5
0
        // Note: A constructor summary is auto-generated by the doc builder.
        /// <summary></summary>
        /// <param name="socketNumber">The socket that this module is plugged in to.</param>
        public SerialCameraL1(int socketNumber)
        {
            // This finds the Socket instance from the user-specified socket number.
            // This will generate user-friendly error messages if the socket is invalid.
            // If there is more than one socket on this module, then instead of "null" for the last parameter,
            // put text that identifies the socket to the user (e.g. "S" if there is a socket type S)
            Socket socket = Socket.GetSocket(socketNumber, true, this, null);

            socket.EnsureTypeIsSupported('U', this);

            serialPort              = new GTI.Serial(socket, 115200, GTI.Serial.SerialParity.None, GTI.Serial.SerialStopBits.One, 8, GTI.Serial.HardwareFlowControl.NotRequired, this);
            serialPort.ReadTimeout  = 5000;
            serialPort.WriteTimeout = 5000;

            serialPort.Open();
            ResetCamera();
        }
        // Note: A constructor summary is auto-generated by the doc builder.
        /// <summary></summary>
        /// <param name="socketNumber">The socket that this module is plugged in to.</param>
        public Bluetooth(int socketNumber)
        {
            // This finds the Socket instance from the user-specified socket number.
            // This will generate user-friendly error messages if the socket is invalid.
            // If there is more than one socket on this module, then instead of "null" for the last parameter,
            // put text that identifies the socket to the user (e.g. "S" if there is a socket type S)
            Socket socket = Socket.GetSocket(socketNumber, true, this, null);

            this.reset = new GTI.DigitalOutput(socket, Socket.Pin.Six, false, this);
            this.statusInt = new GTI.InterruptInput(socket, Socket.Pin.Three, GTI.GlitchFilterMode.Off, GTI.ResistorMode.Disabled, GTI.InterruptMode.RisingAndFallingEdge, this);
            this.serialPort = new Serial(socket, 38400, GTI.Serial.SerialParity.None, GTI.Serial.SerialStopBits.One, 8, GTI.Serial.HardwareFlowControl.NotRequired, this);

            //this.statusInt.Interrupt += new GTI.InterruptInput.InterruptEventHandler(statusInt_Interrupt);
            this.serialPort.ReadTimeout = Timeout.Infinite;
            this.serialPort.Open();

            Thread.Sleep(5);
            this.reset.Write(true);

            readerThread = new Thread(new ThreadStart(runReaderThread));
            readerThread.Start();
            Thread.Sleep(500);
        }
Example #7
0
 /// <summary>
 /// Initializes the serial port to the passed in parameters. If no parameters are passed, the defaults are used.
 /// </summary>
 /// <param name="baudRate">The baud rate for the serail port. Defaulted to 38400.</param>
 /// <param name="parity">Specifies the parity bit for the serial port. Defaulted to none.</param>
 /// <param name="stopBits">Specifies the number of stop bits used on the serial port. Defaulted to one.</param>
 /// <param name="dataBits">The number of data bits. Defaulted to 8.</param>
 public GTI.Serial Initialize(int baudRate = 38400, GTI.Serial.SerialParity parity = GTI.Serial.SerialParity.None, GTI.Serial.SerialStopBits stopBits = GTI.Serial.SerialStopBits.One, int dataBits = 8)
 {
     this.port = new GTI.Serial(this.socket, baudRate, parity, stopBits, dataBits, GTI.Serial.HardwareFlowControl.NotRequired, this);
     this.port.Open();
     return(this.port);
 }