private void OnWriteAddress() { try { byte[] bWriteData; int[] writeRegVals; int writeAddressValue = 0; if (!Utility.ConvertStringInt(WriteAddress, ref writeAddressValue)) { throw new Exception("Invalid address. Enter integer value in decimal <nnn> or hex <0xhhh>"); } if (IsWriteFromFile) { bWriteData = File.ReadAllBytes(WriteFromFilePath); //mDriver.WriteMemory(Model, SelectedMemoryBlock, writeAddressValue, bWriteData); } else { if (IsAccessRegister) // Write Register { if (WriteData.Length < 1) { throw new Exception("Empty input"); } try { string[] regValStrings = WriteData.Split(','); writeRegVals = new int[regValStrings.Length]; for (int i = 0; i < regValStrings.Length; i++) { if (!Utility.ConvertStringInt(regValStrings[i], ref writeRegVals[i])) { throw new Exception("Invalid value string: " + regValStrings[i]); } } if (writeRegVals.Length == 1) { mInstr.RegDriver.RegWrite((AddressSpace)mMyAddressSpace, writeAddressValue, writeRegVals[0]); } else { mInstr.RegDriver.ArrayWrite((AddressSpace)mMyAddressSpace, writeAddressValue, writeRegVals, writeRegVals.Length); } } catch (Exception ex) { throw new Exception("Writing error:" + ex.Message); } } else //Write Memory { if (WriteData.Length < 2) { throw new Exception("Invalid data. Enter at least 1 byte (2 characters)"); } try { bWriteData = HexStringToByteArray(WriteData); } catch { throw new Exception("Invalid data. Enter data in hex"); } //mDriver.WriteMemory(Model, SelectedMemoryBlock, writeAddressValue, bWriteData); } } } catch (Exception ex) { mMainViewModel.LatestMessage = ex.Message; } finally { UpdateErrorMessage(); } }