Exemplo n.º 1
0
        public bool VerifyDevice(DeviceOperation op)
        {
            var device = Config.Device;

            var flashBlocks  = FlashHexBoard.SplitBlocks(device.Flash.PageSize);
            var eepromBlocks = EepromHexBoard.SplitBlocks(device.Eeprom.PageSize);

            op.FlashSize  += flashBlocks.TotalBytes;
            op.EepromSize += eepromBlocks.TotalBytes;

            using (var programmer = CreateProgrammer(op)) {
                using (programmer.Start()) {
                    if (!VerifyBlocks(programmer, flashBlocks, AvrMemoryType.Flash, op))
                    {
                        return(false);
                    }

                    if (!VerifyBlocks(programmer, eepromBlocks, AvrMemoryType.Eeprom, op))
                    {
                        return(false);
                    }
                }
            }
            op.Complete();
            op.CurrentState = "Everything is done";

            return(true);
        }
Exemplo n.º 2
0
 private static bool VerifyBlocks(IProgrammer programmer, HexBlocks blocks, AvrMemoryType memType, DeviceOperation op)
 {
     if (blocks.Blocks.All(block => VerifyBlock(programmer, block, memType, op)))
     {
         return(true);
     }
     op.Complete();
     op.Status = DeviceOperationStatus.Error;
     return(false);
 }
Exemplo n.º 3
0
        public bool EraseDevice(DeviceOperation op)
        {
            var device = Config.Device;

            op.FlashSize  += device.Flash.Size;
            op.EepromSize += device.Eeprom.Size;

            using (var programmer = CreateProgrammer(op)) {
                using (programmer.Start()) {
                    programmer.EraseDevice();
                }
            }

            op.Complete();
            op.CurrentState = "Everything is done";

            return(true);
        }
Exemplo n.º 4
0
        public bool VerifyLockBits(DeviceOperation op)
        {
            var device = Config.Device;

            var lockBlocks = LocksHexBoard.SplitBlocks(1);

            op.LocksSize += lockBlocks.TotalBytes;

            using (var programmer = CreateProgrammer(op)) {
                using (programmer.Start()) {
                    if (!VerifyBlocks(programmer, lockBlocks, device.LockBits.Location ?? AvrMemoryType.LockBits, op))
                    {
                        return(false);
                    }
                }
            }
            op.Complete();
            op.CurrentState = "Everything is done";

            return(true);
        }