Code: Select all
import pyb
pyb.usb_mode('CDC')
So many problems seem be down to this issue.
Code: Select all
import pyb
pyb.usb_mode('CDC')
Code: Select all
def get_data():
data= [i for i in range(10)]
data.append({1:'rats', 2:'aardvark'}) # just to show we can
return data
print(repr(get_data()))
Code: Select all
import pyboard
def execfile(filename, device):
pyb = pyboard.Pyboard(device)
pyb.enter_raw_repl()
output = pyb.execfile(filename)
pyb.exit_raw_repl()
pyb.close()
return output
def loads(s):
d = {}
exec("v=" + s, d)
return d["v"]
def getobject(filename, device='/dev/ttyACM0'):
b = execfile(filename, device)
s = b.decode('utf-8')
return loads(s)
print(getobject('pb_get_object.py'))
Code: Select all
[adminpete@axolotl]: ~
$ python3
Python 3.4.3 (default, Oct 14 2015, 20:28:29)
[GCC 4.8.4] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import print_object
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, {1: 'rats', 2: 'aardvark'}]
>>>
Code: Select all
OSError: [Errno 16] Device or resource busy: '/dev/pyboard'
I was able to get this working but I was wondering if there was a way to give data to the file youre running in the REPL? I have a list I want to give to the script that I want to run on the device, but it doesnt seem that I can just add it as another paramter.dhylands wrote: ↑Wed Nov 11, 2015 4:01 pmCode: Select all
import pyboard def execfile(filename, device='/dev/ttyACM0'): pyb = pyboard.Pyboard(device) pyb.enter_raw_repl() output = pyb.execfile(filename) pyb.exit_raw_repl() pyb.close() return output