USB VCP data transfer issue

Hello!
I’m trying to setup my OpenMV cam as a simple camera that transfers JPEG/RAW images over VCP to python application.
I developed a simple protocol to control OpenMV: camera reads 4 bytes command from VCP and reads additional parameters from VCP depending on that command.
Everything seems to work fine, but… I can not send byte “3”, yep number 3 OpenMV simply crashes with red bliking led.
Am I doing something wrong, or this is kind of special byte for VCP? I can not get any stack trace because VCP is in use.

Here is my PC test code:

import serial, struct
port = ‘COM5’
sp = serial.Serial(port, baudrate=115200, bytesize=serial.EIGHTBITS, parity=serial.PARITY_NONE, xonxoff=False, rtscts=False, stopbits=serial.STOPBITS_ONE, timeout=1000, dsrdtr=True)
sp.dtr = True # i can not receive anything without dtr on
y = 3 #sending 3 does not work!
pk = struct.pack(‘4sb’, b’test’, y)
sp.write(pk)
sp.flush()
res = sp.read(1) #receive result
print(res)

And OpenMV test code:

import pyb, ustruct
green = pyb.LED(2)
blue = pyb.LED(3)
usb = pyb.USB_VCP()
while (True):
cmd = usb.recv(4, timeout=1000)
if (cmd == b’test’):
green.on() # for debugging
buf = usb.recv(1, timeout=1000) # receive
blue.on() # for debugging
val = ustruct.unpack(‘b’, buf)
x = val[0] * 2 # multiply by 2
res = ustruct.pack(‘b’, x) # send back
usb.send(res)

Sending any other value like 4 or 2 works, but not 3! Green or blue leds do not fire up on sending 3.

Edit: By keep reading from VCP after sending 3 I accitentially got a traceback: it states that OpenMV received KeyboardInterrupt on line “green.on()” and OpenMV cam actually does not crash - it goes into python REPL mode. So how do i disable this behavoir?

Ahh… i had to read the docs first :slight_smile: Sorry to bother, problem solved by calling usb.setinterrupt(-1)

Please use the RCP library. We are no longer debugging folks USB code.

Thanks, didn’t know firmware already have that functionality.