private void HardwareController_DeviceRemoved(object sender, HardwareControllerEventArgs e) { if (_programmer == null) { return; } foreach (IChipProgrammer icp in e.ListOfDevices) { if (icp != _programmer) { continue; } _programmer.Busy -= BusyHandler; _programmer.Ready -= ReadyHandler; _programmer = null; SetNoProgrammerState(); _programmersListIsRequested = true; _hardwareController.GetListOfDevicesInProgrammerMode(ProgrammersManagementProc); UpdateComboBox(s02512.Keys.ToArray()); break; } }
private void ProgrammersManagementProc(List <IChipProgrammer> progsList) { _programmersListIsRequested = false; if (_programmer != null) { return; } foreach (IChipProgrammer icp in progsList) { if (icp is IM24CXXProgrammer) { _programmer = icp as IM24CXXProgrammer; _programmer.Busy += BusyHandler; _programmer.Ready += ReadyHandler; UpdateComboBox(_programmer.SupportedChips.ToArray()); SetProgrammerReadyState(); return; } } }
private void M24CXXWrite(string subtype, string name, string serialnumtype, string templatefile) { if ((_programmer == null) || !(_programmer is IM24CXXProgrammer)) { SetAlarmText("Connect the compatible resetter"); return; } IM24CXXProgrammer prog = _programmer as IM24CXXProgrammer; if (prog.IsBusy) { SetInfoText("Resetter is busy"); return; } this.FormClosing += AutoForm_FormClosing; thisBusy = true; MemoryRegion region = null; Action <ProgrammingCompleteInfo> programmComplete = delegate(ProgrammingCompleteInfo pcInfo) { progressBar.Value = progressBar.Minimum; if (pcInfo.error != null) { if (pcInfo.error is VerificationException) { VerificationException ve = pcInfo.error as VerificationException; SetAlarmText( "Verification error At address: " + ve.ErrorAddress.ToString() + " write: " + ve.WrittenByte.ToString() + " read: " + ve.ReadByte.ToString()); } else { SetAlarmText(pcInfo.error.Message); } thisBusy = false; this.FormClosing -= AutoForm_FormClosing; } else if (serialnumtype == "No") { SetOkText(pcInfo.Message); thisBusy = false; this.FormClosing -= AutoForm_FormClosing; } else { Action <FileWorkerIOCompleteInfo> writeComplete = delegate(FileWorkerIOCompleteInfo fwiocInfo) { if (fwiocInfo.Error != null) { SetAlarmText(fwiocInfo.Error.Message); } else { SetOkText(pcInfo.Message); } thisBusy = false; this.FormClosing -= AutoForm_FormClosing; }; _dumpCoprrectors[serialnumtype](region.Data); _fileWorker.Write(templatefile, new List <MemoryRegion>() { region }, writeComplete); } }; Action <FileWorkerIOCompleteInfo> readFileComplete = delegate(FileWorkerIOCompleteInfo fwiocInfo) { if (fwiocInfo.Error != null) { SetAlarmText(fwiocInfo.Error.Message); thisBusy = false; this.FormClosing -= AutoForm_FormClosing; } else { if (prog.IsBusy) { SetInfoText("Resetter is busy"); thisBusy = false; this.FormClosing -= AutoForm_FormClosing; return; } region = fwiocInfo.Regions[0]; prog.ProgramChip(subtype, fwiocInfo.Regions[0], programmComplete, Progress); } }; MemoryRegionInfo regionInfo = new MemoryRegionInfo() { Address = 0, Size = 0, Type = 1 }; regionInfo.Size = (uint)s02512[subtype]; _fileWorker.Read(templatefile, new List <MemoryRegionInfo>() { regionInfo }, readFileComplete); }
private void M24CXXRead(string subtype, string name) { if ((_programmer == null) || !(_programmer is IM24CXXProgrammer)) { SetAlarmText("Connect the compatible resetter"); return; } IM24CXXProgrammer prog = _programmer as IM24CXXProgrammer; if (prog.IsBusy) { SetInfoText("Resetter is busy"); return; } this.FormClosing += AutoForm_FormClosing; thisBusy = true; MemoryRegionInfo regionInfo = new MemoryRegionInfo(); regionInfo.Address = 0; regionInfo.Type = 1; regionInfo.Size = (uint)s02512[subtype]; Action <ProgrammingCompleteInfo, MemoryRegion> completed = delegate(ProgrammingCompleteInfo pcInfo, MemoryRegion region) { progressBar.Value = progressBar.Minimum; if (pcInfo.error == null) { Encoding enc = Encoding.GetEncoding(1251); TextBox textBox = new TextBox(); textBox.Multiline = true; textBox.ReadOnly = true; textBox.BackColor = Color.WhiteSmoke; textBox.ScrollBars = ScrollBars.Vertical; textBox.Size = new Size(150, 100); List <string> strings = new List <string>(); for (int i = 0; i < region.Size; i += 16) { byte[] data = new byte[16]; for (int j = 0; j < 16; j++) { data[j] = region.Data[i + j] < (byte)0x20 ? (byte)0x2E : region.Data[i + j]; } strings.Add(enc.GetString(data)); } textBox.Lines = strings.ToArray(); infoLayoutPanel.Controls.Add(textBox); infoLayoutPanel.Controls.SetChildIndex(textBox, 0); SetOkText("Read OK"); } else { SetAlarmText(pcInfo.error.Message); } thisBusy = false; this.FormClosing -= AutoForm_FormClosing; }; prog.ReadChip(subtype, regionInfo, completed, Progress); }