File tree Expand file tree Collapse file tree 1 file changed +20
-2
lines changed Expand file tree Collapse file tree 1 file changed +20
-2
lines changed Original file line number Diff line number Diff line change 99 import pyboard
1010 pyb = pyboard.Pyboard('/dev/ttyACM0')
1111 pyb.enter_raw_repl()
12- pyb.exec('pyb.Led (1).on()')
12+ pyb.exec('pyb.LED (1).on()')
1313 pyb.exit_raw_repl()
1414
1515To run a script from the local machine on the board and print out the results:
1616
1717 import pyboard
1818 pyboard.execfile('test.py', device='/dev/ttyACM0')
1919
20+ This script can also be run directly. To execute a local script, use:
21+
22+ python pyboard.py test.py
23+
2024"""
2125
2226import time
@@ -157,5 +161,19 @@ def run_test():
157161 pyb .exit_raw_repl ()
158162 pyb .close ()
159163
164+ def main ():
165+ import argparse
8C2D
166+ cmd_parser = argparse .ArgumentParser (description = 'Run scripts on the pyboard.' )
167+ cmd_parser .add_argument ('--device' , default = '/dev/ttyACM0' , help = 'the serial device of the pyboard' )
168+ cmd_parser .add_argument ('--test' , action = 'store_true' , help = 'run a small test suite on the pyboard' )
169+ cmd_parser .add_argument ('files' , nargs = '*' , help = 'input files' )
170+ args = cmd_parser .parse_args ()
171+
172+ if args .test :
173+ run_test ()
174+
175+ for file in args .files :
176+ execfile (file , device = args .device )
177+
160178if __name__ == "__main__" :
161- run_test ()
179+ main ()
You can’t perform that action at this time.
0 commit comments