private void btnSetPosition_Click(object sender, EventArgs e)
        {
            using (SetPositionForm setPosition = new SetPositionForm())
            {
                if (setPosition.ShowDialog(this) == DialogResult.OK)
                {
                    Cortex.OpenFocus.Device dev = new Device();
                    dev.Connect(Serial);

                    dev.Position = UInt16.Parse(setPosition.Position);

                    dev.Disconnect();
                }
            }
        }
        private void LoadValues()
        {
            Cortex.OpenFocus.Device dev = new Device();
            dev.Connect(Serial);
            Version firmware = dev.FirmwareVersion;
            dev.Disconnect();

            this.tbName.Text                       = Device.Name;
            this.tbMaxPosition.Text                = Device.MaxPosition.ToString();
            this.tbTemperatureCoefficient.Text     = Device.TemperatureCoefficient.ToString();
            this.cbReverse.Checked                 = Device.Reverse;

            this.SerialNumber.Text                  = Serial;
            this.toolTip.SetToolTip(this.SerialNumber, Serial);
            this.FirmwareVersion.Text               = firmware.ToString();
        }
Exemple #3
0
        private void btnFindDevice_Click(object sender, EventArgs e)
        {
            try
            {
                done = false;
                Bootloader.Connect();
                PageSize = Bootloader.PageSize;
                FlashSize = Bootloader.FlashSize;

                Logger.Write("Connected");
            #if DEBUG
                Logger.Write("Page Size: " + PageSize.ToString() + " bytes");
                Logger.Write("Flash Size: " + FlashSize.ToString() + " bytes");
            #endif

                this.btnLocateFirmware.Enabled = true;
                this.btnFindDevice.Enabled = false;
            }
            catch (DeviceNotFoundException)
            {
                try
                {
                    Device dev = new Device();
                    dev.Connect();
                    Logger.Write("Rebooting device into firmware update mode...");
                    dev.RebootToBootloader();
                    dev.Disconnect();
                    while (wait) /* Wait for device to reboot and be enumerated by the OS */
                    {
                        System.Threading.Thread.Sleep(200);
                        Application.DoEvents();
                    }
                    wait = true;
                    btnFindDevice_Click(null, null);
                }
                catch (DeviceNotFoundException)
                {
                    done = true;
                    Logger.Write("Device not found!");
                }
                catch (NullReferenceException)
                {
                    done = true;
                    Logger.Write("Device not found!");
                }
            }
        }
Exemple #4
0
        public static void Connect()
        {
            try /* Try to connect to the bootloader */
            {
                Bootloader.Connect();

                Logger.Write("Device Found!");
                Logger.Write("Page Size: " + Bootloader.PageSize.ToString() + " bytes");
                Logger.Write("Flash Size: " + Bootloader.FlashSize.ToString() + " bytes");
                Logger.Write("EEPROM Size: " + Bootloader.EEPROMSize.ToString() + " bytes");
            }
            catch (DeviceNotFoundException) /* If the device isn't found... */
            {
                try /* Try connecting to the device and rebooting it into the bootloader */
                {
                    Device dev = new Device();
                    dev.Connect();
                    Logger.Write("Rebooting device into firmware update mode...");
                    dev.RebootToBootloader();
                    dev.Disconnect();
                    System.Threading.Thread.Sleep(2000);
                    Connect();
                    return;
                }
                catch (DeviceNotFoundException) /* If this is reach, the device probably is not connected */
                {
                    goto DeviceNotFound;
                }
                catch (NullReferenceException)
                {
                    goto DeviceNotFound;
                }
            }
            return;
            DeviceNotFound:
            Logger.Write("Device not found!", Logger.LogType.Error);
            return;
        }