예제 #1
0
        private void HardwareController_DeviceRemoved(object sender, HardwareControllerEventArgs e)
        {
            if (_programmer == null)
            {
                return;
            }
            foreach (IChipProgrammer icp in e.ListOfDevices)
            {
                if (icp != _programmer)
                {
                    continue;
                }

                passwordSelectComboBox.Items.Clear();

                _programmer.Busy  -= BusyHandler;
                _programmer.Ready -= ReadyHandler;

                _programmer = null;
                SetNoProgrammerState();
                _programmersListIsRequested = true;
                _hardwareController.GetListOfDevicesInProgrammerMode(ProgrammersManagementProc);

                break;
            }
        }
예제 #2
0
        private void ProgrammersManagementProc(List <IChipProgrammer> progsList)
        {
            _programmersListIsRequested = false;
            if (_programmer != null)
            {
                return;
            }
            foreach (IChipProgrammer icp in progsList)
            {
                if (icp is IAT88Programmer)
                {
                    _programmer = icp as IAT88Programmer;

                    _programmer.Busy  += BusyHandler;
                    _programmer.Ready += ReadyHandler;

                    passwordSelectComboBox.Items.AddRange(_programmer.SupportedChips.ToArray());
                    passwordSelectComboBox.SelectedIndex = 0;
                    SetProgrammerReadyState();



                    return;
                }
            }
        }
예제 #3
0
        public void AT88Write(string subtype, string name, string serialnumtype, string templatefile)
        {
            if ((_programmer == null) || !(_programmer is IAT88Programmer))
            {
                SetAlarmText("Connect the compatible resetter");
                return;
            }
            IAT88Programmer prog = _programmer as IAT88Programmer;

            if (prog.IsBusy)
            {
                SetInfoText("Resetter is busy");
                return;
            }

            this.FormClosing += AutoForm_FormClosing;
            thisBusy          = true;

            List <MemoryRegion> regions = 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")
                {
                    thisBusy          = false;
                    this.FormClosing -= AutoForm_FormClosing;
                    SetOkText(pcInfo.Message);
                }
                else
                {
                    Action <FileWorkerIOCompleteInfo> writeComplete =
                        delegate(FileWorkerIOCompleteInfo fwiocInfo)
                    {
                        SetOkText(pcInfo.Message);
                        thisBusy          = false;
                        this.FormClosing -= AutoForm_FormClosing;
                    };

                    _dumpCoprrectors[serialnumtype](regions[0].Data);
                    _fileWorker.Write(templatefile, regions, writeComplete);
                }
            };

            Action <FileWorkerIOCompleteInfo> readFileComplete =
                delegate(FileWorkerIOCompleteInfo fwiocInfo)
            {
                if (fwiocInfo.Error != null)
                {
                    thisBusy          = false;
                    this.FormClosing -= AutoForm_FormClosing;
                    SetAlarmText(fwiocInfo.Error.Message);
                }
                else
                {
                    if (prog.IsBusy)
                    {
                        thisBusy          = false;
                        this.FormClosing -= AutoForm_FormClosing;
                        SetInfoText("Resetter is busy");
                        return;
                    }
                    regions = fwiocInfo.Regions;
                    prog.ProgramChip(subtype, fwiocInfo.Regions, programmComplete, Progress);
                }
            };
            MemoryRegionInfo regionInfo = new MemoryRegionInfo()
            {
                Address = 0, Size = 256, Type = 1
            };

            _fileWorker.Read(templatefile, new List <MemoryRegionInfo>()
            {
                regionInfo
            }, readFileComplete);
        }
예제 #4
0
        public void AT88Read(string subtype, string name)
        {
            if ((_programmer == null) || !(_programmer is IAT88Programmer))
            {
                SetAlarmText("Connect the compatible resetter");
                return;
            }
            IAT88Programmer prog = _programmer as IAT88Programmer;

            if (prog.IsBusy)
            {
                SetInfoText("Resetter is busy");
                return;
            }

            this.FormClosing += AutoForm_FormClosing;
            thisBusy          = true;

            MemoryRegionInfo regionInfo = new MemoryRegionInfo()
            {
                Address = 0, Size = 256, Type = 1
            };

            Action <ProgrammingCompleteInfo, List <MemoryRegion> > completed =
                delegate(ProgrammingCompleteInfo pcInfo, List <MemoryRegion> regions)
            {
                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 < regions[0].Size; i += 16)
                    {
                        byte[] data = new byte[16];
                        for (int j = 0; j < 16; j++)
                        {
                            data[j] = regions[0].Data[i + j] < (byte)0x20 ? (byte)0x2E : regions[0].Data[i + j];
                        }
                        strings.Add(enc.GetString(data));
                    }
                    if (regions.Count == 2)
                    {
                        strings.Add("");
                        strings.Add("Configuration data");
                        strings.Add("");
                        for (int i = 0; i < regions[1].Size; i += 16)
                        {
                            byte[] data = new byte[16];
                            for (int j = 0; j < 16; j++)
                            {
                                data[j] = regions[1].Data[i + j] < (byte)0x20 ? (byte)0x2E : regions[1].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
                {
                    try
                    {
                        SetAlarmText(_messages[pcInfo.error.Message]);
                    }
                    catch (KeyNotFoundException)
                    {
                        SetAlarmText(pcInfo.error.Message);
                    }
                }

                thisBusy          = false;
                this.FormClosing -= AutoForm_FormClosing;
            };

            prog.ReadChip(subtype, new List <MemoryRegionInfo>()
            {
                regionInfo
            }, completed, Progress);
        }