Beispiel #1
0
        private void SaveConfigDataFileMenuItem_Click(object sender, EventArgs e)
        {
            saveFileDialog.Filter           = "hex files (*.hex)|*.hex|bin files (*.bin)|*.bin";
            saveFileDialog.FilterIndex      = 1;
            saveFileDialog.RestoreDirectory = false;
            saveFileDialog.FileName         = "";
            if (saveFileDialog.ShowDialog() != DialogResult.OK)
            {
                return;
            }
            MemoryRegion region = new MemoryRegion(0x100, 256, 0);

            region.WriteData(0x100, _configDataBytes.GetBytes());
            List <MemoryRegion> regions = new List <MemoryRegion>()
            {
                region
            };
            Action <FileWorkerIOCompleteInfo> complete =
                delegate(FileWorkerIOCompleteInfo info)
            {
                if (info.Error != null)
                {
                    infoPanel.SetErrorState(info.Error.Message);
                }
            };

            file.Write(saveFileDialog.FileName, regions, complete);
        }
Beispiel #2
0
        private void writeChipStripButton_Click(object sender, EventArgs e)
        {
            this.FormClosing += CRUM921Form_FormClosing;
            if (_programmer.IsBusy || (_programmer == null))
            {
                return;
            }

            Action <ProgrammingCompleteInfo> complete =
                delegate(ProgrammingCompleteInfo pcInfo)
            {
                if (pcInfo.error != null)
                {
                    infoPanel.SetErrorState(pcInfo.error.Message);
                }
                else
                {
                    infoPanel.SetOkState(pcInfo.Message);
                }

                this.FormClosing -= CRUM921Form_FormClosing;
            };



            infoPanel.SetInfoState("Starting process");
            MemoryRegion region = new MemoryRegion(0, 384, 1);

            region.WriteData(0, _dataBytes.GetBytes());
            _programmer.ProgramChip("Mode 0", region, complete, infoPanel.GetProgressDelegate());
        }
Beispiel #3
0
        private void saveFile_Btn_Click(object sender, EventArgs e)
        {
            saveFileDialog.Filter           = "hex files (*.hex)|*.hex|bin files (*.bin)|*.bin";
            saveFileDialog.FilterIndex      = 1;
            saveFileDialog.RestoreDirectory = false;
            saveFileDialog.FileName         = "";

            if (saveFileDialog.ShowDialog() != DialogResult.OK)
            {
                return;
            }

            MemoryRegion region = new MemoryRegion(0, 8, 0);

            region.WriteData(0, ((DynamicByteProvider)(rw1990_HexBox.ByteProvider)).Bytes.ToArray());
            List <MemoryRegion> regions = new List <MemoryRegion>()
            {
                region
            };

            Action <FileWorkerIOCompleteInfo> complete =
                delegate(FileWorkerIOCompleteInfo info)
            {
                if (info.Error == null)
                {
                    Text = "M24CXX DUMP " + saveFileDialog.FileName;
                }
                else
                {
                    infoPanel.SetErrorState(info.Error.Message);
                }
            };

            file.Write(saveFileDialog.FileName, regions, complete);
        }
Beispiel #4
0
        private void writeCrumButton_Click(object sender, EventArgs e)
        {
            this.FormClosing += AT88DumpForm_FormClosing;
            if (_programmer.IsBusy || (_programmer == null))
            {
                return;
            }

            MemoryRegion udr = new MemoryRegion(0, 256, 1);

            udr.WriteData(0, _userDataBytes.GetBytes());
            List <MemoryRegion> regions = new List <MemoryRegion> {
                udr
            };

            Action <ProgrammingCompleteInfo> complete =
                delegate(ProgrammingCompleteInfo pcInfo)
            {
                if (pcInfo.error != null)
                {
                    if (pcInfo.error is VerificationException)
                    {
                        VerificationException ve = pcInfo.error as VerificationException;
                        infoPanel.SetErrorState(
                            "Verification error. At address: " + ve.ErrorAddress.ToString("X")
                            + " write: " + ve.WrittenByte.ToString("X")
                            + " read: " + ve.ReadByte.ToString("X"));
                    }
                    else
                    {
                        infoPanel.SetErrorState(pcInfo.error.Message);
                    }
                }
                else
                {
                    infoPanel.SetOkState("Write complete");
                }

                this.FormClosing -= AT88DumpForm_FormClosing;
            };



            infoPanel.SetProgressState("Writing");
            _programmer.ProgramChip(passwordSelectComboBox.SelectedItem.ToString(), regions, complete, infoPanel.GetProgressDelegate());
        }
        private void writeChipStripButton_Click(object sender, EventArgs e)
        {
            this.FormClosing += Xerox0190Form_FormClosing;
            if (_programmer.IsBusy || (_programmer == null))
            {
                return;
            }

            Action <ProgrammingCompleteInfo> complete =
                delegate(ProgrammingCompleteInfo pcInfo)
            {
                if (pcInfo.error != null)
                {
                    if (pcInfo.error is VerificationException)
                    {
                        VerificationException ve = pcInfo.error as VerificationException;
                        infoPanel.SetErrorState(
                            "Verification error. At address: " + ve.ErrorAddress.ToString("X")
                            + " write: " + ve.WrittenByte.ToString("X")
                            + " read: " + ve.ReadByte.ToString("X"));
                    }
                    else
                    {
                        infoPanel.SetErrorState(pcInfo.error.Message);
                    }
                }
                else
                {
                    infoPanel.SetOkState("Write complete");
                }

                this.FormClosing -= Xerox0190Form_FormClosing;
            };



            infoPanel.SetProgressState("Writing");
            MemoryRegion region = new MemoryRegion(0, 256, 1);

            region.WriteData(0, _dataBytes.GetBytes());
            _programmer.ProgramChip("Mode 0", region, complete, infoPanel.GetProgressDelegate());
        }
Beispiel #6
0
        void IUSBPacketsFactory.AddRxPacket(byte[] packet)
        {
            if (packet[8] != 0)
            {
                throw new Exception("I2C read error " + packet[8].ToString("X2"));
            }

            uint address = 0;

            if (addressSize == 2)
            {
                address = (((uint)(packet[5] & (byte)0x0E)) << 7) | (uint)packet[6];
            }
            else
            {
                address = (((uint)(packet[5] & (byte)0x0E)) << 15) | ((uint)packet[6] << 8) | (uint)packet[7];
            }

            byte[] packData = new byte[packet[9]];
            Array.Copy(packet, 17, packData, 0, packet[9]);
            region.WriteData(address, packData);
        }
        private void saveFileMenuItem_Click(object sender, EventArgs e)
        {
            saveFileDialog.Filter           = "hex files (*.hex)|*.hex|bin files (*.bin)|*.bin";
            saveFileDialog.FilterIndex      = 1;
            saveFileDialog.RestoreDirectory = false;
            saveFileDialog.FileName         = "";

            if (saveFileDialog.ShowDialog() != DialogResult.OK)
            {
                return;
            }

            MemoryRegion region = new MemoryRegion(0, 256, 0);

            region.WriteData(0, _dataBytes.GetBytes());
            List <MemoryRegion> regions = new List <MemoryRegion>()
            {
                region
            };

            Action <FileWorkerIOCompleteInfo> complete =
                delegate(FileWorkerIOCompleteInfo info)
            {
                if (info.Error == null)
                {
                    Text = "XEROX 01/90 DUMP " + saveFileDialog.FileName;
                    hexBox.ByteProvider.Changed += HexBoxChanged;
                }
                else
                {
                    infoPanel.SetErrorState(info.Error.Message);
                }
            };

            file.Write(saveFileDialog.FileName, regions, complete);
        }
Beispiel #8
0
        private void saveFileButton_Click(object sender, EventArgs e)
        {
            saveFileDialog.Filter           = "hex files (*.hex)|*.hex|bin files (*.bin)|*.bin";
            saveFileDialog.FilterIndex      = 1;
            saveFileDialog.RestoreDirectory = false;
            saveFileDialog.FileName         = "";

            if (saveFileDialog.ShowDialog() != DialogResult.OK)
            {
                return;
            }

            MemoryRegion region = new MemoryRegion(0, 6, 0);

            region.WriteData(0, ((DynamicByteProvider)(hexBox.ByteProvider)).Bytes.ToArray());
            byte setting = 0x00;

            if (manchesterRadioButton.Checked)
            {
                setting |= 0x10;
            }
            else if (biphaseRadioButton.Checked)
            {
                setting |= 0x20;
            }

            if (rf16datarateRadioButton.Checked)
            {
                setting |= 0x01;
            }
            else if (rf32datarateRadioButton.Checked)
            {
                setting |= 0x02;
            }
            else if (rf64datarateRadioButton.Checked)
            {
                setting = 0x03;
            }

            region.Data[5] = setting;

            List <MemoryRegion> regions = new List <MemoryRegion>()
            {
                region
            };

            Action <FileWorkerIOCompleteInfo> complete =
                delegate(FileWorkerIOCompleteInfo info)
            {
                if (info.Error == null)
                {
                    Text = "EM4100 DUMP " + saveFileDialog.FileName;
                }
                else
                {
                    infoPanel.SetErrorState(info.Error.Message);
                }
            };

            file.Write(saveFileDialog.FileName, regions, complete);
        }
Beispiel #9
0
        int IM24CXXProgrammer.ProgramChip(string chip, MemoryRegion region, Action <ProgrammingCompleteInfo> completed, Action <ProgrammingProgressInfo> progress)
        {
            _isBusy = true;
            AsyncOperation asyncOp = AsyncOperationManager.CreateOperation(new Guid());

            if (chip == "24C02")
            {
                byte[] regdata = new byte[256];
                region.ReadData(0, regdata);
                region = new MemoryRegion(0, 512, 1);
                region.WriteData(0, regdata);
            }


            Action <int, int> progressAct = delegate(int val, int max)
            {
                asyncOp.Post(delegate(object args) { progress(new ProgrammingProgressInfo(new ProgressBarData(0, val, max))); }, null);
            };

            ThreadStart start = delegate()
            {
                asyncOp.Post(delegate(object args) { OnBusy(); }, null);

                ProgrammingCompleteInfo pcInfo = new ProgrammingCompleteInfo();

                try
                {
                    SafeFileHandle handle = CreateFile(_hardwarePath, Win32HardwareIOSupport.GENERIC_WRITE | Win32HardwareIOSupport.GENERIC_READ,
                                                       Win32HardwareIOSupport.FILE_SHARE_WRITE | Win32HardwareIOSupport.FILE_SHARE_READ, IntPtr.Zero, Win32HardwareIOSupport.OPEN_EXISTING, 0, IntPtr.Zero);

                    if (handle.IsInvalid)
                    {
                        Marshal.ThrowExceptionForHR(Marshal.GetHRForLastWin32Error());
                    }

                    using (FileStream harwareStream = new FileStream(handle, FileAccess.ReadWrite, 65))
                    {
                        SetTaskNumber(harwareStream, _m24CXXChipSet[chip]);

                        UpdateCurrentMemRegConfig(harwareStream);

                        if ((_currentMemoryRegionsConfig.Count != 1) || (_currentMemoryRegionsConfig[0] != region.GetRegionInfo()))
                        {
                            Exception e1      = Marshal.GetExceptionForHR((int)((Convert.ToUInt32(4319) | 0x80070000)));
                            Exception e2      = Marshal.GetExceptionForHR((int)((Convert.ToUInt32(1784) | 0x80070000)));
                            string    message = e1.Message.Substring(0, e1.Message.IndexOf("(")) +
                                                e2.Message.Substring(0, e2.Message.IndexOf("("));
                            throw new Exception(message);
                        }


                        asyncOp.Post(delegate(object args) { progress(new ProgrammingProgressInfo("Programming")); }, null);

                        ProgramRegion(harwareStream, region, progressAct);

                        MemoryRegion testRegion = new MemoryRegion(_currentMemoryRegionsConfig[0]);

                        asyncOp.Post(delegate(object args) { progress(new ProgrammingProgressInfo("Verification")); }, null);
                        asyncOp.Post(delegate(object args) { progress(new ProgrammingProgressInfo(new ProgressBarData(0, 0, 1))); }, null);

                        ReadRegion(harwareStream, testRegion, progressAct);

                        for (int i = 0; i < region.Size; i++)
                        {
                            if (region.Data[i] != testRegion.Data[i])
                            {
                                throw new VerificationException(region.Address + (uint)i, region.Data[i], testRegion.Data[i]);
                            }
                        }
                    }
                }
                catch (VerificationException ve)
                {
                    if ((chip == "24C02") && (ve.ErrorAddress >= 256))
                    {
                    }
                    else
                    {
                        pcInfo.error = ve;
                    }
                }
                catch (Exception e)
                {
                    pcInfo.error = e;
                }
                pcInfo.Message = "Programming complete";
                asyncOp.Post(delegate(object args) { completed(pcInfo); }, null);
                _isBusy = false;
                asyncOp.PostOperationCompleted(delegate(object args) { OnReady(); }, null);
            };

            (new Thread(start)).Start();

            return(0);
        }
        int IRFIDProgrammer.Adjust(Action <ProgrammingCompleteInfo, MemoryRegion> completed, Action <ProgrammingProgressInfo> progress)
        {
            _isBusy = true;



            AsyncOperation asyncOp = AsyncOperationManager.CreateOperation(new Guid());

            Action <int, int> progressAct = delegate(int val, int max)
            {
                asyncOp.Post(delegate(object args) { progress(new ProgrammingProgressInfo(new ProgressBarData(0, val, max))); }, null);
            };

            ThreadStart start = delegate()
            {
                asyncOp.Post(delegate(object args) { OnBusy(); }, null);
                ProgrammingCompleteInfo pcInfo = new ProgrammingCompleteInfo();
                MemoryRegion            region = new MemoryRegion(0, 256, 0);


                try
                {
                    SafeFileHandle WriteHandle = CreateFile(_hardwarePath, Win32HardwareIOSupport.GENERIC_WRITE,
                                                            Win32HardwareIOSupport.FILE_SHARE_WRITE | Win32HardwareIOSupport.FILE_SHARE_READ, IntPtr.Zero, Win32HardwareIOSupport.OPEN_EXISTING, 0, IntPtr.Zero);

                    if (WriteHandle.IsInvalid)
                    {
                        Marshal.ThrowExceptionForHR(Marshal.GetHRForLastWin32Error());
                    }
                    SafeFileHandle ReadHandle = CreateFile(_hardwarePath, Win32HardwareIOSupport.GENERIC_READ,
                                                           Win32HardwareIOSupport.FILE_SHARE_WRITE | Win32HardwareIOSupport.FILE_SHARE_READ, IntPtr.Zero, Win32HardwareIOSupport.OPEN_EXISTING, 0, IntPtr.Zero);

                    if (ReadHandle.IsInvalid)
                    {
                        Marshal.ThrowExceptionForHR(Marshal.GetHRForLastWin32Error());
                    }

                    uint wrBytes;

                    byte[] request = new byte[65];

                    byte[] response = new byte[65];

                    byte maxTime = 0;
                    byte minTime = 0xFF;

                    for (int i = 0; i < 20; i++)
                    {
                        request[1] = Constants.RFID125_TEST;


                        if (!WriteFile(WriteHandle, request, 65, out wrBytes, IntPtr.Zero))
                        {
                            Marshal.ThrowExceptionForHR(Marshal.GetHRForLastWin32Error());
                        }

                        if (!ReadFile(ReadHandle, response, 65, out wrBytes, IntPtr.Zero))
                        {
                            Marshal.ThrowExceptionForHR(Marshal.GetHRForLastWin32Error());
                        }

                        if (response[3] > maxTime)
                        {
                            maxTime = response[3];
                        }
                        if (response[3] < minTime)
                        {
                            minTime = response[3];
                        }

                        progressAct(i, 20);
                    }

                    response[3] = maxTime;
                    response[4] = minTime;

                    region.WriteData(0, response);
                }
                catch (Exception e)
                {
                    pcInfo.error = e;
                }
                pcInfo.Message = "Complete";
                asyncOp.Post(delegate(object args) { progress(new ProgrammingProgressInfo(new ProgressBarData(0, 0, 1))); }, null);

                asyncOp.Post(delegate(object args) { completed(pcInfo, region); }, null);
                _isBusy = false;
                asyncOp.PostOperationCompleted(delegate(object args) { OnReady(); }, null);
            };

            (new Thread(start)).Start();

            return(0);
        }
        int IOneWireProgrammer.ExecuteCommandSet(List <byte[]> request, Action <ProgrammingCompleteInfo, MemoryRegion> completed, Action <ProgrammingProgressInfo> progress)
        {
            _isBusy = true;


            AsyncOperation asyncOp = AsyncOperationManager.CreateOperation(new Guid());

            Action <int, int> progressAct = delegate(int val, int max)
            {
                asyncOp.Post(delegate(object args) { progress(new ProgrammingProgressInfo(new ProgressBarData(0, val, max))); }, null);
            };

            ThreadStart start = delegate()
            {
                asyncOp.Post(delegate(object args) { OnBusy(); }, null);
                ProgrammingCompleteInfo pcInfo = new ProgrammingCompleteInfo();
                MemoryRegion            region = new MemoryRegion(0, (uint)(65 * request.Count), 0);


                try
                {
                    SafeFileHandle WriteHandle = CreateFile(_hardwarePath, Win32HardwareIOSupport.GENERIC_WRITE,
                                                            Win32HardwareIOSupport.FILE_SHARE_WRITE | Win32HardwareIOSupport.FILE_SHARE_READ, IntPtr.Zero, Win32HardwareIOSupport.OPEN_EXISTING, 0, IntPtr.Zero);

                    if (WriteHandle.IsInvalid)
                    {
                        Marshal.ThrowExceptionForHR(Marshal.GetHRForLastWin32Error());
                    }
                    SafeFileHandle ReadHandle = CreateFile(_hardwarePath, Win32HardwareIOSupport.GENERIC_READ,
                                                           Win32HardwareIOSupport.FILE_SHARE_WRITE | Win32HardwareIOSupport.FILE_SHARE_READ, IntPtr.Zero, Win32HardwareIOSupport.OPEN_EXISTING, 0, IntPtr.Zero);

                    if (ReadHandle.IsInvalid)
                    {
                        Marshal.ThrowExceptionForHR(Marshal.GetHRForLastWin32Error());
                    }

                    uint wrBytes;

                    List <byte> respdata = new List <byte>();

                    int curreq = 0;

                    foreach (byte[] data in request)
                    {
                        if (!WriteFile(WriteHandle, data, 65, out wrBytes, IntPtr.Zero))
                        {
                            Marshal.ThrowExceptionForHR(Marshal.GetHRForLastWin32Error());
                        }

                        byte[] resp = new byte[65];


                        if (!ReadFile(ReadHandle, resp, 65, out wrBytes, IntPtr.Zero))
                        {
                            Marshal.ThrowExceptionForHR(Marshal.GetHRForLastWin32Error());
                        }

                        if (resp[1] != 0)
                        {
                            throw new Exception("ONEWIRE ERROR :" + resp[1].ToString("X2"));
                        }


                        progressAct(100 * ++curreq / request.Count, 100);

                        respdata.AddRange(resp);
                    }
                    region.WriteData(0, respdata.ToArray());
                }
                catch (Exception e)
                {
                    pcInfo.error = e;
                }
                pcInfo.Message = "Complete";
                asyncOp.Post(delegate(object args) { progress(new ProgrammingProgressInfo(new ProgressBarData(0, 0, 1))); }, null);

                asyncOp.Post(delegate(object args) { completed(pcInfo, region); }, null);
                _isBusy = false;
                asyncOp.PostOperationCompleted(delegate(object args) { OnReady(); }, null);
            };

            (new Thread(start)).Start();

            return(0);
        }
        int IOneWireProgrammer.ExecuteCommandSet(byte[] request, Action <ProgrammingCompleteInfo, MemoryRegion> completed, Action <ProgrammingProgressInfo> progress)
        {
            _isBusy = true;


            AsyncOperation asyncOp = AsyncOperationManager.CreateOperation(new Guid());

            Action <int, int> progressAct = delegate(int val, int max)
            {
                asyncOp.Post(delegate(object args) { progress(new ProgrammingProgressInfo(new ProgressBarData(0, val, max))); }, null);
            };

            ThreadStart start = delegate()
            {
                asyncOp.Post(delegate(object args) { OnBusy(); }, null);
                ProgrammingCompleteInfo pcInfo = new ProgrammingCompleteInfo();
                MemoryRegion            region = new MemoryRegion(0, 256, 0);


                try
                {
                    SafeFileHandle WriteHandle = CreateFile(_hardwarePath, Win32HardwareIOSupport.GENERIC_WRITE,
                                                            Win32HardwareIOSupport.FILE_SHARE_WRITE | Win32HardwareIOSupport.FILE_SHARE_READ, IntPtr.Zero, Win32HardwareIOSupport.OPEN_EXISTING, 0, IntPtr.Zero);

                    if (WriteHandle.IsInvalid)
                    {
                        Marshal.ThrowExceptionForHR(Marshal.GetHRForLastWin32Error());
                    }
                    SafeFileHandle ReadHandle = CreateFile(_hardwarePath, Win32HardwareIOSupport.GENERIC_READ,
                                                           Win32HardwareIOSupport.FILE_SHARE_WRITE | Win32HardwareIOSupport.FILE_SHARE_READ, IntPtr.Zero, Win32HardwareIOSupport.OPEN_EXISTING, 0, IntPtr.Zero);

                    if (ReadHandle.IsInvalid)
                    {
                        Marshal.ThrowExceptionForHR(Marshal.GetHRForLastWin32Error());
                    }

                    uint wrBytes;



                    if (!WriteFile(WriteHandle, request, 65, out wrBytes, IntPtr.Zero))
                    {
                        Marshal.ThrowExceptionForHR(Marshal.GetHRForLastWin32Error());
                    }

                    byte[] respdata = new byte[65];


                    if (!ReadFile(ReadHandle, respdata, 65, out wrBytes, IntPtr.Zero))
                    {
                        Marshal.ThrowExceptionForHR(Marshal.GetHRForLastWin32Error());
                    }


                    region.WriteData(0, respdata);
                }
                catch (Exception e)
                {
                    pcInfo.error = e;
                }
                pcInfo.Message = "Complete";
                asyncOp.Post(delegate(object args) { progress(new ProgrammingProgressInfo(new ProgressBarData(0, 0, 1))); }, null);

                asyncOp.Post(delegate(object args) { completed(pcInfo, region); }, null);
                _isBusy = false;
                asyncOp.PostOperationCompleted(delegate(object args) { OnReady(); }, null);
            };

            (new Thread(start)).Start();

            return(0);
        }