private void cmdRead_Click(object sender, RoutedEventArgs e) { if (String.IsNullOrEmpty(cboDevice.Text) || String.IsNullOrEmpty(cboPrinterType.Text)) { MessageBox.Show("I need a Device and Printer Type before I can read."); return; } c = dm.ReadCartridge(cboDevice.Text, Machine.FromType(cboPrinterType.Text)); if (c == null) { return; } LoadControls(); }
public Cartridge ReadCartridge(string name, Machine machine) { Cartridge c = null; byte[] rom = null; byte[] flash = null; using (SerialPort sp = new SerialPort(ParseComPortName(devices.Where(d => d.Name.Equals(name)).Select(d => d.Name).First()), baudRate)) { sp.ReadTimeout = 3000; sp.Parity = Parity.None; sp.StopBits = StopBits.One; sp.DataBits = 8; sp.Handshake = Handshake.None; sp.DtrEnable = true; if (!sp.IsOpen) { sp.Open(); } WaitForChip(sp); rom = ReadROM(sp); flash = ReadFlash(sp); sp.Close(); } if (BitConverter.IsLittleEndian) { rom = rom.Reverse(); } SaveFlashToFile(rom, flash); c = new Cartridge(flash, machine, rom); return(c); }
public Cartridge ReadCartridge(string name, Machine machine, bool decrypt = true) { Cartridge c = null; byte[] rom = null; byte[] flash = null; using (SerialPort sp = new SerialPort(name, baudRate)) { sp.ReadTimeout = 3000; sp.Parity = Parity.None; sp.StopBits = StopBits.One; sp.DataBits = 8; sp.Handshake = Handshake.None; sp.DtrEnable = true; if (!sp.IsOpen) { sp.Open(); } WaitForChip(sp); rom = ReadROM(sp); flash = ReadFlash(sp); sp.Close(); } if (BitConverter.IsLittleEndian) { rom = rom.Reverse(); } //SaveFlashToFile(rom, flash); c = new Cartridge(flash, machine, rom, decrypt); return(c); }
public Cartridge ReadCartridge(Machine machine, string flashstring) { Cartridge c = null; { rom = ConvertHexStringToByteArray(clear_ID(flashstring)); flash = ConvertHexStringToByteArray(clear_code(flashstring)); } if (BitConverter.IsLittleEndian) { rom = rom.Reverse(); } if (Properties.Settings.Default.Save_to_File) { SaveFlashToFile(flashstring); } c = new Cartridge(flash, machine, rom); return(c); }
private void cmdRead_Click(object sender, RoutedEventArgs e) { if (String.IsNullOrEmpty(cboDevice.Text) || String.IsNullOrEmpty(cboPrinterType.Text)) { MessageBox.Show("I need a Device and Printer Type before I can read."); return; } c = dm.ReadCartridge(cboDevice.Text, Machine.FromType(cboPrinterType.Text)); if (c == null) return; LoadControls(); }
public Cartridge ReadCartridge(string name, Machine machine) { Cartridge c = null; byte[] rom = null; byte[] flash = null; using (SerialPort sp = new SerialPort(ParseComPortName(devices.Where(d => d.Name.Equals(name)).Select(d => d.Name).First()), baudRate)) { sp.ReadTimeout = 3000; sp.Parity = Parity.None; sp.StopBits = StopBits.One; sp.DataBits = 8; sp.Handshake = Handshake.None; sp.DtrEnable = true; if (!sp.IsOpen) sp.Open(); WaitForChip(sp); rom = ReadROM(sp); flash = ReadFlash(sp); sp.Close(); } if (BitConverter.IsLittleEndian) rom = rom.Reverse(); SaveFlashToFile(rom, flash); c = new Cartridge(flash, machine, rom); return c; }
public byte[] WriteCartridge(string name, Cartridge c) { byte[] result = null; using (SerialPort sp = new SerialPort(ParseComPortName(devices.Where(d => d.Name.Equals(name)).Select(d => d.Name).First()), baudRate)) { sp.ReadTimeout = 3000; sp.Parity = Parity.None; sp.StopBits = StopBits.One; sp.DataBits = 8; sp.Handshake = Handshake.None; sp.DtrEnable = true; if (!sp.IsOpen) sp.Open(); WaitForChip(sp); result = WriteFlash(sp, c.Encrypted); sp.Close(); } return result; }