Exemple #1
0
        public string ReadCharsetVersion()
        {
            EEPROM tempEeprom = new EEPROM();


            bool       fail = false;
            ArduinoSTK sp   = osd.OpenArduino();


            if (sp != null && sp.connectAP())
            {
                try {
                    for (int i = 0; i < 5; i++)   //try to download two times if it fail
                    {
                        byte[] data = sp.download(EEPROM_SIZE);
                        if (!sp.down_flag)
                        {
                            if (sp.keepalive())
                            {
                                Console.WriteLine("keepalive successful (iter " + i + ")");
                            }
                            else
                            {
                                Console.WriteLine("keepalive fail (iter " + i + ")");
                            }
                        }
                        else
                        {
                            eeprom.data = data;
                            break;
                        }
                    }
                } catch (Exception ex) {
                    MessageBox.Show(ex.Message);
                }
            }
            else
            {
                MessageBox.Show("Failed to talk to bootloader");
                fail = true;
            }

            sp.Close();

            if (!fail)
            {
                //lblLatestCharsetUploaded.Text = "Last charset uploaded to OSD: " + tempEeprom[CS_VERSION1_ADDR].ToString() + "." + tempEeprom[CS_VERSION1_ADDR + 1].ToString() + "." + tempEeprom[CS_VERSION1_ADDR + 2].ToString();
                return(tempEeprom.CS_version);
            }
            return("");
        }
Exemple #2
0
        public OSD.ModelType GetModelType()
        {
            OSD.ModelType modelType  = OSD.ModelType.Unknown;
            EEPROM        tempEeprom = new EEPROM();

            ArduinoSTK sp = osd.OpenArduino();

            if (sp.connectAP())
            {
                try {
                    for (int i = 0; i < 5; i++)   //try to download two times if it fail
                    {
                        byte[] data = sp.download(EEPROM_SIZE);
                        if (!sp.down_flag)
                        {
                            if (sp.keepalive())
                            {
                                Console.WriteLine("keepalive successful (iter " + i + ")");
                            }
                            else
                            {
                                Console.WriteLine("keepalive fail (iter " + i + ")");
                            }
                        }
                        else
                        {
                            tempEeprom.data = data;
                            break;
                        }
                    }
                    modelType = (OSD.ModelType)tempEeprom.sets.model_type;
                } catch (Exception ex) {
                    MessageBox.Show(ex.Message);
                }
            }
            else
            {
                MessageBox.Show("Failed to talk to bootloader");
            }

            sp.Close();

            //Setup configuration panel
            return(modelType);
        }
Exemple #3
0
        public bool WriteCharsetVersion(string version)
        {
            //			byte[] tempEeprom = new byte[3];
            //			tempEeprom[0] = (byte)version[0];
            //			tempEeprom[1] = (byte)version[1];
            //			tempEeprom[2] = (byte)version[2];

            EEPROM tempEeprom = new EEPROM();

            ArduinoSTK sp = osd.OpenArduino();

            if(sp!=null && sp.connectAP()) {
                // Сначала считать
                try {
                    for (int i = 0; i < 5; i++) { //try to download two times if it fail
                        byte[] data = sp.download(EEPROM_SIZE);
                        if(sp.down_flag) {
                            tempEeprom.data = data;
                            break;
                        } else {
                            if(sp.keepalive())
                                Console.WriteLine("keepalive successful (iter " + i + ")");
                            else
                                Console.WriteLine("keepalive fail (iter " + i + ")");
                        }
                    }
                } catch (Exception ex) {
                    MessageBox.Show(ex.Message);
                    return false;
                }

                tempEeprom.CS_version = version ;

                try {
                    bool spupload_flag = false;
                    for (int i = 0; i < 10; i++) { //try to upload two times if it fail
            //						spupload_flag = sp.upload(tempEeprom, (short)0, (short)tempEeprom.Length, (short)CS_VERSION1_ADDR);
                        spupload_flag = sp.upload(tempEeprom.data , (short)Settings_offset, (short)Settings_size, (short)Settings_offset);
                        if(!spupload_flag) {
                            if(sp.keepalive())
                                Console.WriteLine("keepalive successful (iter " + i + ")");
                            else
                                Console.WriteLine("keepalive fail (iter " + i + ")");
                        } else
                            break;
                    }
                    if(spupload_flag)
                        MessageBox.Show("Done writing configuration data!");
                    else
                        MessageBox.Show("Failed to upload new configuration data");
                } catch (Exception ex) {
                    MessageBox.Show(ex.Message);
                }
            } else {
                MessageBox.Show("Failed to talk to bootloader");
            }

            sp.Close();
            return true;
        }
Exemple #4
0
        public string ReadCharsetVersion()
        {
            EEPROM tempEeprom = new EEPROM();

            bool fail = false;
            ArduinoSTK sp = osd.OpenArduino();

            if(sp!=null && sp.connectAP()) {
                try {
                    for (int i = 0; i < 5; i++) { //try to download two times if it fail
                        byte[] data = sp.download(EEPROM_SIZE);
                        if(!sp.down_flag) {
                            if(sp.keepalive())
                                Console.WriteLine("keepalive successful (iter " + i + ")");
                            else
                                Console.WriteLine("keepalive fail (iter " + i + ")");
                        } else {
                            eeprom.data = data;
                            break;
                        }
                    }
                } catch (Exception ex) {
                    MessageBox.Show(ex.Message);
                }
            } else {
                MessageBox.Show("Failed to talk to bootloader");
                fail = true;
            }

            sp.Close();

            if(!fail) {
                //lblLatestCharsetUploaded.Text = "Last charset uploaded to OSD: " + tempEeprom[CS_VERSION1_ADDR].ToString() + "." + tempEeprom[CS_VERSION1_ADDR + 1].ToString() + "." + tempEeprom[CS_VERSION1_ADDR + 2].ToString();
                return tempEeprom.CS_version;
            }
            return "";
        }
Exemple #5
0
        public OSD.ModelType GetModelType()
        {
            OSD.ModelType modelType = OSD.ModelType.Unknown;
            EEPROM tempEeprom = new EEPROM();

            ArduinoSTK sp=osd.OpenArduino();

            if (sp.connectAP())
            {
                try
                {
                    for (int i = 0; i < 5; i++)
                    { //try to download two times if it fail
                        byte[] data = sp.download(EEPROM_SIZE);
                        if (!sp.down_flag)
                        {
                            if (sp.keepalive()) Console.WriteLine("keepalive successful (iter " + i + ")");
                            else Console.WriteLine("keepalive fail (iter " + i + ")");
                        } else {
                            tempEeprom.data=data;
                            break;
                        }
                    }
                    modelType = (OSD.ModelType)tempEeprom.sets.model_type ;
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
            }
            else
            {
                MessageBox.Show("Failed to talk to bootloader");
            }

            sp.Close();

            //Setup configuration panel
            return modelType;
        }
Exemple #6
0
        private OSD osd; // ссылка на родителя для удобия доступа

        #endregion Fields

        #region Constructors

        // методы
        public Config(OSD aosd)
        {
            osd = aosd;
            eeprom = new EEPROM();
            eeprom.clear();
        }
Exemple #7
0
        public bool WriteCharsetVersion(string version, bool showMsg = true)
        {
            //			byte[] tempEeprom = new byte[3];
            //			tempEeprom[0] = (byte)version[0];
            //			tempEeprom[1] = (byte)version[1];
            //			tempEeprom[2] = (byte)version[2];

            EEPROM tempEeprom = new EEPROM();

            ArduinoSTK sp = osd.OpenArduino();

            if (sp != null && sp.connectAP())
            {
                // Сначала считать
                try {
                    for (int i = 0; i < 5; i++)   //try to download two times if it fail
                    {
                        byte[] data = sp.download(EEPROM_SIZE);
                        if (sp.down_flag)
                        {
                            tempEeprom.data = data;
                            break;
                        }
                        else
                        {
                            if (sp.keepalive())
                            {
                                Console.WriteLine("keepalive successful (iter " + i + ")");
                            }
                            else
                            {
                                Console.WriteLine("keepalive fail (iter " + i + ")");
                            }
                        }
                    }
                } catch (Exception ex) {
                    MessageBox.Show(ex.Message);
                    return(false);
                }

                tempEeprom.CS_version = version;

                try {
                    bool spupload_flag = false;
                    for (int i = 0; i < 10; i++)   //try to upload two times if it fail
                    //						spupload_flag = sp.upload(tempEeprom, (short)0, (short)tempEeprom.Length, (short)CS_VERSION1_ADDR);
                    {
                        spupload_flag = sp.upload(tempEeprom.data, (short)Settings_offset, (short)Settings_size, (short)Settings_offset);
                        if (!spupload_flag)
                        {
                            if (sp.keepalive())
                            {
                                Console.WriteLine("keepalive successful (iter " + i + ")");
                            }
                            else
                            {
                                Console.WriteLine("keepalive fail (iter " + i + ")");
                            }
                        }
                        else
                        {
                            break;
                        }
                    }
                    if (spupload_flag)
                    {
                        if (showMsg)
                        {
                            MessageBox.Show("Done writing configuration data!");
                        }
                    }
                    else
                    {
                        MessageBox.Show("Failed to upload new configuration data");
                    }
                } catch (Exception ex) {
                    MessageBox.Show(ex.Message);
                }
            }
            else
            {
                MessageBox.Show("Failed to talk to bootloader");
            }

            sp.Close();
            return(true);
        }
Exemple #8
0
        private OSD osd;// ссылка на родителя для удобия доступа

        // методы
        public Config(OSD aosd)
        {
            osd    = aosd;
            eeprom = new EEPROM();
            eeprom.clear();
        }
Exemple #9
0
        private Compass osd;// ссылка на родителя для удобия доступа

        // методы
        public Config(Compass aosd)
        {
            osd    = aosd;
            eeprom = new EEPROM();
            eeprom.clear();
        }