private void Consolidate() { var blocks = new List <HexBlock>(); var ela = 0u; foreach (var l in lines) { if (l.Type == HexRecordType.EndOfFile) { break; } switch (l.Type) { case HexRecordType.Data: blocks.Add(new HexBlock(l.LineStartAddr + ela, l.Data)); break; case HexRecordType.ExtendedLinearAddress: ela = ((uint)l.Data[0] << 24) + ((uint)l.Data[1] << 16); break; default: throw new NotImplementedException(); } } blocks.Sort((a, b) => (int)a.StartAddr - (int)b.StartAddr); HexBlock last = null; var consolidated = new List <HexBlock>(); foreach (var b in blocks) { if (last != null && b.StartAddr == last.NextAddr) { last.Append(b.Data[0]); } else { last = b; consolidated.Add(last); } } regions = new List <HexRegion>(); foreach (var b in consolidated) { regions.Add(new HexRegion { StartAddr = b.StartAddr, Data = b.Data.SelectMany(a => a).ToArray(), }); } }
private static bool VerifyBlock(IProgrammer programmer, HexBlock block, AvrMemoryType memType, DeviceOperation op) { var actualData = new byte[block.Data.Length]; programmer.ReadPage(block.Address, memType, actualData, 0, actualData.Length); for (var i = 0; i < block.Data.Length; i++) { var actual = actualData[i]; var expected = block.Data[i]; var address = i + block.Address; if (!op.Device.Verify(memType, address, actual, expected)) { op.CurrentState = string.Format("Verification failed at {0}:0x{1:x4}.\r\nExpected 0x{2:x2} but was 0x{3:x2}", memType, i + block.Address, expected, actual); return(false); } } return(true); }
public void Setup() { block1 = new GameObject("1").AddComponent <HexBlock>(); block2 = new GameObject("2").AddComponent <HexBlock>(); }