Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Guinness
firmware
Commits
1f488472
Commit
1f488472
authored
Oct 06, 2019
by
Rahix
Browse files
Merge 'Add flag to pycard10 to set time'
See merge request
card10/firmware!342
parents
c3c5a5f8
110b71c5
Changes
1
Hide whitespace changes
Inline
Side-by-side
tools/pycard10.py
View file @
1f488472
...
...
@@ -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"
))
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment