Esempio n. 1
0
        public DriverStation(PortDefinition wifiPort)
        {
            if (wifiPort is IPortUart)
            {
                IPortUart p = (IPortUart)wifiPort;
                _uart    = new System.IO.Ports.SerialPort(p.UART, 115200, System.IO.Ports.Parity.None, 8, System.IO.Ports.StopBits.One);
                _restart = new Microsoft.SPOT.Hardware.OutputPort(p.Pin6, true);
                if (wifiPort is Port1Definition)
                {
                    _flashPin = new Microsoft.SPOT.Hardware.OutputPort(((Port1Definition)wifiPort).Pin3, true);
                }
                if (wifiPort is Port4Definition)
                {
                    _flashPin = new Microsoft.SPOT.Hardware.OutputPort(((Port4Definition)wifiPort).Pin3, true);
                }
                if (wifiPort is Port6Definition)
                {
                    _flashPin = new Microsoft.SPOT.Hardware.OutputPort(((Port6Definition)wifiPort).Pin3, true);
                }
            }
            else
            {
                throw new ArgumentException("Port is not UART compatible");
            }


            _uart.Open();
            _uart.Flush();


            _enabled   = false;
            _connected = false;
            CTRE.Controller.GameControllerValues _g = new Controller.GameControllerValues();
            CTRE.Controller.GameControllerValues _h = new Controller.GameControllerValues();
            CTRE.Controller.GameControllerValues _j = new Controller.GameControllerValues();
            CTRE.Controller.GameControllerValues _k = new Controller.GameControllerValues();
            CTRE.Controller.GameControllerValues _l = new Controller.GameControllerValues();
            CTRE.Controller.GameControllerValues _m = new Controller.GameControllerValues();
            _joysticks = new CTRE.Controller.GameControllerValues[6] {
                _g, _h, _j, _k, _l, _m
            };
            _controllers = new CTRE.Controller.GameController[6];
            _data        = new byte[255];
            _timeout.Start();
            _sendingMessage = new byte[1] {
                0x00
            };
            _enableTimeout.Start();
            _initialization.Start();
        }
        public DriverStation(PortDefinition wifiPort)
        {
            if (wifiPort is IPortUart)
            {
                IPortUart p = (IPortUart)wifiPort;
                _uart    = new System.IO.Ports.SerialPort(p.UART, 115200, System.IO.Ports.Parity.None, 8, System.IO.Ports.StopBits.One);
                _restart = new Microsoft.SPOT.Hardware.OutputPort(p.Pin6, true);
                if (wifiPort is Port1Definition)
                {
                    _flashPin = new Microsoft.SPOT.Hardware.OutputPort(((Port1Definition)wifiPort).Pin3, true);
                }
                if (wifiPort is Port4Definition)
                {
                    _flashPin = new Microsoft.SPOT.Hardware.OutputPort(((Port4Definition)wifiPort).Pin3, true);
                }
                if (wifiPort is Port6Definition)
                {
                    _flashPin = new Microsoft.SPOT.Hardware.OutputPort(((Port6Definition)wifiPort).Pin3, true);
                }
            }
            else
            {
                status = ErrorCode.PORT_MODULE_TYPE_MISMATCH;
                Reporting.SetError(status);
            }


            _uart.Open();
            _uart.Flush();


            _enabled   = false;
            _connected = false;
            CTRE.Phoenix.Controller.GameControllerValues _g = new Controller.GameControllerValues();
            CTRE.Phoenix.Controller.GameControllerValues _h = new Controller.GameControllerValues();
            CTRE.Phoenix.Controller.GameControllerValues _j = new Controller.GameControllerValues();
            CTRE.Phoenix.Controller.GameControllerValues _k = new Controller.GameControllerValues();
            CTRE.Phoenix.Controller.GameControllerValues _l = new Controller.GameControllerValues();
            CTRE.Phoenix.Controller.GameControllerValues _m = new Controller.GameControllerValues();
            _joysticks = new CTRE.Phoenix.Controller.GameControllerValues[6] {
                _g, _h, _j, _k, _l, _m
            };
            _controllers    = new CTRE.Phoenix.Controller.GameController[6];
            _data           = new byte[255];
            _sendingMessage = new byte[1] {
                0x00
            };
            buffer = new Containers.ByteRingBuffer(255);
        }
Esempio n. 3
0
        public ESPModule(PortDefinition wifiPort)
        {
            if (wifiPort is IPortUart)
            {
                IPortUart p = (IPortUart)wifiPort;
                _uart    = new System.IO.Ports.SerialPort(p.UART, 115200, System.IO.Ports.Parity.None, 8, System.IO.Ports.StopBits.One);
                _restart = new Microsoft.SPOT.Hardware.OutputPort(p.Pin6, true);
                //Need to define the flash pin to ensure it's held true
                if (wifiPort is Port1Definition)
                {
                    _flashPin = new Microsoft.SPOT.Hardware.OutputPort(((Port1Definition)wifiPort).Pin3, true);
                }
                if (wifiPort is Port4Definition)
                {
                    _flashPin = new Microsoft.SPOT.Hardware.OutputPort(((Port4Definition)wifiPort).Pin3, true);
                }
                if (wifiPort is Port6Definition)
                {
                    _flashPin = new Microsoft.SPOT.Hardware.OutputPort(((Port6Definition)wifiPort).Pin3, true);
                }
            }
            else
            {
                throw new ArgumentException("Port is not UART compatible");
            }


            _uart.Open();
            _uart.Flush();


            _connected = false;
            _data      = new byte[255];
            _timeout.Start();
            _sendingMessage = new byte[1] {
                0x00
            };
            _enableTimeout.Start();
            _initialization.Start();
        }
 public void InitPresenceCheck(IPortUart port)
 {
     resetPin      = new InputPort(port.Pin6, false, Port.ResistorMode.PullDown);
     GPIO          = new InputPort(port.Pin3, false, Port.ResistorMode.PullDown);
     modulePresent = resetPin.Read();
 }
 private void InitUart(IPortUart port)
 {
     uart = new System.IO.Ports.SerialPort(port.UART, baud, System.IO.Ports.Parity.None, 8, System.IO.Ports.StopBits.One);
     uart.Open();
 }