I’m finding that if I’m using USB_VCP my script runs fine from the ide. However, when I attempt to run the script standalone, it crashes. Other scripts run fine. Is this something I’m doing wrong?
simplified script:
import sensor, image, time, utime
from pyb import LED, USB_VCP
def blink(led,t=80):
LED(led).on()
time.sleep(t)
LED(led).off()
def write():
blink(3,t=1000)
if usb.isconnected():
print("usb exists; blinking 2")
blink(2)
while(True):
time.sleep(20)
if usb.any():
print("usb exists")
blink(2, t=1000)
cmd = usb.readlines(timeout=50) #fails here
else:
blink(2,t=50)
print("Nothing on the usb")
sensor.reset()
sensor.set_pixformat(sensor.GRAYSCALE)
sensor.set_framesize(sensor.QQVGA)
sensor.skip_frames(time = 2000)
sensor.set_auto_gain(False)
sensor.set_auto_whitebal(False)
clock = time.clock()
usb = USB_VCP()
while (True):
write()
output coming from the ide:
>>> usb exists; blinking 2
Nothing on the usb
Nothing on the usb
Nothing on the usb
Nothing on the usb
Output from minicom while running the script:
Welcome to minicom 2.7.1
OPTIONS: I18n
Compiled on Aug 13 2017, 15:25:34.
Port /dev/ttyACM1, 19:41:01
Press CTRL-A Z for help on special keys
usb exists; blinking 2
usb exists
Traceback (most recent call last):
File "/main.py", line 36, in <module>
File "/main.py", line 21, in write
TypeError: fAT
Traceback (most recent call last):AT
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
NameError: name 'AT' isn't defined
>>> ~x~