Skip to content
Snippets Groups Projects
Commit 1f488472 authored by rahix's avatar rahix
Browse files

Merge 'Add flag to pycard10 to set time'

See merge request !342
parents c3c5a5f8 110b71c5
No related branches found
No related tags found
No related merge requests found
......@@ -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"))
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment