/// <summary>
 /// Callback from the above, data in response is processed.
 /// </summary>
 /// <param name="context"></param>
 private void OnReadCallback(MySerial.AsyncContext context)
 {
     appendToLog("trying to read.\n");
     context.ResponseRaw.CopyTo(eeprom);
     _stopwatch.Stop();
     appendToLog(maxAddress + " bytes read in " + _stopwatch.ElapsedMilliseconds / 1000 + " seconds\n");
 }
        /// <summary>
        /// After writing a binary block this is the callback indicating success.
        /// It then writes the next blockm or declares success if no more blocks
        /// need to be written.
        /// </summary>
        /// <param name="context">an argument block for tracking status of the writes.</param>
        private void OnWriteCallback(MySerial.AsyncContext context)
        {
            // index into the block by the amount written.
            int addr = context.Offset + context.Count;

            if (addr < this.maxAddress)
            {
                int newCount = (addr + context.Count) < maxAddress ? context.Count : (maxAddress - addr);
                mySerial.Write("w," + Utility.wordToHex(addr) + "," + Utility.wordToHex(newCount) + "\n", '%', null);
                mySerial.Write(data, addr, newCount, '%', 0, OnWriteCallback);
                appendToLog("wrote data from 0x" + Utility.wordToHex(addr) + " to 0x" + Utility.wordToHex(addr + 1023) + "\n");
            }
            else
            {
                _clear.IsEnabled = true;
                _write.IsEnabled = true;
                _read.IsEnabled  = true;
            }
        }
 /// <summary>
 /// Callback from above which contains the version text.
 /// </summary>
 /// <param name="context"></param>
 private void OnVersionCallback(MySerial.AsyncContext context)
 {
     appendToLog(context.ResponseText);
 }