Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: GlasgowEmbedded/glasgow
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 32a36a2fdb60
Choose a base ref
...
head repository: GlasgowEmbedded/glasgow
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: c098ef4621b8
Choose a head ref
  • 1 commit
  • 1 file changed
  • 1 contributor

Commits on Jan 30, 2020

  1. Copy the full SHA
    c098ef4 View commit details
Showing with 30 additions and 3 deletions.
  1. +30 −3 software/glasgow/applet/memory/_24x/__init__.py
33 changes: 30 additions & 3 deletions software/glasgow/applet/memory/_24x/__init__.py
Original file line number Diff line number Diff line change
@@ -175,14 +175,27 @@ def hex_bytes(arg):
p_write.add_argument(
"address", metavar="ADDRESS", type=address,
help="write memory starting at address ADDRESS")
g_data = p_write.add_mutually_exclusive_group(required=True)
g_data.add_argument(
g_write_data = p_write.add_mutually_exclusive_group(required=True)
g_write_data.add_argument(
"-d", "--data", metavar="DATA", type=hex_bytes,
help="write memory with DATA as hex bytes")
g_data.add_argument(
g_write_data.add_argument(
"-f", "--file", metavar="FILENAME", type=argparse.FileType("rb"),
help="write memory with contents of FILENAME")

p_verify = p_operation.add_parser(
"verify", help="verify memory")
p_verify.add_argument(
"address", metavar="ADDRESS", type=address,
help="verify memory starting at address ADDRESS")
g_verify_data = p_verify.add_mutually_exclusive_group(required=True)
g_verify_data.add_argument(
"-d", "--data", metavar="DATA", type=hex_bytes,
help="compare memory with DATA as hex bytes")
g_verify_data.add_argument(
"-f", "--file", metavar="FILENAME", type=argparse.FileType("rb"),
help="compare memory with contents of FILENAME")

async def interact(self, device, args, m24x_iface):
if args.operation == "read":
data = await m24x_iface.read(args.address, args.length)
@@ -203,3 +216,17 @@ async def interact(self, device, args, m24x_iface):
success = await m24x_iface.write(args.address, data)
if not success:
raise GlasgowAppletError("memory did not acknowledge write")

if args.operation == "verify":
if args.data is not None:
golden_data = args.data
if args.file is not None:
golden_data = args.file.read()

actual_data = await m24x_iface.read(args.address, len(golden_data))
if actual_data is None:
raise GlasgowAppletError("memory did not acknowledge read")
if actual_data == golden_data:
self.logger.info("verify PASS")
else:
raise GlasgowAppletError("verify FAIL")