public void WriteEEPROM(BootloaderClient endpoint, MemoryMap source) { Console.CursorVisible = false; Console.Write(" Writing EEPROM memory ({0}kB): ", source.Size / 1024); ConsoleProgressBar cpb = new ConsoleProgressBar(0, source.Size); for (uint addr = 0; addr < source.Size; addr += 128, cpb.Progress = addr) { byte[] payload = new byte[2 + 128]; payload[0] = (byte)(addr & 0xFF); payload[1] = (byte)((addr >> 8) & 0xFF); source.Read(addr, payload, 2, 128); Message msg_write = new Message(endpoint.BootloaderAddress, MessageType.WriteEepromPage, payload); Message response = SendAndWaitForResponse(endpoint, msg_write, 2000); if (response.Type != MessageType.WriteEepromPage) { throw new CnCException("response.Type"); } } Console.CursorVisible = true; Console.WriteLine("Done."); }
public void WriteFLASH(Device endpoint, MemoryMap source) { Console.CursorVisible = false; Console.Write("Writing FLASH memory ({0}kB): ", source.Size / 1024); ConsoleProgressBar cpb = new ConsoleProgressBar(0, source.Size); for (uint addr = 0; addr < source.Size; addr += 128, cpb.Progress = addr) { byte[] payload = new byte[2 + 128]; payload[0] = (byte)(addr & 0xFF); payload[1] = (byte)((addr >> 8) & 0xFF); source.Read(addr, payload, 2, 128); Message msg_write = new Message((byte)endpoint.address, MessageType.WriteFlashPage, payload); Message response = SendAndWaitForResponse(endpoint, msg_write, 2000); } Console.CursorVisible = true; Console.WriteLine("Done."); }