File tree 1 file changed +20
-2
lines changed 1 file changed +20
-2
lines changed Original file line number Diff line number Diff line change 9
9
import pyboard
10
10
pyb = pyboard.Pyboard('/dev/ttyACM0')
11
11
pyb.enter_raw_repl()
12
- pyb.exec('pyb.Led (1).on()')
12
+ pyb.exec('pyb.LED (1).on()')
13
13
pyb.exit_raw_repl()
14
14
15
15
To run a script from the local machine on the board and print out the results:
16
16
17
17
import pyboard
18
18
pyboard.execfile('test.py', device='/dev/ttyACM0')
19
19
20
+ This script can also be run directly. To execute a local script, use:
21
+
22
+ python pyboard.py test.py
23
+
20
24
"""
21
25
22
26
import time
@@ -157,5 +161,19 @@ def run_test():
157
161
pyb .exit_raw_repl ()
158
162
pyb .close ()
159
163
164
+ def main ():
165
+ import argparse
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
+
160
178
if __name__ == "__main__" :
161
- run_test ()
179
+ main ()
You can’t perform that action at this time.
0 commit comments