Exemplo n.º 1
0
        public static void Main()
        {
            using (var led = new Microsoft.SPOT.Hardware.OutputPort(Pins.ONBOARD_LED, false)) {
                for (var i = 0; i < 3; i++)
                {
                    led.Write(true);
                    Thread.Sleep(250);
                    led.Write(false);
                    Thread.Sleep(250);
                }
            }

            // Frank tests
            // TestBLEMini.Run ();
            TestRCCar.Run();

            // MotorShield (deprecated)
            // TestDrunkenRobotWithMotorShield.Run();

            // TestSensors.Run ();
            // TestDrunkenRobot.Run ();
            // TestWallBouncingRobotWithHBridge.Run ();

            // No eyes, just motors
            // TestDrunkenRobotWithHbridge.Run ();

            // Requires IR sensors
            // TestTwoEyedRobotWithHbridge.Run ();
        }
Exemplo n.º 2
0
		public static void Main()
		{
            using (var led = new Microsoft.SPOT.Hardware.OutputPort (Pins.ONBOARD_LED, false)) {

                for (var i = 0; i < 3; i++) {
                    led.Write (true);
                    Thread.Sleep (250);
                    led.Write (false);
                    Thread.Sleep (250);
                }
            }

            // Frank tests
            // TestBLEMini.Run ();
            TestRCCar.Run ();

            // MotorShield (deprecated)
            // TestDrunkenRobotWithMotorShield.Run();

            // TestSensors.Run ();
            // TestDrunkenRobot.Run ();
            // TestWallBouncingRobotWithHBridge.Run ();
            
            // No eyes, just motors
            // TestDrunkenRobotWithHbridge.Run ();
            
            // Requires IR sensors
            // TestTwoEyedRobotWithHbridge.Run ();
		}
Exemplo n.º 3
0
 public Relay()
 {
     relayPort = new Microsoft.SPOT.Hardware.OutputPort((Microsoft.SPOT.Hardware.Cpu.Pin) 21, false);
     if (relayPort == null)
     {
         new NotImplementedException("This library is developed for EG IoT Kit Emulator");
     }
 }
Exemplo n.º 4
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);
        }
Exemplo n.º 6
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();
        }
Exemplo n.º 7
0
        static void Main(string[] args)
        {
            //string buffer = "STATUS:3\r\n+CIPSTATUS:0,\"TCP\",\"74.125.133.94\",80,0\r\n+CIPSTATUS:1,\"TCP\",\"192.168.20.1\",80,0\r\n\r\nOK\r\n";
            string buffer = "STATUS:3\r\n\r\nOK\r\n";

            BrusDev.Text.RegularExpressions.Regex r = new BrusDev.Text.RegularExpressions.Regex(@"STATUS:[0-9]\r\n(\+CIPSTATUS:[^\r\n]+\r\n)*\r\n(OK)\r\n");
            BrusDev.Text.RegularExpressions.Match m = r.Match(buffer);

            int connectionId;
            int clientConnectionId;
            int receivedBytes;
            int totalReceivedBytes;

            byte[] sendingBuffer;
            byte[] receivingBuffer;
            string remoteIPAddress;
            string connectionStatus;

#if MF_FRAMEWORK
            Microsoft.SPOT.Hardware.OutputPort deviceSwitch = new Microsoft.SPOT.Hardware.OutputPort(
                SecretLabs.NETMF.Hardware.NetduinoPlus.Pins.GPIO_PIN_D2, false);
#endif

            receivingBuffer = new byte[128];


            using (SerialPort serialPort = new SerialPort("COM10", 9600,
                                                          System.IO.Ports.Parity.None, 8, System.IO.Ports.StopBits.One))
            {
                serialPort.Open();

#if MF_FRAMEWORK
                deviceSwitch.Write(true);

                using (ESP8266ATModem modem = new ESP8266ATModem(serialPort))
#else
                using (ESP8266ATModem modem = new ESP8266ATModem(serialPort.BaseStream))
#endif
                {
                    //modem.AccessPointName = "Vodafone-brusnet";
                    //modem.AccessPassword = "******";
                    modem.AccessPointName = "LeonardoRicerche";
                    modem.AccessPassword  = "******";

                    modem.OpenDataConnection();

                    //remoteIPAddress = "192.168.10.1";
                    remoteIPAddress = "www.google.it";

                    connectionStatus = modem.GetIPConnectionStatus(0);

                    modem.StartListening(1234);

                    clientConnectionId = modem.Accept();

                    sendingBuffer = Encoding.UTF8.GetBytes("HELLO\r\n");
                    modem.SendData(clientConnectionId, sendingBuffer, 0, sendingBuffer.Length);

                    totalReceivedBytes = 0;
                    while ((receivedBytes = modem.ReceiveData(clientConnectionId, receivingBuffer, 0, receivingBuffer.Length)) > 0)
                    {
                        totalReceivedBytes += receivedBytes;

                        //Debug.Print(new string(Encoding.UTF8.GetChars(receivingBuffer, 0, receivedBytes)));

                        //modem.SendData(clientConnectionId, receivingBuffer, 0, receivedBytes);

                        Debug.Print("ReceiveData > " + receivedBytes + "/" + totalReceivedBytes);
                    }

                    connectionId = modem.OpenIPConnection("TCP", remoteIPAddress, 80);

                    connectionStatus = modem.GetIPConnectionStatus(connectionId);


                    sendingBuffer = Encoding.UTF8.GetBytes("GET / HTTP/1.0\r\n\r\n");
                    modem.SendData(connectionId, sendingBuffer, 0, sendingBuffer.Length);

                    totalReceivedBytes = 0;
                    while ((receivedBytes = modem.ReceiveData(connectionId, receivingBuffer, 0, receivingBuffer.Length)) > 0)
                    {
                        totalReceivedBytes += receivedBytes;

                        if (totalReceivedBytes < 1000)
                        {
                            Debug.Print(new string(Encoding.UTF8.GetChars(receivingBuffer, 0, receivedBytes)));
                        }

                        //modem.SendData(clientConnectionId, receivingBuffer, 0, receivedBytes);

                        Debug.Print("ReceiveData > " + receivedBytes + "/" + totalReceivedBytes);
                    }

                    modem.CloseIPConnection(connectionId);
                    modem.CloseDataConnection();
                }
            }
        }
Exemplo n.º 8
0
        static void Main(string[] args)
        {
            //string buffer = "STATUS:3\r\n+CIPSTATUS:0,\"TCP\",\"74.125.133.94\",80,0\r\n+CIPSTATUS:1,\"TCP\",\"192.168.20.1\",80,0\r\n\r\nOK\r\n";
            string buffer = "STATUS:3\r\n\r\nOK\r\n";
            BrusDev.Text.RegularExpressions.Regex r = new BrusDev.Text.RegularExpressions.Regex(@"STATUS:[0-9]\r\n(\+CIPSTATUS:[^\r\n]+\r\n)*\r\n(OK)\r\n");
            BrusDev.Text.RegularExpressions.Match m = r.Match(buffer);

            int connectionId;
            int clientConnectionId;
            int receivedBytes;
            int totalReceivedBytes;
            byte[] sendingBuffer;
            byte[] receivingBuffer;
            string remoteIPAddress;
            string connectionStatus;
            #if MF_FRAMEWORK
            Microsoft.SPOT.Hardware.OutputPort deviceSwitch = new Microsoft.SPOT.Hardware.OutputPort(
                SecretLabs.NETMF.Hardware.NetduinoPlus.Pins.GPIO_PIN_D2, false);
            #endif

            receivingBuffer = new byte[128];

            using (SerialPort serialPort = new SerialPort("COM10", 9600,
                System.IO.Ports.Parity.None, 8, System.IO.Ports.StopBits.One))
            {
                serialPort.Open();

            #if MF_FRAMEWORK
                deviceSwitch.Write(true);

                using (ESP8266ATModem modem = new ESP8266ATModem(serialPort))
            #else
                using (ESP8266ATModem modem = new ESP8266ATModem(serialPort.BaseStream))
            #endif
                {
                    //modem.AccessPointName = "Vodafone-brusnet";
                    //modem.AccessPassword = "******";
                    modem.AccessPointName = "LeonardoRicerche";
                    modem.AccessPassword = "******";

                    modem.OpenDataConnection();

                    //remoteIPAddress = "192.168.10.1";
                    remoteIPAddress = "www.google.it";

                    connectionStatus = modem.GetIPConnectionStatus(0);

                    modem.StartListening(1234);

                    clientConnectionId = modem.Accept();

                    sendingBuffer = Encoding.UTF8.GetBytes("HELLO\r\n");
                    modem.SendData(clientConnectionId, sendingBuffer, 0, sendingBuffer.Length);

                    totalReceivedBytes = 0;
                    while ((receivedBytes = modem.ReceiveData(clientConnectionId, receivingBuffer, 0, receivingBuffer.Length)) > 0)
                    {
                        totalReceivedBytes += receivedBytes;

                        //Debug.Print(new string(Encoding.UTF8.GetChars(receivingBuffer, 0, receivedBytes)));

                        //modem.SendData(clientConnectionId, receivingBuffer, 0, receivedBytes);

                        Debug.Print("ReceiveData > " + receivedBytes + "/" + totalReceivedBytes);
                    }

                    connectionId = modem.OpenIPConnection("TCP", remoteIPAddress, 80);

                    connectionStatus = modem.GetIPConnectionStatus(connectionId);

                    sendingBuffer = Encoding.UTF8.GetBytes("GET / HTTP/1.0\r\n\r\n");
                    modem.SendData(connectionId, sendingBuffer, 0, sendingBuffer.Length);

                    totalReceivedBytes = 0;
                    while ((receivedBytes = modem.ReceiveData(connectionId, receivingBuffer, 0, receivingBuffer.Length)) > 0)
                    {
                        totalReceivedBytes += receivedBytes;

                        if (totalReceivedBytes < 1000)
                        {
                            Debug.Print(new string(Encoding.UTF8.GetChars(receivingBuffer, 0, receivedBytes)));
                        }

                        //modem.SendData(clientConnectionId, receivingBuffer, 0, receivedBytes);

                        Debug.Print("ReceiveData > " + receivedBytes + "/" + totalReceivedBytes);
                    }

                    modem.CloseIPConnection(connectionId);
                    modem.CloseDataConnection();
                }
            }
        }
 public OutputPort(Microsoft.SPOT.Hardware.OutputPort outputPort)
 {
     _internalPort = outputPort;
 }