Camera doesn't react through serial port

Discussion related to "under the hood" OpenMV topics.
Posts: 9
Joined: Sun Mar 31, 2019 6:18 pm

Camera doesn't react through serial port

Postby Houkouha » Wed Apr 08, 2020 6:20 am

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:

Code: Select all

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:

Code: Select all

size = struct.unpack("<L",[0]
frame =
The camera script:

Code: Select all

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:

Code: Select all

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.
User avatar
Posts: 4271
Joined: Sun May 24, 2015 2:10 pm

Re: Camera doesn't react through serial port

Postby kwagyeman » Wed Apr 08, 2020 1:23 pm


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.

Return to “Technical Discussion”

Who is online

Users browsing this forum: No registered users and 15 guests