示例#1
0
        private CaesarContainer PickContainer()
        {
            if (Containers.Count == 0)
            {
                MessageBox.Show("No containers have been loaded yet.");
                return(null);
            }
            CaesarContainer targetContainer = Containers[0];

            if (Containers.Count > 1)
            {
                // there isn't an embedded qualifier to identify containers easily; the ecu name is probably an easier name to identify with
                List <string[]> table = new List <string[]>();
                foreach (CaesarContainer container in Containers)
                {
                    if (container.CaesarECUs.Count > 0)
                    {
                        table.Add(new string[] { container.CaesarECUs[0].Qualifier });
                    }
                }
                GenericPicker picker = new GenericPicker(table.ToArray(), new string[] { "Container" }, 0);
                picker.Text = "Please select a container";
                if (picker.ShowDialog() != DialogResult.OK)
                {
                    return(null);
                }
                string selectedEcuQualifier = picker.SelectedResult[0];
                targetContainer = Containers.Find(x => ((x.CaesarECUs.Count > 0) && (x.CaesarECUs[0].Qualifier == selectedEcuQualifier)));
            }
            return(targetContainer);
        }
示例#2
0
        public static void ShowMetadataModal(ECUConnection connection)
        {
            if (connection.ConnectionProtocol is null)
            {
                Console.WriteLine("Please initiate contact with a target first.");
                return;
            }
            ECUMetadata metadata = connection.ConnectionProtocol.QueryECUMetadata(connection);

            string[][] rows = new string[][]
            {
                new string[] { "Variant ID", metadata.VariantID.ToString("X4") },
                new string[] { "Gateway Mode", metadata.GatewayMode.ToString() },
                new string[] { "Boot Version", metadata.BootVersion },
                new string[] { "Serial Number", metadata.SerialNumber },
                new string[] { "Chassis Number (Current)", metadata.ChassisNumberCurrent },
                new string[] { "Chassis Number (Original)", metadata.ChassisNumberOriginal },
                new string[] { "Hardware Part Number", metadata.HardwarePartNumber },
                new string[] { "Hardware Version", metadata.HardwareVersion },
                new string[] { "Hardware Supplier", ECUMetadata.GetVendorName(metadata.VendorID) },
            };

            List <string[]> rowsAsList = new List <string[]>(rows);

            foreach (ECUFlashMetadata flash in metadata.FlashMetadata)
            {
                string blockPrefix = $"SW Block #{flash.Index} : ";
                string flashStatus = flash.StatusID == 1 ? "Valid" : "Invalid";

                rowsAsList.Add(new string[] { $"{blockPrefix}Descriptor", $"{flash.PartNumber} [Version {flash.Version} from {ECUMetadata.GetVendorName(flash.VendorID)}]" });
                rowsAsList.Add(new string[] { $"{blockPrefix}Status", $"{flashStatus}, Last flashed by {ECUMetadata.GetVendorName(flash.LastFlashVendor)} on {flash.FlashDate} (Fingerprint: {flash.FlashFingerprint})" });
            }

            GenericPicker picker = new GenericPicker(rowsAsList.ToArray(), new string[] { "Attribute", "Value" });

            picker.Text = "ECU Metadata";
            picker.ShowDialog();
        }