Example #1
0
        void doUpload(ArduinoConnection con)
        {
            string _fileName = "";

            this.avrUploader.SetCurrentPortName(con.PortName);

            DirectoryInfo _dirInfo = new DirectoryInfo(info.TempDir);

            FileInfo[] _fileInfos = _dirInfo.GetFiles();

            foreach (var _file in _fileInfos)
            {
                if (_file.Extension.Equals(".hex"))
                {
                    _fileName = _file.FullName;
                    break;
                }
            }

            // Upload hex file by avrdude
            var s = avrUploader.uploadViaBootloader(_fileName);

            message(s);
            message("Upload complete");

            // cleanup
            Directory.Delete(info.TempDir, true);
        }
Example #2
0
        public ConnectionListItem(ArduinoConnection con, EventHandler OnRemove, EventHandler OnTest, EventHandler OnSelect)
        {
            this.Tag    = con;
            Name        = con.FriendlyName + con.IpAddress;
            this.Click += OnSelect;
            Cursor      = Cursors.Hand;
            //Name Label
            Label name = new Label()
            {
                Text     = con.FriendlyName,
                Location = new Point(10, 10),
                AutoSize = true
            };

            this.Controls.Add(name);
            //IP Label
            Label ip = new Label()
            {
                Text     = con.IpAddress + ":" + con.Port,
                Location = new Point(10, 30),
                AutoSize = true
            };

            Controls.Add(ip);
            //Remove Button
            Button removeButton = new Button()
            {
                Text     = "Remove",
                Tag      = con,
                Location = new Point(75, 45)
            };

            removeButton.Click += OnRemove;
            this.Controls.Add(removeButton);
        }
Example #3
0
        static void Main(string[] args)
        {
            // create the arduino connection
            a = new ArduinoConnection();
            // just use the last com port for this.. that one's usually the one
            a.PortName = ArduinoConnection.GetAvailablePorts().Last();

            // create the uploader
            // this is where the root of the ardiono ide installation lives
            var root    = @"C:\arduino-1.0.1";
            var tempDir = Environment.CurrentDirectory + "/Temp";

            var info = Uploader.GetUploadConfig(root, tempDir,
                                                "Arduino Mega 2560 or Mega ADK",
                                                CommunicationTypeEnum.USB);

            u            = new Uploader(info);
            u.OnError   += u_OnError;
            u.OnMessage += u_OnMessage;
            u.OnSuccess += u_OnSuccess;

            // do some tests
            runTest(new TestBlink(a, u));
            Thread.Sleep(4000);
            runTest(new TestSendOnOffMessage(a, u));
        }
Example #4
0
        private void Start()
        {
            _connection = new ArduinoConnection(definition.BaudRate, definition.PortName, "Test-Arduino");

            _connection.InitializeConnection();

            StartCoroutine(TestConnection());
        }
Example #5
0
        public void UploadCode(ArduinoConnection con, string code)
        {
            hasError = false;
            // close the arduino if it was open
            bool wasOpen = con.IsConnected;
            if (wasOpen)
            {
                message("Closing current arduino connection");
                con.CloseConnection();
            }

            if (con.PortName == "") throw new Exception("Arduino port not specified");

            var c = new Compiler(info);
            c.OnError += c_OnError;
            c.OnMessage += c_OnMessage;
            c.OnSuccess += c_OnSuccess;

            try
            {
                // need to compile it first
                c.Compile(code);

                if (!hasError)
                {
                    // upload sketch 
                    message("Uploading to device via " + con.PortName);

                    doUpload(con);
                }

            }
            catch (Exception ex)
            {
                message("Error uploading!");
                if (OnError != null) OnError(this, null);
            }
            finally
            {
                c.OnError -= c_OnError;
                c.OnMessage -= c_OnMessage;
                c.OnSuccess -= c_OnSuccess;
                c = null;

                // open the connection again if needed
                if (wasOpen)
                {
                    message("Re-opening arduino connection");
                    con.OpenConnection();
                }
            }

            if (!hasError)
            {
                if (OnSuccess != null) OnSuccess(this, null);
            }
        }
Example #6
0
        static void Main(string[] args)
        {
            ArduinoConnection arduinoConnection = new ArduinoConnection("COM3", 115200);

            if (args.Length > 0)
            {
                arduinoConnection.ProgramSecurityRegisterUserFieldData(args[0]);
            }
            System.Console.WriteLine(arduinoConnection.ReadSecurityRegister());
        }
Example #7
0
        public TrimConfigurationDialog(ConnectionManager manager, ArduinoConnection connection)
        {
            InitializeComponent();

            connectionManager    = manager;
            connectionProperties = connection;

            //populate sliders
            ForwardTrackBar.Value = connection.Trim.LeftToRightCorrection;
            YawTrackBar.Value     = connection.Trim.FrontToBackCorrection;
            RollTrackBar.Value    = connection.Trim.RollCorrection;
        }
    // Use this for initialization
    void Start()
    {
        player=FindObjectOfType(typeof(PlayerBehaviour)) as PlayerBehaviour;
        //meshSlender.enabled=false;

        //player.SetFeedBackAlpha(0.1f);

        gameController=FindObjectOfType(typeof(GameController)) as GameController;

        currentScareFactory=scareFactory;
        currentRadieusToSpawn=radiusToSpawn;

        arduino=FindObjectOfType(typeof(ArduinoConnection)) as ArduinoConnection;
    }
Example #9
0
        private void SaveButton_Click(object sender, EventArgs e)
        {
            ArduinoConnection conn = new ArduinoConnection()
            {
                FriendlyName    = nameField.Text,
                IpAddress       = IPField.Text,
                Port            = (int)PortField.Value,
                Password        = PasswordField.Text,
                ConnectionClass = ThrusterLayout.TL2
            };

            connectionManager.Add(conn);
            Close();
        }
Example #10
0
        private void RemoveButton_Click(object sender, EventArgs e)
        {
            ArduinoConnection conn = (ArduinoConnection)((Button)sender).Tag;

            if (openConnection == null || openConnection.connection != conn)
            {
                connectionManager.Remove(conn);
                if (conn == selectedConnection)
                {
                    selectedConnection = null;
                }
                PopulateConnectionsList();
            }
        }
Example #11
0
    // Use this for initialization
    void Start()
    {
        player = FindObjectOfType(typeof(PlayerBehaviour)) as PlayerBehaviour;
        //meshSlender.enabled=false;

        //player.SetFeedBackAlpha(0.1f);

        gameController = FindObjectOfType(typeof(GameController)) as GameController;

        currentScareFactory   = scareFactory;
        currentRadieusToSpawn = radiusToSpawn;

        arduino = FindObjectOfType(typeof(ArduinoConnection)) as ArduinoConnection;
    }
Example #12
0
        public static void TestClassinitialize(TestContext context)
        {
            var manager        = new ConnectionManager();
            var connectionInfo = new ArduinoConnection()
            {
                IpAddress       = "192.168.1.146",
                Port            = 1740,
                Password        = "******",
                ConnectionClass = "ThrusterLayout2Connection"
            };

            connection = manager.GetConnectionContext(connectionInfo);
            connection.OpenConnection();
            connection.Authorize();
        }
Example #13
0
        public static void Main()
        {
            Console.WriteLine("Init");

            var conn     = ArduinoConnection.Build();
            int sensorId = 0;

            conn.LogToConsole();
            conn.PrintLogToConsole();

            while (true)
            {
                sensorId = (sensorId + 1) % 4;
                Thread.Sleep(3000);
                conn.Write(sensorId.ToString());
                conn.Read();
                Thread.Sleep(3000);
                conn.Write("10");
                conn.Read();
            }
        }
Example #14
0
        static void Main(string[] args)
        {
            var arguments = new ProgramArguments();

            args = Arguments.Parse(args, arguments);

            if (arguments.PrintHelp)
            {
                System.Console.Write(Arguments.GetDescriptionText(arguments));
                Environment.Exit(1);
            }

            ArduinoConnection arduinoConnection = new ArduinoConnection(arguments.Port, arguments.Speed);

            using (var inputStream = GetFileOrUrlStream(args[0]))
            {
                IEnumerable pageEnumerable = IsBitFile(args[0]) ?
                                             (IEnumerable) new BitFilePageCollection(inputStream, Constants.UserStartAddress) :
                                             (IEnumerable) new BinFilePageCollection(inputStream, Constants.UserStartAddress);
                arduinoConnection.UploadPages(pageEnumerable);
            }
        }
Example #15
0
        private void ConnectionSelected(object sender, EventArgs e)
        {
            ConnectionListItem selectedConn = (ConnectionListItem)sender;

            if (selectedConn.Selected)
            {
                //unselecting
                this.selectedConnection = null;
                SetConnectionSpecificButtonsEnabled(selectedConn.ToggleSelected());
            }
            else
            {
                //selecting
                //make sure one is not already selected
                if (this.selectedConnection == null)
                {
                    SetConnectionSpecificButtonsEnabled(true);
                    this.selectedConnection = (ArduinoConnection)selectedConn.Tag;
                    selectedConn.ToggleSelected();
                }
            }
        }
 public TestSendOnOffMessage(ArduinoConnection a, Uploader u)
 {
     this.a = a;
     this.u = u;
 }
Example #17
0
 protected ConnectionContext(ArduinoConnection connection)
 {
     this.connection = connection;
 }
Example #18
0
 public ThrusterLayout2Connection(ArduinoConnection connection) : base(connection)
 {
 }
Example #19
0
 public OnOffActuatorPinSender(ArduinoConnection con, ActuatorPins pins)
 {
     this.pinSender = new SimplePinSender(con);
     this.pins      = pins;
 }
 // Use this for initialization
 void Start()
 {
     gameController=FindObjectOfType(typeof(GameController)) as GameController;
     arduino=FindObjectOfType(typeof(ArduinoConnection)) as ArduinoConnection;
 }
Example #21
0
 public ConnectionContext GetConnectionContext(ArduinoConnection connection)
 {
     return((ConnectionContext)System.Reflection.Assembly.GetExecutingAssembly().CreateInstance("ROV2019.Presenters." + connection.ConnectionClass, true, System.Reflection.BindingFlags.CreateInstance, null, new object[] { connection }, null, null));
 }
Example #22
0
        public void UploadCode(ArduinoConnection con, string code)
        {
            hasError = false;
            // close the arduino if it was open
            bool wasOpen = con.IsConnected;

            if (wasOpen)
            {
                message("Closing current arduino connection");
                con.CloseConnection();
            }

            if (con.PortName == "")
            {
                throw new Exception("Arduino port not specified");
            }

            var c = new Compiler(info);

            c.OnError   += c_OnError;
            c.OnMessage += c_OnMessage;
            c.OnSuccess += c_OnSuccess;

            try
            {
                // need to compile it first
                c.Compile(code);

                if (!hasError)
                {
                    // upload sketch
                    message("Uploading to device via " + con.PortName);

                    doUpload(con);
                }
            }
            catch (Exception ex)
            {
                message("Error uploading!");
                if (OnError != null)
                {
                    OnError(this, null);
                }
            }
            finally
            {
                c.OnError   -= c_OnError;
                c.OnMessage -= c_OnMessage;
                c.OnSuccess -= c_OnSuccess;
                c            = null;

                // open the connection again if needed
                if (wasOpen)
                {
                    message("Re-opening arduino connection");
                    con.OpenConnection();
                }
            }

            if (!hasError)
            {
                if (OnSuccess != null)
                {
                    OnSuccess(this, null);
                }
            }
        }
Example #23
0
 public TestBlink(ArduinoConnection a, Uploader u)
 {
     this.a = a;
     this.u = u;
 }
 public OnOffActuatorPinSender(ArduinoConnection con, ActuatorPins pins)
 {
     this.pinSender = new SimplePinSender(con);
     this.pins = pins;
 }
Example #25
0
        void doUpload(ArduinoConnection con)
        {
            string _fileName = "";

            this.avrUploader.SetCurrentPortName(con.PortName);

            DirectoryInfo _dirInfo = new DirectoryInfo(info.TempDir);
            FileInfo[] _fileInfos = _dirInfo.GetFiles();

            foreach (var _file in _fileInfos)
            {
                if (_file.Extension.Equals(".hex"))
                {
                    _fileName = _file.FullName;
                    break;
                }
            }

            // Upload hex file by avrdude
            var s = avrUploader.uploadViaBootloader(_fileName);
            message(s);
            message("Upload complete");

            // cleanup
            Directory.Delete(info.TempDir, true);
        }
Example #26
0
 // Use this for initialization
 void Start()
 {
     gameController = FindObjectOfType(typeof(GameController)) as GameController;
     arduino        = FindObjectOfType(typeof(ArduinoConnection)) as ArduinoConnection;
 }
Example #27
0
 protected override async Task InitializeAsyncCore()
 {
     _arduino = new ArduinoConnection(PinNumber, PositionOff, PositionIdle, PositionReady, PositionDepressed, PressTime);
     return;
 }