diff --git a/tools/pycard10.py b/tools/pycard10.py index d5b51e7ed0572f62088201e075b6d4f5dc3d5d05..820925d1eb8a8568c8795c4182ff3f8d4e73a389 100755 --- a/tools/pycard10.py +++ b/tools/pycard10.py @@ -213,6 +213,11 @@ def main(): "--device", default="/dev/ttyACM0", help="the serial device of the card10" ) cmd_parser.add_argument("-c", "--command", help="program passed in as string") + cmd_parser.add_argument( + "--set-time", + action="store_true", + help="Set card10 system time to this host's time", + ) cmd_parser.add_argument( "-w", "--wait", @@ -241,7 +246,7 @@ def main(): if args.reset: card10.soft_reset() - elif args.command is not None or len(args.files): + elif args.set_time or args.command is not None or len(args.files): # we must enter raw-REPL mode to execute commands # this will do a soft-reset of the board try: @@ -268,6 +273,16 @@ def main(): stdout_write_bytes(ret_err) sys.exit(1) + # Set card10 system time + if args.set_time: + now = round(time.time()) + code = """\ +import utime +utime.set_unix_time({time}) +print("Time was set to {time}!") +""" + execbuffer(code.format(time=now)) + # run the command, if given if args.command is not None: execbuffer(args.command.encode("utf-8"))