public DialogUnitSelect() { InitializeComponent(); base.Size = new Size(base.Size.Width, (int)(FormPICkit2.ScalefactH * (float)base.Size.Height)); ushort num = 0; while (num < 8) { Constants.PICkit2USB pICkit2USB = PICkitFunctions.DetectPICkit2Device(num, readFW: false); if (pICkit2USB != Constants.PICkit2USB.notFound) { string text = PICkitFunctions.GetSerialUnitID(); if (text == "PIC18F2550") { text = "<bootloader>"; } listBoxUnits.Items.Add(" " + num.ToString() + " " + text); num = (ushort)(num + 1); continue; } break; } }
// PICusb.FormPICusb private bool detectPICkit2(bool showFound, bool detectMult) { Constants.PICkit2USB pICkit2USB; if (detectMult) { //FormPICusb.pk2number = 0; pICkit2USB = PICkitFunctions.DetectPICkit2Device(0, false); if (pICkit2USB != Constants.PICkit2USB.notFound) { Constants.PICkit2USB pICkit2USB2 = PICkitFunctions.DetectPICkit2Device(1, false); if (pICkit2USB2 != Constants.PICkit2USB.notFound) { //DialogUnitSelect dialogUnitSelect = new DialogUnitSelect(); //dialogUnitSelect.ShowDialog(); } } } pICkit2USB = PICkitFunctions.DetectPICkit2Device(0, true); bool result; if (pICkit2USB == Constants.PICkit2USB.found) { //this.downloadPICkit2FirmwareToolStripMenuItem.Enabled = true; //this.chkBoxVddOn.Enabled = true; //if (!FormPICusb.selfPoweredTarget) //{ // this.numUpDnVDD.Enabled = true; //} //this.deviceToolStripMenuItem.Enabled = true; if (showFound) { string serialUnitID = PICkitFunctions.GetSerialUnitID(); if (serialUnitID[0] == '-') { //this.displayStatusWindow.Text = "DevBugger found and connected."; this.Text = "PICusb"; } else { if (serialUnitID == "DEVBUGV3") { //this.displayStatusWindow.Text = "DevBugger found and connected."; //this.Text = "PICusb"; } else { //this.displayStatusWindow.Text = "DevBugger connected."; //this.Text = "PICusb"; } } } result = true; } else { //this.downloadPICkit2FirmwareToolStripMenuItem.Enabled = false; //this.chkBoxVddOn.Enabled = false; //this.numUpDnVDD.Enabled = false; //this.deviceToolStripMenuItem.Enabled = false; //this.disableGUIControls(); if (pICkit2USB == Constants.PICkit2USB.firmwareInvalid) { //this.displayStatusWindow.BackColor = Color.Yellow; //this.downloadPICkit2FirmwareToolStripMenuItem.Enabled = true; //this.displayStatusWindow.Text = "The OS v" + PICkitFunctions.FirmwareVersion + " must be updated.\nUse the Tools menu to download a new OS."; //this.oldFirmware = true; result = false; } else { if (pICkit2USB == Constants.PICkit2USB.bootloader) { //this.displayStatusWindow.BackColor = Color.Yellow; //this.downloadPICkit2FirmwareToolStripMenuItem.Enabled = true; //this.displayStatusWindow.Text = "The programmer has no Operating System.\nUse the Tools menu to download an OS."; //this.bootLoad = true; result = false; } else { //this.displayStatusWindow.BackColor = Color.Salmon; //this.displayStatusWindow.Text = "DevBugger not found. Check USB connections and \nuse Tools->Check Communication to retry."; result = false; } } } return(result); }