Exemple #1
0
        public MainForm()
        {
            InitializeComponent();

            MMn.Renderer = new MMnRenderer();

            splitContainer1.FixedPanel       = FixedPanel.Panel1;
            splitContainer1.SplitterDistance = Settings.GetObject("MainForm Splitter Position", 260);
            MnNotifyNewVersion.Checked       = Settings.GetObject("Auto Update", true);
            MnNotifyMinorVersion.Checked     = Settings.GetObject("Auto Update Build", false);
            MnNotifyPreRelease.Checked       = Settings.GetObject("Auto Update Pre", false);

            MnAutoUpdate.DropDown.Closing += MnAutoUpdateDropDown_Closing;

            if (System.Threading.Thread.CurrentThread.Name == null)
            {
                System.Threading.Thread.CurrentThread.Name = "Main Thread";
            }

            using (SplashScreenForm f = new SplashScreenForm())
                f.ShowDialog();

            //build main communication object
            Firmware ftype = Settings.GetObject("Firmware Type", Firmware.Grbl);

            if (ftype == Firmware.Smoothie)
            {
                Core = new SmoothieCore(this, PreviewForm, JogForm);
            }
            else if (ftype == Firmware.Marlin)
            {
                Core = new MarlinCore(this, PreviewForm, JogForm);
            }
            else
            {
                Core = new GrblCore(this, PreviewForm, JogForm);
            }

            ExceptionManager.Core = Core;

            MnGrblConfig.Visible = Core.UIShowGrblConfig;
            MnUnlock.Visible     = Core.UIShowUnlockButtons;

            MnGrbl.Text = Core.Type.ToString();

            Core.MachineStatusChanged += OnMachineStatus;
            Core.OnFileLoaded         += OnFileLoaded;
            Core.OnOverrideChange     += RefreshOverride;
            Core.IssueDetected        += OnIssueDetected;

            PreviewForm.SetCore(Core);
            ConnectionForm.SetCore(Core);
            JogForm.SetCore(Core);

            GitHub.NewVersion += GitHub_NewVersion;

            ColorScheme.CurrentScheme = Settings.GetObject("Color Schema", ColorScheme.Scheme.BlueLaser);;
            RefreshColorSchema();             //include RefreshOverride();
            RefreshFormTitle();
        }
Exemple #2
0
        public Firmware GetFile(String file_name)
        {
            Debuger.PrintLn($"Getting file_name {file_name}.");
            Firmware temp = new Firmware($"Firmwares/{file_name}");

            return(temp);
        }
        public static Firmware UpdateCheckAuto(string model, string region, bool BinaryNature)
        {
            int      num      = 0;
            Firmware firmware = new Firmware();

            foreach (Func <string, string, string> func in FWFetch.FWFetchFuncs)
            {
                string str = func(model, region);
                if (!string.IsNullOrEmpty(str))
                {
                    num++;
                    firmware = UpdateCheck(model, region, str, BinaryNature, true);
                    if ((firmware.Version != null) || firmware.ConnectionError)
                    {
                        break;
                    }
                }
            }
            if (firmware.Version == null)
            {
                Logger.WriteLine("Error UpdateCheckAuto(): Could not fetch info for " + model + "/" + region + ". Please check the input data.");
            }
            firmware.FetchAttempts = num;
            return(firmware);
        }
Exemple #4
0
        public FirmwareUpdaterWindow(Firmware firmware, FirmwareLoader loader)
        {
            InitializeComponent();
            Icon = NFEPaths.ApplicationIcon;
            InitializeControls();

            m_firmware                = firmware;
            m_loader                  = loader;
            m_worker.DoWork          += BackgroundWorker_DoWork;
            m_worker.ProgressChanged += BackgroundWorker_ProgressChanged;

            Load += (s, e) =>
            {
                // When form shown as dialog we dont need to handle click event to close it,
                // otherwise we need to close application mannualy.
                if (!Modal)
                {
                    CancelButton.Click += (s1, e1) => Application.Exit();
                }
            };

            Closing += (s, e) =>
            {
                if (!CancelButton.Enabled)
                {
                    e.Cancel = true;
                    return;
                }
                HidConnector.Instance.DeviceConnected -= DeviceConnected;
            };
        }
Exemple #5
0
        /// <summary>
        /// Initializes a new instance of the <see cref="SMBIOS"/> class. Retrieves the SMBIOS information by WMI.
        /// </summary>
        /// <remarks>
        /// Retrieves the <b>SMBIOS</b> information by <b>WMI</b>
        /// </remarks>
        private SMBIOS()
        {
            string[] tableNames = Firmware.EnumerateTables(FirmwareProvider.RSMB);
            if (tableNames.Any())
            {
                byte[] rawSmbiosTable = Firmware.GetTable(FirmwareProvider.RSMB, tableNames[0]);
                _majorVersion = rawSmbiosTable[0x01];
                _minorVersion = rawSmbiosTable[0x02];
                Lenght        = rawSmbiosTable.Length - 0x08;

                var smbiosData = rawSmbiosTable.Extract(0x08, Lenght);
                SmbiosHelper.ToRawTables(smbiosData);
            }
            else
            {
                using (var wmi = new ManagementObjectSearcher("root\\WMI", "SELECT * FROM MSSmBios_RawSMBiosTables"))
                {
                    foreach (var o in wmi.Get())
                    {
                        var queryObj = (ManagementObject)o;
                        Lenght        = (int)(uint)queryObj["Size"];
                        _majorVersion = (byte)queryObj["SmbiosMajorVersion"];
                        _minorVersion = (byte)queryObj["SmbiosMinorVersion"];

                        SmbiosHelper.ToRawTables((byte[])queryObj["SMBiosData"]);
                    }
                }
            }
        }
Exemple #6
0
        public override void ShowSettings()
        {
            if (Path == null)
            {
                return;
            }

            base.ShowSettings();

            Console.WriteLine("Firmware\t{0}", Firmware.ToUpper());
            Console.WriteLine("Sound Card\t{0}\t{1}", SoundCard, VMware.ValueToDescripton(SoundCard));
            Console.WriteLine();

            List <string> NIC = NICs;

            if (NIC.Count > 0)
            {
                Console.Write("NICs");
            }

            for (int i = 0; i < NIC.Count; i++)
            {
                Console.WriteLine("\t[{0}]\t{1}\t{2}", i, NIC[i], VMware.ValueToDescripton(NIC[i]));
            }
        }
Exemple #7
0
        public async Task InitializeAsync()
        {
            Console.WriteLine($"Initialize");
            var twin = await this.deviceClient.GetTwinAsync().ConfigureAwait(false);

            if (twin != null && twin.Properties != null && twin.Properties.Reported != null &&
                twin.Properties.Reported.Contains(FirwarePropertyName))
            {
                currentFirmware =
                    (JObject.FromObject(twin.Properties.Reported[FirwarePropertyName])).ToObject <Firmware>();
            }
            else
            {
                currentFirmware = new Firmware
                {
                    DownloadUrl = new Uri("https://www.example.com/fw/0.0"),
                    Version     = new Common.Data.Version
                    {
                        Major = 0,
                        Minor = 0,
                    }
                };
            }

            this.PopulateDesiredFirmwareFromDesiredProperties(twin.Properties.Desired, true);
            await this.deviceClient.SetDesiredPropertyUpdateCallbackAsync(this.OnDesiredPropertiesChangeAsync, null);

            await this.deviceClient.UpdateReportedPropertiesAsync(this.GetReportedPropertiesPatch());

            this.CheckNewVersionAndApplyAsync().Fork();
        }
        /// <summary>Check if all task errors are palusible</summary>
        /// <returns>Empty string on success, else error text</returns>
        public string CheckTaskErrors()
        {
            Firmware fw          = new Firmware(Version);
            byte     allow_error = 0;

            for (int TaskPos = 0; TaskPos < mTaskAnzahl; TaskPos++)
            {
                for (int ErrPos = 0; ErrPos < 7; ErrPos++)
                {
                    allow_error = fw.GetTaskError(maTask[TaskPos].GetTaskId(), ErrPos);
                    if (allow_error != 255)
                    {
                        if ((mTaskErrorTable[TaskPos, ErrPos].ErrNo != allow_error) &&
                            (mTaskErrorTable[TaskPos, ErrPos].ErrNo != 0))
                        {
                            return(String.Format("Fehler {0}[{1}] != {2}", maTask[TaskPos].GetTaskId(), ErrPos, allow_error));
                        }
                    }
                    if ((mTaskErrorTable[TaskPos, ErrPos].ErrNo == 0) &&
                        (mTaskErrorTable[TaskPos, ErrPos].Ring))
                    {
                        return(String.Format("{0}[{1}] = 0 darf nicht auf Ring", maTask[TaskPos].GetTaskId(), ErrPos));
                    }
                }
            }
            return(String.Empty);
        }
        public FirmwareViewModel(Firmware firmware)
        {
            Status           = firmware.Status;
            UpdatableVersion = firmware.UpdatableVersion;

            _firmware = firmware;
        }
Exemple #10
0
            private static ICollection <FwNode> CombineFw(Firmware fw1, Firmware fw2, bool fillFF = false)
            {
                if (fw1 == null || fw2 == null)
                {
                    throw new FirmwareToolsException(471, ERR_471);
                }

                var matches = fw1.Nodes.Intersect(fw2.Nodes, new FwNodeAddrComparer());

                if (matches == null || matches.Count() < 1)
                {
                    fw1.Nodes.AddRange(fw2.Nodes);
                    var ret = fw1.Nodes.OrderBy(o => o.Addr).ToList();

                    if (fillFF)
                    {
                        return(FillGapsWithFF(ret).Data);
                    }
                    return(ret);
                }
                else
                {
                    throw new FirmwareToolsException(481, ERR_481);
                }
            }
        public void EncryptionTest()
        {
            var key = Encoding.ASCII.GetBytes("20121109joyetechjoyetech20128850");

            byte[] actual;
            using (var decFileStream = new FileStream("Evic11.dec", FileMode.Open, FileAccess.Read))
            using (var firmware = new Firmware(key))
            {
                decFileStream.CopyTo(firmware.Stream);
                firmware.UpdateHeader();

                actual = new byte[firmware.BaseStream.Length];
                firmware.BaseStream.Seek(0, SeekOrigin.Begin);
                firmware.BaseStream.Read(actual, 0, actual.Length);
            }

            byte[] expected;
            using (var encFileStream = new FileStream("Evic11.enc", FileMode.Open, FileAccess.Read))
            {
                expected = new byte[actual.Length];
                encFileStream.Read(expected, 0, expected.Length);
            }

            CollectionAssert.AreEquivalent(expected, actual);
        }
Exemple #12
0
 public void ParseFirmware(string FwPath)
 {
     Firmware fw1 = Parse(FwPath);                          // Fw.Format = AUTO
     Firmware fw2 = Parse(FwPath, FillFF: true);            // gaps are filled with 0xFF
     Firmware fw3 = Parse(FwPath, FwFormat.SREC);           // Fw.Format = SREC
     Firmware fw4 = Parse(FwPath, Log: new StringWriter()); // save parse log
 }
Exemple #13
0
 public FirmwareVo(Firmware firm)
 {
     Id          = firm.Id;
     Nombre      = firm.Nombre;
     Descripcion = firm.Descripcion;
     Firma       = firm.Firma;
 }
        public void OnFirmwareLoaded(Firmware firmware)
        {
            m_firmware        = firmware;
            m_suitablePatches = m_patchManager.LoadPatchesForFirmware(firmware.Definition).OrderBy(x => x.Name);

            PatchListView.Fill(m_suitablePatches.Select(patch =>
            {
                patch.IsApplied    = m_patchManager.IsPatchApplied(patch, m_firmware);
                patch.IsCompatible = m_patchManager.IsPatchCompatible(patch, m_firmware) || patch.IsApplied;
                return(new ListViewItem(new[]
                {
                    patch.Name,
                    patch.FileName,
                    patch.Version,
                    patch.IsApplied ? "Yes" : "No",
                    patch.IsCompatible ? "Yes" : "No"
                })
                {
                    Tag = patch
                });
            }));
            ReloadPatchesButton.Enabled = true;

            if (m_configuration.CheckForApplicationUpdates)
            {
                bool updatesAlreadyChecked;
                m_checkedFirmwares.TryGetValue(firmware.Definition.Name, out updatesAlreadyChecked);

                if (!updatesAlreadyChecked)
                {
                    m_checkedFirmwares[firmware.Definition.Name] = true;
                    CheckForUpdatesWithUserInteraction(false);
                }
            }
        }
        public PreviewResourcePackWindow
        (
            Firmware firmware,
            IList <int> originalImageIndices,
            IList <bool[, ]> importedImages,
            bool resourceImport          = false,
            BlockType?defaultImportBlock = null
        ) : this()
        {
            if (originalImageIndices.Count != importedImages.Count)
            {
                throw new InvalidOperationException("Source and imported images count does not match.");
            }
            m_firmware = firmware;

            if (m_firmware.Block2Images.Any())
            {
                ImportModeComboBox.Items.Add("Block 1 & 2");
                ImportModeComboBox.Items.Add("Block 1");
                ImportModeComboBox.Items.Add("Block 2");

                if (defaultImportBlock.HasValue)
                {
                    ImportModeComboBox.SelectedIndex = defaultImportBlock == BlockType.Block1 ? 1 : 2;
                }
                else
                {
                    ImportModeComboBox.SelectedIndex = 0;
                }
            }
            else
            {
                ImportModeComboBox.Items.Add("Block 1");
                ImportModeComboBox.SelectedIndex = 0;
            }

            OptionsGroupBox.Enabled = !resourceImport;
            LeftLayoutPanel.SuspendLayout();
            RightLayoutPanel.SuspendLayout();
            for (var i = 0; i < originalImageIndices.Count; i++)
            {
                var originalImageIndex = originalImageIndices[i];
                var originalImage      = GetImageByIndex(originalImageIndex);
                if (originalImage == null)
                {
                    continue;
                }

                var importedImage        = importedImages[i];
                var croppedImportedImage = FirmwareImageProcessor.PasteImage(originalImage, importedImage);

                m_originalImportedImages[i] = importedImage;
                m_croppedImportedImages[i]  = croppedImportedImage;

                LeftLayoutPanel.Controls.Add(CreateGrid(originalImage));
                RightLayoutPanel.Controls.Add(CreateGrid(croppedImportedImage));
            }
            LeftLayoutPanel.ResumeLayout();
            RightLayoutPanel.ResumeLayout();
        }
Exemple #16
0
        /// <summary>
        /// Returns the <see cref="Firmware"/> having the passed <see cref="Firmware.Id"/>.
        /// Additionally, the<code> uuid</code> and<code> leds</code> query parameter can be set. These parameter values will be added as query parameters in all hyperlinks of the returned resource representation such that
        /// a consumer of the REST API is navigated to an individual firmware file where these values are already injected.
        /// The methods throws a <see cref="ResourceNotFoundException"/> if the requested <see cref="Firmware"/> does not exist.
        /// </summary>
        /// <param name="id"><see cref="Firmware.Id"/> of the requested firmeware</param>
        /// <param name="query">additional query parameters containing the UUID and the LED count (can be null)</param>
        /// <returns>the <see cref="Firmware"/> having the passed ID</returns>
        public Firmware GetFirmware(string id, IDictionary <string, string> query)
        {
            IFirmwareDataSet fds = _firmwareStorage.GetFirmware(id);

            if (fds != null)
            {
                Firmware fw = new Firmware();
                fw.FirmwareId    = id;
                fw.MajorVersion  = fds.MajorVersion;
                fw.MinorVersion  = fds.MinorVersion;
                fw.DeviceName    = fds.DeviceName;
                fw.FileExtension = fds.FirmwareFileExtension;
                if (query != null && query.ContainsKey("uuid") && query.ContainsKey("leds"))
                {
                    fw.Uuid     = query["uuid"];
                    fw.LedCount = query["leds"];
                }
                fw.HasRawData = _firmwareStorage.HasRawData(id);
                return(fw);
            }
            else
            {
                throw new ResourceNotFoundException(ResourceNotFoundException.MSG_FIRMWARE_NOT_FOUND.Replace("{VALUE}", id));
            }
        }
        public static LayoutFilePatch[] GetFixLegacy(string LayoutName, Firmware fw, string nxName)
        {
            // Check PatchRevision definitions in PatchTemplte.cs for firmware version
            if (fw >= Firmware.Fw9_0 && nxName == "lock")
            {
                if (LayoutName.ToLower().Contains("clear lockscreen"))
                {
                    return(JsonConvert.DeserializeObject <LayoutPatch>(ClearLock9Fix).Files);
                }
            }

            // These are have all been updated in the builtins as of 4.4
            if (fw >= Firmware.Fw8_0 && nxName == "home")             // >= 8.0 home menu
            {
                if (LayoutName.ToLower().Contains("dogelayout") || LayoutName.ToLower().Contains("clearlayout"))
                {
                    return(JsonConvert.DeserializeObject <LayoutPatch>(DogeLayoutFix).Files);
                }
                else if (LayoutName.ToLower().Contains("diamond layout"))
                {
                    return(JsonConvert.DeserializeObject <LayoutPatch>(DiamondFix).Files);
                }
                else if (LayoutName.ToLower().Contains("small compact"))
                {
                    return(JsonConvert.DeserializeObject <LayoutPatch>(CompactFix).Files);
                }
            }
            return(null);
        }
Exemple #18
0
 private void CMB_history_SelectedIndexChanged(object sender, EventArgs e)
 {
     firmwareurl = Firmware.getUrl(CMB_history.SelectedValue.ToString(), "");
     REL_Type    = (APFirmware.RELEASE_TYPES) 99;
     softwares.Clear();
     UpdateFWList();
 }
Exemple #19
0
        private void but_getfw_Click(object sender, EventArgs e)
        {
            string basedir = Application.StartupPath + Path.DirectorySeparatorChar + "History";

            Directory.CreateDirectory(basedir);

            Firmware fw = new Firmware();

            var list = fw.getFWList();

            using (XmlTextWriter xmlwriter = new XmlTextWriter(basedir + Path.DirectorySeparatorChar + @"firmware2.xml", Encoding.ASCII))
            {
                xmlwriter.Formatting = Formatting.Indented;

                xmlwriter.WriteStartDocument();

                xmlwriter.WriteStartElement("options");

                foreach (var software in list)
                {
                    xmlwriter.WriteStartElement("Firmware");

                    xmlwriter.WriteElementString("url", new Uri(software.url).LocalPath.TrimStart('/', '\\'));
                    xmlwriter.WriteElementString("url2560", new Uri(software.url2560).LocalPath.TrimStart('/', '\\'));
                    xmlwriter.WriteElementString("url2560-2", new Uri(software.url2560_2).LocalPath.TrimStart('/', '\\'));
                    xmlwriter.WriteElementString("urlpx4", new Uri(software.urlpx4v1).LocalPath.TrimStart('/', '\\'));
                    xmlwriter.WriteElementString("urlpx4v2", new Uri(software.urlpx4v2).LocalPath.TrimStart('/', '\\'));
                    xmlwriter.WriteElementString("name", software.name);
                    xmlwriter.WriteElementString("desc", software.desc);
                    xmlwriter.WriteElementString("format_version", software.k_format_version.ToString());

                    xmlwriter.WriteEndElement();

                    if (software.url != "")
                    {
                        Common.getFilefromNet(software.url, basedir + new Uri(software.url).LocalPath);
                    }
                    if (software.url2560 != "")
                    {
                        Common.getFilefromNet(software.url2560, basedir + new Uri(software.url2560).LocalPath);
                    }
                    if (software.url2560_2 != "")
                    {
                        Common.getFilefromNet(software.url2560_2, basedir + new Uri(software.url2560_2).LocalPath);
                    }
                    if (software.urlpx4v1 != "")
                    {
                        Common.getFilefromNet(software.urlpx4v1, basedir + new Uri(software.urlpx4v1).LocalPath);
                    }
                    if (software.urlpx4v2 != "")
                    {
                        Common.getFilefromNet(software.urlpx4v2, basedir + new Uri(software.urlpx4v2).LocalPath);
                    }
                }

                xmlwriter.WriteEndElement();
                xmlwriter.WriteEndDocument();
            }
        }
Exemple #20
0
        public void GetFirmware(HttpContext context, string firmwareId)
        {
            Firmware firmware = _firmwareHandler.GetFirmware(firmwareId, context.Request.ParsedQuery);
            string   json     = JsonSerializer.SerializeJson(firmware);

            context.Response.Payload.Write(json);
            context.Response.Status = HttpStatus.OK;
        }
Exemple #21
0
        private void but_getfw_Click(object sender, EventArgs e)
        {
            var basedir = Settings.GetDataDirectory() + "History";

            Directory.CreateDirectory(basedir);

            var fw = new Firmware();

            var list = fw.getFWList();

            var options = new optionsObject();

            options.softwares = list;

            var members = typeof(software).GetFields();

            XmlWriterSettings settings = new XmlWriterSettings();

            settings.IndentChars = "    ";
            settings.Indent      = true;
            settings.Encoding    = Encoding.ASCII;

            using (var xmlwriter = XmlWriter.Create(basedir + Path.DirectorySeparatorChar + @"firmware2.xml", settings))
            {
                for (int a = 0; a < options.softwares.Count; a++)
                {
                    Loading.ShowLoading(((a - 1) / (float)list.Count) * 100.0 + "% " + options.softwares[a].name, this);

                    List <Task <bool> > tasklist = new List <Task <bool> >();

                    foreach (var field in members)
                    {
                        if (field.Name.ToLower().Contains("url"))
                        {
                            var url = field.GetValue(options.softwares[a]).ToString();

                            if (String.IsNullOrEmpty(url))
                            {
                                continue;
                            }

                            field.SetValue(options.softwares[a], new Uri(url).LocalPath.TrimStart('/', '\\'));

                            var task = Download.getFilefromNetAsync(url, basedir + new Uri(url).LocalPath);
                            tasklist.Add(task);
                        }
                    }

                    //Task.WaitAll(tasklist.ToArray());
                }

                XmlSerializer xms = new XmlSerializer(typeof(optionsObject), new Type[] { typeof(software) });

                xms.Serialize(xmlwriter, options);
            }
            Loading.Close();
        }
        public async Task <InvokeResult> UpdateFirmwareAsync(Firmware firmware, EntityHeader org, EntityHeader user)
        {
            ValidationCheck(firmware, Actions.Update);
            await AuthorizeAsync(firmware, AuthorizeResult.AuthorizeActions.Update, user, org);

            await _repo.UpdateFirmwareAsync(firmware);

            return(InvokeResult.Success);
        }
        public static AnimFilePatch[] GetNoOnlineButtonFix(Firmware fw)
        {
            if (fw >= Firmware.Fw11_0)
            {
                return(JsonConvert.DeserializeObject <LayoutPatch>(NoOnlineButton).Anims);
            }

            return(null);
        }
        public static AnimFilePatch[] GetAppletsPositionFix(Firmware fw)
        {
            if (fw >= Firmware.Fw11_0)
            {
                return(JsonConvert.DeserializeObject <LayoutPatch>(NoMoveApplets11).Anims);
            }

            return(null);
        }
        private void Lbl_Custom_firmware_label_Click(object sender, EventArgs e)
        {
            using (var fd = new OpenFileDialog {
                Filter = "Firmware (*.hex;*.px4;*.vrx;*.apj)|*.hex;*.px4;*.vrx;*.apj|All files (*.*)|*.*"
            })
            {
                if (Directory.Exists(custom_fw_dir))
                {
                    fd.InitialDirectory = custom_fw_dir;
                }
                fd.ShowDialog();
                if (File.Exists(fd.FileName))
                {
                    custom_fw_dir = Path.GetDirectoryName(fd.FileName);
                    Settings.Instance["FirmwareFileDirectory"] = custom_fw_dir;

                    var fw = new Firmware();

                    fw.Progress += fw_Progress1;

                    var boardtype = BoardDetect.boards.none;
                    try
                    {
                        if (fd.FileName.ToLower().EndsWith(".px4") || fd.FileName.ToLower().EndsWith(".apj"))
                        {
                            if (solo.Solo.is_solo_alive &&
                                CustomMessageBox.Show("Solo", "Is this a Solo?", CustomMessageBox.MessageBoxButtons.YesNo) == CustomMessageBox.DialogResult.Yes)
                            {
                                boardtype = BoardDetect.boards.solo;
                            }
                            else
                            {
                                boardtype = BoardDetect.boards.px4v2;
                            }
                        }
                        else
                        {
                            boardtype = BoardDetect.DetectBoard(MainV2.comPortName, Win32DeviceMgmt.GetAllCOMPorts());
                        }

                        if (boardtype == BoardDetect.boards.none)
                        {
                            CustomMessageBox.Show(Strings.CantDetectBoardVersion);
                            return;
                        }
                    }
                    catch
                    {
                        CustomMessageBox.Show(Strings.CanNotConnectToComPortAnd, Strings.ERROR);
                        return;
                    }

                    fw.UploadFlash(MainV2.comPortName, fd.FileName, boardtype);
                }
            }
        }
        public static LayoutFilePatch[] GetFix(string NxPart, string LayoutID, Firmware fw)
        {
            // As of 4.5 this still hasn't been fixed in the builtin layouts but it has been given an ID
            if (fw >= Firmware.Fw9_0 && LayoutID == "builtin_ClearLock" && NxPart == "lock")             /* Do we need NxPart ? */
            {
                return(JsonConvert.DeserializeObject <LayoutPatch>(ClearLock9Fix).Files);
            }

            return(null);
        }
        public FirmwareViewModel Load(string path)
        {
            using (var fileStream = new FileStream(path, FileMode.Open, FileAccess.Read))
            using (var firmwareFile = new Firmware(fileStream))
            {
                var stream = firmwareFile.Stream;
            }

            return null;
        }
        public void OnFirmwareLoaded(Firmware firmware)
        {
            m_firmware = firmware;

            Block1ImageRadioButton.Enabled = true;
            Block1ImageRadioButton.Checked = true;
            Block2ImageRadioButton.Enabled = m_firmware.Block2Images.Any();

            Block2ImageListBox.Fill(m_firmware.Block2Images.Select(x => new ImagedItem <FirmwareImageMetadata>(x, x.Index, string.Format("0x{0:X2}", x.Index))), true);
            Block1ImageListBox.Fill(m_firmware.Block1Images.Select(x => new ImagedItem <FirmwareImageMetadata>(x, x.Index, string.Format("0x{0:X2}", x.Index))), true);
        }
        public static void RebuildCache([NotNull] Firmware firmware)
        {
            if (firmware == null)
            {
                throw new ArgumentNullException("firmware");
            }

            RebuildGlyphImageCache(firmware);
            RebuildStringImageCache(firmware, BlockType.Block1);
            RebuildStringImageCache(firmware, BlockType.Block2);
        }
        public FirmwareUpdaterWindow(Firmware firmware, FirmwareLoader loader)
        {
            InitializeComponent();
            Icon = Paths.ApplicationIcon;
            InitializeControls();

            m_firmware                = firmware;
            m_loader                  = loader;
            m_worker.DoWork          += BackgroundWorker_DoWork;
            m_worker.ProgressChanged += BackgroundWorker_ProgressChanged;
        }
Exemple #31
0
 private bool ValidFirmware(Firmware firmware)
 {
     if (ValidHomieESP8266Firmware(firmware))
     {
         return(true);
     }
     else
     {
         return(false);
     }
 }
Exemple #32
0
            /// <summary>
            /// Combines two firmware files into single one with format specified. Usually, main firmware
            /// and EEPROM file is done this way, or main firmware and Info A flash content is merged.
            /// Returned Fw is firmware and Format1 with Format2 are useful for auto-detect feedback, indicates input formats.
            /// <para/>FillFF is optional parameter forcing to fill missing addr nodes with 0xFF
            /// and return monolithic piece of code, which is usefull for crc calc or overwriting whole memory in mcu.
            /// <para/>LineLength defines amount of data bytes per one text row. When = 0, default values are set
            /// (TI-TXT = 16, Intel-HEX = 32, SREC = 32).
            /// </summary>
            /// <exception cref="FirmwareToolsException"></exception>
            public static (string Fw, FwFormat Format1, FwFormat Format2) Combine(string FirmwarePath1,
                                                                                  string FirmwarePath2,
                                                                                  FwFormat Format,
                                                                                  bool FillFF    = false,
                                                                                  int LineLength = 0)
            {
                Firmware fw1 = ParseAutoDetect(FirmwarePath1, FillFF);
                Firmware fw2 = ParseAutoDetect(FirmwarePath2, FillFF);

                return(Create(CombineFw(fw1, fw2, FillFF), Format, LineLength), fw1.Info.Format, fw2.Info.Format);
            }
        public void DecryptionTest()
        {
            byte[] actual;
            using (var encFileStream = new FileStream("Evic11.enc", FileMode.Open, FileAccess.Read))
            using (var firmware = new Firmware(encFileStream))
            {
                actual = new byte[firmware.Stream.Length];
                firmware.Stream.Read(actual, 0, actual.Length);
            }

            byte[] expected;
            using (var decFileStream = new FileStream("Evic11.dec", FileMode.Open, FileAccess.Read))
            {
                expected = new byte[actual.Length];
                decFileStream.Read(expected, 0, expected.Length);
            }

            CollectionAssert.AreEquivalent(expected, actual);
        }
Exemple #34
0
            public EnsembleDataSet(int ValueType, int NumElements, int ElementsMultiplier, int Imag, int NameLength, string Name,
                                    int EnsembleNumber, int NumBins, int NumBeams, int DesiredPingCount, int ActualPingCount,
                                    SerialNumber SysSerialNumber, Firmware SysFirmware, SubsystemConfiguration SubsystemConfig, Status Status,
                                    int Year, int Month, int Day, int Hour, int Minute, int Second, int HSec)
                : base(ValueType, NumElements, ElementsMultiplier, Imag, NameLength, Name)
            {
                //this.UniqueId = UniqueId;
                this.EnsembleNumber = EnsembleNumber;
                this.NumBins = NumBins;
                this.NumBeams = NumBeams;
                this.DesiredPingCount = DesiredPingCount;
                this.ActualPingCount = ActualPingCount;
                this.SysSerialNumber = SysSerialNumber;
                this.SysFirmware = SysFirmware;
                this.SubsystemConfig = SubsystemConfig;
                this.Status = Status;
                this.Year = Year;
                this.Month = Month;
                this.Day = Day;
                this.Hour = Hour;
                this.Minute = Minute;
                this.Second = Second;
                this.HSec = HSec;
                //this.EnsDateTime = EnsDateTime;

                // Set the time and date
                ValidateDateTime(Year, Month, Day, Hour, Minute, Second, HSec / 10);

                // Create UniqueId
                UniqueId = new UniqueID(EnsembleNumber, EnsDateTime);
            }
 private void imageLabelapm2_Click(object sender, EventArgs e)
 {
     fw = Firmware.apm2;
     this.Close();
 }
 private void imageLabelpx4_Click(object sender, EventArgs e)
 {
     fw = Firmware.px4;
     this.Close();
 }
Exemple #37
0
            /// <summary>
            /// Read the JSON object and convert to the object.  This will allow the serializer to
            /// automatically convert the object.  No special instructions need to be done and all
            /// the properties found in the JSON string need to be used.
            /// 
            /// DataSet.EnsembleDataSet decodedEns = Newtonsoft.Json.JsonConvert.DeserializeObject{DataSet.EnsembleDataSet}(encodedEns)
            /// 
            /// </summary>
            /// <param name="reader">NOT USED. JSON reader.</param>
            /// <param name="objectType">NOT USED> Type of object.</param>
            /// <param name="existingValue">NOT USED.</param>
            /// <param name="serializer">Serialize the object.</param>
            /// <returns>Serialized object.</returns>
            public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
            {
                if (reader.TokenType != JsonToken.Null)
                {
                    // Load the object
                    JObject jsonObject = JObject.Load(reader);

                    // Decode the data
                    int NumElements = (int)jsonObject[DataSet.BaseDataSet.JSON_STR_NUMELEMENTS];
                    int ElementsMultiplier = (int)jsonObject[DataSet.BaseDataSet.JSON_STR_ELEMENTSMULTIPLIER];

                    // EnsembleNumber
                    int EnsembleNumber = (int)jsonObject[DataSet.BaseDataSet.JSON_STR_ENSEMBLENUMBER];

                    // NumBins
                    int NumBins = (int)jsonObject[DataSet.BaseDataSet.JSON_STR_NUMBINS];

                    // NumBeams
                    int NumBeams = (int)jsonObject[DataSet.BaseDataSet.JSON_STR_NUMBEAMS];

                    // DesiredPingCount
                    int DesiredPingCount = (int)jsonObject[DataSet.BaseDataSet.JSON_STR_DESIREDPINGCOUNT];

                    // ActualPingCount
                    int ActualPingCount = (int)jsonObject[DataSet.BaseDataSet.JSON_STR_ACTUALPINGCOUNT];

                    // SysSerialNumber
                    SerialNumber SysSerialNumber = new SerialNumber((string)jsonObject[DataSet.BaseDataSet.STR_JSON_SERIALNUMBER_SERIALNUMBERSTRING]);

                    // SysFirmware
                    ushort major = (ushort)jsonObject[DataSet.BaseDataSet.JSON_STR_FIRMWAREMAJOR];
                    ushort minor = (ushort)jsonObject[DataSet.BaseDataSet.JSON_STR_FIRMWAREMINOR];
                    ushort rev = (ushort)jsonObject[DataSet.BaseDataSet.JSON_STR_FIRMWAREREVISION];
                    byte code = (byte)jsonObject[DataSet.BaseDataSet.JSON_STR_SUBSYSTEMCODE].ToObject<byte>();
                    Firmware SysFirmware = new Firmware(code, major, minor, rev);

                    // SubsystemConfig
                    ushort index = (ushort)jsonObject[DataSet.BaseDataSet.JSON_STR_SUBSYSTEM_INDEX];
                    byte ssCode = (byte)jsonObject[DataSet.BaseDataSet.JSON_STR_SUBSYSTEM_CODE].ToObject<byte>();
                    byte cepoIndex = (byte)jsonObject[DataSet.BaseDataSet.JSON_STR_CEPOINDEX].ToObject<byte>();
                    byte configNum = (byte)jsonObject[DataSet.BaseDataSet.JSON_STR_SSCONFIG_INDEX].ToObject<byte>();
                    SubsystemConfiguration SubsystemConfig = new SubsystemConfiguration(new Subsystem(ssCode, index), cepoIndex, configNum);

                    // Status
                    Status status = new Status((int)jsonObject[DataSet.BaseDataSet.JSON_STR_STATUS]);

                    // Year
                    int Year = (int)jsonObject[DataSet.BaseDataSet.JSON_STR_YEAR];

                    // Month
                    int Month = (int)jsonObject[DataSet.BaseDataSet.JSON_STR_MONTH];

                    // Day
                    int Day = (int)jsonObject[DataSet.BaseDataSet.JSON_STR_DAY];

                    // Hour
                    int Hour = (int)jsonObject[DataSet.BaseDataSet.JSON_STR_HOUR];

                    // Minute
                    int Minute = (int)jsonObject[DataSet.BaseDataSet.JSON_STR_MINUTE];

                    // Second
                    int Second = (int)jsonObject[DataSet.BaseDataSet.JSON_STR_SECOND];

                    // HSec
                    int HSec = (int)jsonObject[DataSet.BaseDataSet.JSON_STR_HSEC];

                    // Create the object
                    // Need to call the constructor to create
                    // the correct EnsDateTime and UniqueID
                    var data = new EnsembleDataSet(DataSet.Ensemble.DATATYPE_INT, NumElements, ElementsMultiplier, DataSet.Ensemble.DEFAULT_IMAG, DataSet.Ensemble.DEFAULT_NAME_LENGTH, DataSet.Ensemble.EnsembleDataID,
                                                    EnsembleNumber, NumBins, NumBeams, DesiredPingCount, ActualPingCount,
                                                    SysSerialNumber, SysFirmware, SubsystemConfig, status,
                                                    Year, Month, Day, Hour, Minute, Second, HSec);

                    return data;
                }

                return null;
            }
Exemple #38
0
            /// <summary>
            /// Create a Ensemble data set.  This will create a blank dataset.  The user must fill in the data for all
            /// the important values.
            /// </summary>
            /// <param name="valueType">Whether it contains 32 bit Integers or Single precision floating point </param>
            /// <param name="numElments">Number of Elements.</param>
            /// <param name="elementMultiplier">Element Multipliers.</param>
            /// <param name="imag"></param>
            /// <param name="nameLength">Length of name</param>
            /// <param name="name">Name of data type</param>
            /// <param name="numBins">Number of Bin</param>
            /// <param name="numBeams">Number of beams</param>
            public EnsembleDataSet(int valueType, int numElments, int elementMultiplier, int imag, int nameLength, string name, int numBins, int numBeams)
                : base(valueType, numElments, elementMultiplier, imag, nameLength, name)
            {
                // Set the ensemble number to the default ensemble number
                EnsembleNumber = DEFAULT_ENS_NUM;

                // Set time to the current time
                SetTime();

                // Create UniqueId
                UniqueId = new UniqueID(EnsembleNumber, EnsDateTime);

                // Set the number of beams
                NumBeams = numBeams;

                // Set the number of bins
                NumBins = numBins;

                // Use a blank serial number
                SysSerialNumber = new SerialNumber();

                // Create blank firmware
                SysFirmware = new Firmware();

                // Create Blank Subsystem configuration
                SubsystemConfig = new SubsystemConfiguration();

                // Create a blank status
                Status = new Status(0);
            }
Exemple #39
0
            /// <summary>
            /// Decode the break statement of all its data.
            /// 
            /// Ex:
            /// Copyright (c) 2009-2012 Rowe Technologies Inc. All rights reserved.
            /// DP300 DP1200 
            /// SN: 01460000000000000000000000000000
            /// FW: 00.02.05 Apr 17 2012 05:40:11
            /// </summary>
            /// <param name="buffer">Buffer containing the break statement.</param>
            /// <returns>Return the values decoded from the buffer given.</returns>
            public static BreakStmt DecodeBREAK(string buffer)
            {
                string serial = "";
                string fw = "";
                string hw = "";
                Firmware firmware = new Firmware();

                // Check if the buffer given was empty
                if (string.IsNullOrEmpty(buffer))
                {
                    return new BreakStmt();
                }

                // Break up the lines
                char[] delimiters = new char[] { '\r', '\n' };
                string[] lines = buffer.Split(delimiters, StringSplitOptions.RemoveEmptyEntries);

                // Decode each line of data
                for (int x = 0; x < lines.Length; x++)
                {
                    // Change delimiter to a space
                    delimiters = new char[] { ' ' };
                    string[] elem = lines[x].Split(delimiters, StringSplitOptions.RemoveEmptyEntries);

                    // Firmware
                    if (lines[x].Contains("FW:"))
                    {
                        if (elem.Length >= 2)
                        {
                            fw = elem[1].Trim();

                            // Decode the firmware version
                            char[] fwDelimiters = new char[] { '.' };
                            string[] fwElem = fw.Split(fwDelimiters, StringSplitOptions.RemoveEmptyEntries);
                            if (fwElem.Length == 3)
                            {
                                ushort major = 0;
                                ushort minor = 0;
                                ushort revision = 0;
                                if (ushort.TryParse(fwElem[0], out major))
                                {
                                    firmware.FirmwareMajor = major;
                                }
                                if (ushort.TryParse(fwElem[1], out minor))
                                {
                                    firmware.FirmwareMinor = minor;
                                }
                                if (ushort.TryParse(fwElem[2], out revision))
                                {
                                    firmware.FirmwareRevision = revision;
                                }
                            }

                        }
                    }

                    // Serial number
                    if (lines[x].Contains("SN:"))
                    {
                        if (elem.Length >= 2)
                        {
                            serial = elem[1];
                        }
                    }

                    // Hardware
                    if (lines[x].Contains("DP") || lines[x].Contains("SC"))
                    {
                        hw = lines[x];
                    }
                }

                // Return the break statement values
                return new BreakStmt(){ SerialNum = new SerialNumber(serial), FirmwareVersion = firmware, Hardware = hw.Trim() };
            }
Exemple #40
0
            // Dataset ID
            /// <summary>
            /// Create a Ensemble data set.  This will create a blank dataset.  The user must fill in the data for all
            /// the important values.
            /// </summary>
            public EnsembleDataSet()
                : base(DataSet.Ensemble.DATATYPE_INT,                         // Type of data stored (Float or Int)
                            NUM_DATA_ELEMENTS,                              // Number of elements
                            DataSet.Ensemble.DEFAULT_NUM_BEAMS_NONBEAM,     // Element Multiplier
                            DataSet.Ensemble.DEFAULT_IMAG,                  // Default Image
                            DataSet.Ensemble.DEFAULT_NAME_LENGTH,           // Default Image length
                            DataSet.Ensemble.EnsembleDataID)
            {
                // Set the ensemble number to the default ensemble number
                EnsembleNumber = DEFAULT_ENS_NUM;

                // Set time to the current time
                SetTime();

                // Create UniqueId
                UniqueId = new UniqueID(EnsembleNumber, EnsDateTime);

                // Set the number of beams
                //NumBeams = numBeams;

                // Set the number of bins
                //NumBins = numElements;

                // Use a blank serial number
                SysSerialNumber = new SerialNumber();

                // Create blank firmware
                SysFirmware = new Firmware();

                // Create Blank Subsystem configuration
                SubsystemConfig = new SubsystemConfiguration();

                // Create a blank status
                Status = new Status(0);
            }
Exemple #41
0
            /// <summary>
            /// Create an Ensemble data set.  Include all the information
            /// about the current ensemble from the sentence.  This will include
            /// the ensemble number and status.
            /// </summary>
            /// <param name="sentence">Sentence containing data.</param>
            public EnsembleDataSet(Prti03Sentence sentence)
                : base(DataSet.Ensemble.DATATYPE_INT, NUM_DATA_ELEMENTS, DataSet.Ensemble.DEFAULT_NUM_BEAMS_NONBEAM, DataSet.Ensemble.DEFAULT_IMAG, DataSet.Ensemble.DEFAULT_NAME_LENGTH, DataSet.Ensemble.EnsembleDataID)
            {
                // Set the ensemble number
                EnsembleNumber = sentence.SampleNumber;

                // Set time to now
                SetTime();

                // Create UniqueId
                UniqueId = new UniqueID(EnsembleNumber, EnsDateTime);

                // Use default value for beams
                NumBeams = DataSet.Ensemble.DEFAULT_NUM_BEAMS_BEAM;

                // Use the special serial number for a DVL
                SysSerialNumber = SerialNumber.DVL;

                // Create blank firmware
                SysFirmware = new Firmware();

                // Create Subsystem Configuration based off Firmware and Serialnumber
                if (sentence.SubsystemConfig != null)
                {
                    SubsystemConfig = sentence.SubsystemConfig;
                    SysFirmware.SubsystemCode = sentence.SubsystemConfig.SubSystem.Code;
                }
                else
                {
                    // Create Subsystem Configuration based off Firmware and Serialnumber
                    SubsystemConfig = new SubsystemConfiguration(SysFirmware.GetSubsystem(SysSerialNumber), 0, 0);
                }

                // Get the status from the sentence
                Status = sentence.SystemStatus;

                // No bin data
                NumBins = 0;
            }
Exemple #42
0
            /// <summary>
            /// Get all the information about the Ensemble.
            /// </summary>
            /// <param name="data">Byte array containing the Ensemble data type.</param>
            private void Decode(byte[] data)
            {
                EnsembleNumber = MathHelper.ByteArrayToInt32(data, GenerateIndex(0));
                NumBins = MathHelper.ByteArrayToInt32(data, GenerateIndex(1));
                NumBeams = MathHelper.ByteArrayToInt32(data, GenerateIndex(2));
                DesiredPingCount = MathHelper.ByteArrayToInt32(data, GenerateIndex(3));
                ActualPingCount = MathHelper.ByteArrayToInt32(data, GenerateIndex(4));
                Status = new Status(MathHelper.ByteArrayToInt32(data, GenerateIndex(5)));
                Year = MathHelper.ByteArrayToInt32(data, GenerateIndex(6));
                Month = MathHelper.ByteArrayToInt32(data, GenerateIndex(7));
                Day = MathHelper.ByteArrayToInt32(data, GenerateIndex(8));
                Hour = MathHelper.ByteArrayToInt32(data, GenerateIndex(9));
                Minute = MathHelper.ByteArrayToInt32(data, GenerateIndex(10));
                Second = MathHelper.ByteArrayToInt32(data, GenerateIndex(11));
                HSec = MathHelper.ByteArrayToInt32(data, GenerateIndex(12));

                // Revision D additions
                if (NumElements >= NUM_DATA_ELEMENTS_REV_D && data.Length >= NUM_DATA_ELEMENTS_REV_D * Ensemble.BYTES_IN_INT32)
                {
                    // Get the System Serial Num
                    // Start at index 13
                    byte[] serial = new byte[SERIAL_NUM_INT * Ensemble.BYTES_IN_INT32];
                    System.Buffer.BlockCopy(data, GenerateIndex(13), serial, 0, SERIAL_NUM_INT * Ensemble.BYTES_IN_INT32);
                    SysSerialNumber = new SerialNumber(serial);

                    // Get the firmware number
                    // Start at index 21
                    byte[] firmware = new byte[FIRMWARE_NUM_INT * Ensemble.BYTES_IN_INT32];
                    System.Buffer.BlockCopy(data, GenerateIndex(21), firmware, 0, FIRMWARE_NUM_INT * Ensemble.BYTES_IN_INT32);
                    SysFirmware = new Firmware(firmware);

                    // FOR BACKWARDS COMPATITBILITY
                    // Old subsystems in the ensemble were set by the Subsystem Index in Firmware.
                    // This means the that a subsystem code of 0 could be passed because
                    // the index was 0 to designate the first subsystem index.  Firmware revision 0.2.13 changed
                    // SubsystemIndex to SubsystemCode.  This will check which Firmware version this ensemble is
                    // and convert to the new type using SubsystemCode.
                    //
                    // Get the correct subsystem by getting the index found in the firmware and getting
                    // subsystem code from the serial number.
                    //if (SysFirmware.FirmwareMajor <= 0 && SysFirmware.FirmwareMinor <= 2 && SysFirmware.FirmwareRevision <= 13 && GetSubSystem().IsEmpty())
                    //{
                    //    // Set the correct subsystem based off the serial number
                    //    // Get the index for the subsystem
                    //    byte index = SysFirmware.SubsystemCode;

                    //    // Ensure the index is not out of range of the subsystem string
                    //    if (SysSerialNumber.SubSystems.Length > index)
                    //    {
                    //        // Get the Subsystem code from the serialnumber based off the index found
                    //        string code = SysSerialNumber.SubSystems.Substring(index, 1);

                    //        // Create a subsystem with the code and index
                    //        Subsystem ss = new Subsystem(Convert.ToByte(code), index);

                    //        // Set the new subsystem code to the firmware
                    //        //SysFirmware.SubsystemCode = Convert.ToByte(code);

                    //        // Remove the old subsystem and add the new one to the dictionary
                    //        SysSerialNumber.SubSystemsDict.Remove(Convert.ToByte(index));
                    //        SysSerialNumber.SubSystemsDict.Add(Convert.ToByte(index), ss);

                    //    }
                    //}

                }
                else
                {
                    SysSerialNumber = new SerialNumber();
                    SysFirmware = new Firmware();

                }

                // Revision H additions
                if (NumElements >= NUM_DATA_ELEMENTS_REV_H && data.Length >= NUM_DATA_ELEMENTS_REV_H * Ensemble.BYTES_IN_INT32)
                {
                    // Get the Subsystem Configuration
                    // Start at index 22
                    byte[] subConfig = new byte[SUBSYSTEM_CONFIG_NUM_INT * Ensemble.BYTES_IN_INT32];
                    System.Buffer.BlockCopy(data, GenerateIndex(22), subConfig, 0, SUBSYSTEM_CONFIG_NUM_INT * Ensemble.BYTES_IN_INT32);
                    SubsystemConfig = new SubsystemConfiguration(SysFirmware.GetSubsystem(SysSerialNumber), subConfig);
                }
                else
                {
                    // Create a default SubsystemConfig with a configuration of 0
                    SubsystemConfig = new SubsystemConfiguration(SysFirmware.GetSubsystem(SysSerialNumber), 0, 0);
                }

                // Set the time and date
                ValidateDateTime(Year, Month, Day, Hour, Minute, Second, HSec / 10);

                // Create UniqueId
                UniqueId = new UniqueID(EnsembleNumber, EnsDateTime);
            }