Camera doesn't react through serial port

Hi. I’ve been working with the camera from linux and python3. Yesterday I couldn’t make the camera return a picture through it’s port to my computer. The error:

File "", line 42, in camera_capture
    frame =
File "/home/filip/.local/lib/python3.6/site-packages/serial/", line 483, in read
    ready, _, _ =[self.fd, self.pipe_abort_read_r], [], [], timeout.time_left())

Communication is done with:

size = struct.unpack("<L",[0]
frame =

The camera script:

import sensor, image, time, ustruct, pyb
from pyb import USB_VCP
usb = USB_VCP()
sensor.skip_frames(time = 2000)
    cmd = usb.recv(4, timeout=5000)
    img = sensor.snapshot().compress()
    if (cmd == b'snap'):
        usb.send(ustruct.pack("<L", img.size()))

Connection established as:

port = '/dev/ttyACM0'
sp = serial.Serial(port, baudrate=115200, bytesize=serial.EIGHTBITS, parity=serial.PARITY_NONE,
        xonxoff=False, rtscts=False, stopbits=serial.STOPBITS_ONE, timeout=None, dsrdtr=True)
sp.setDTR(True) # dsrdtr is ignored on Windows.

The script was left hanging on read from camera as it didn’t return anything. I tried flashing the camera, but still couldn’t make it work until it randomly started working again after ~10 tries. Today I boot up my computer and the camera won’t work again. The tty port is right, checked trough both OPENMVIDE and terminal. Am I doing something wrong?

UPDATE: since then the camera is working again. I literally didn’t do anything just ran the script every 30 mins to check.


Um, we have a new RPC library for control over a UART coming soon. Dealing with these issues will be a thing of the past very soon. Expect a new IDE release with the new functionality within the month.