static void ReadAndVerifyEEPROMPage(int numberOfPageToRead) { Console.Clear(); var totalErrorCount = 0; var t = Stopwatch.StartNew(); //byte [] buf; ///+++ for (var pageIndex = 0; pageIndex < numberOfPageToRead; pageIndex++) { if (pageIndex % 50 == 0 || pageIndex < 5) { Console.WriteLine("Reading page {0}", pageIndex); } var r = _eeprom.ReadPage(pageIndex * _eeprom.PAGE_SIZE, _eeprom.PAGE_SIZE); if (r.Succeeded) { EEPROM_24LC256.VerifyPage(r, pageIndex); } else { Console.WriteLine("ReadBuffer failure"); } } t.Stop(); Console.WriteLine("{0} error(s), Time:{1}, {2:0.00} kb/s", totalErrorCount, t.ElapsedMilliseconds, _eeprom.MaxByte * 1.0 / t.ElapsedMilliseconds ); Console.WriteLine("Hit enter key"); Console.ReadLine(); }
static void ReadAndVerifyEEPROMPageInBatch(int numberOfPageToRead) { Console.Clear(); var totalErrorCount = 0; var t = Stopwatch.StartNew(); var batchSize = 64; var pageIndex = 0; byte[] buf; for (var batchIndex = 0; batchIndex < numberOfPageToRead; batchIndex += batchSize) { Console.WriteLine("Reading page {0}", batchIndex); var r = _eeprom.ReadPage(batchIndex * _eeprom.PAGE_SIZE, _eeprom.PAGE_SIZE * batchSize); if (r.Succeeded) { for (var b = 0; b < batchSize; b++) { buf = r.GetPage(b, _eeprom.PAGE_SIZE); var tmpBuf = new EEPROM_BUFFER { Buffer = buf }; EEPROM_24LC256.VerifyPage(tmpBuf, pageIndex); pageIndex += 1; } } else { Console.WriteLine("ReadBuffer failure"); } } t.Stop(); Console.WriteLine("{0} error(s), Time:{1}, {2:0.00} kb/s", totalErrorCount, t.ElapsedMilliseconds, _eeprom.MaxByte * 1.0 / t.ElapsedMilliseconds ); Console.WriteLine("Hit enter key"); Console.ReadLine(); }
public static void Run(string[] args) { Console.WriteLine("Nusbio initialization"); var serialNumber = Nusbio.Detect(); if (serialNumber == null) // Detect the first Nusbio available { Console.WriteLine("nusbio not detected"); return; } var clockPin = NusbioGpio.Gpio0; var dataPin = NusbioGpio.Gpio1; using (var nusbio = new Nusbio(serialNumber)) { Cls(nusbio); var mask = nusbio.GetGpioMask(); byte EEPROM1_WR = 80; // 0xA0; _eeprom = new EEPROM_24LC256(nusbio, dataPin, clockPin); _eeprom.Begin(EEPROM1_WR); while (nusbio.Loop()) { if (Console.KeyAvailable) { var k = Console.ReadKey(true).Key; if (k == ConsoleKey.W) { var a = ConsoleEx.Question(23, "Write 32k now Y)es, N)o", new List <char>() { 'Y', 'N' }); if (a == 'Y') { WriteEEPROMPage(512); } } if (k == ConsoleKey.R) { ReadAndVerifyEEPROMPage(10); Cls(nusbio); } if (k == ConsoleKey.A) { ReadAndVerifyEEPROMPage(512); } if (k == ConsoleKey.B) { ReadAndVerifyEEPROMPageInBatch(512); } if (k == ConsoleKey.Q) { break; } Cls(nusbio); } } } Console.Clear(); }