def trace_test(core, tracepath, commands): args, unknown_args = parse_args() args.device = core_to_device[core] args.replay = tracepath cli = InternalBlueCLI(args) cmd_array = commands.split("; ") if "quit" not in cmd_array[len(cmd_array)-1]: cmd_array += "quit" cli.runcmds_plus_hooks(cmd_array)
# and now read and save the random random = internalblue.readMem(MEM_RNG, MEM_ROUNDS * 5) data.extend(random) i = i + 1 internalblue.logger.info("Finished acquiring random data!") # every 5th byte i 0x42 check = data[4::5] for c in check: if c != 0x42: internalblue.logger.error("Data was corrupted by another process!") # uhm and for deleting every 5th let's take numpy (oh why??) data = np.delete(data, np.arange(4, data.__len__(), 5)) f = open("rpi3p-randomdata-%irounds.bin" % rounds, "wb") f.write(data) f.close() internalblue.logger.info("--------------------") internalblue.logger.info("Entering InternalBlue CLI to interpret RNG.") # enter CLI cli = InternalBlueCLI( Namespace(data_directory=None, verbose=False, trace=None, save=None), internalblue) sys.exit(cli.cmdloop())