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 "main_bolts.py", line 42, in camera_capture frame = sp.read(size) File "/home/filip/.local/lib/python3.6/site-packages/serial/serialposix.py", line 483, in read ready, _, _ = select.select([self.fd, self.pipe_abort_read_r], , , timeout.time_left())
Communication is done with:
sp.write(b"snap") sp.flush() size = struct.unpack("<L", sp.read(4)) frame = sp.read(size)
The camera script:
import sensor, image, time, ustruct, pyb from pyb import USB_VCP usb = USB_VCP() sensor.reset() sensor.set_pixformat(sensor.RGB565) sensor.set_framesize(sensor.QVGA) sensor.skip_frames(time = 2000) while(True): cmd = usb.recv(4, timeout=5000) img = sensor.snapshot().compress() if (cmd == b'snap'): usb.send(ustruct.pack("<L", img.size())) usb.send(img)
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.