# USB VCP data transfer issue

**URL:** <https://forums.openmv.io/t/usb-vcp-data-transfer-issue/6242>\
**Category:** OpenMV Boards\
**Created:** [August 17, 2021, 9:44am UTC](https://forums.openmv.io/t/usb-vcp-data-transfer-issue/6242 "2021-08-17T09:44:10Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Lattice](https://avatars.discourse-cdn.com/v4/letter/l/c57346/32.png) [@Lattice](https://forums.openmv.io/u/Lattice)\
**Post date:** [August 17, 2021, 9:44am UTC](https://forums.openmv.io/t/usb-vcp-data-transfer-issue/6242/1 "2021-08-17T09:44:10Z")

</div>

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 🙂 Sorry to bother, problem solved by calling usb.setinterrupt(-1)

---

<div class="post-metadata">

**Author:** ![kwagyeman](https://yyz1.discourse-cdn.com/flex029/user_avatar/forums.openmv.io/kwagyeman/32/4_2.png) [@kwagyeman](https://forums.openmv.io/u/kwagyeman)\
**Post date:** [August 18, 2021, 4:17am UTC](https://forums.openmv.io/t/usb-vcp-data-transfer-issue/6242/2 "2021-08-18T04:17:52Z")

</div>

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

> **[openmv/tools/rpc at master · openmv/openmv](https://github.com/openmv/openmv/tree/master/tools/rpc)**
>
> master/tools/rpc

---

<div class="post-metadata">

**Author:** ![Lattice](https://avatars.discourse-cdn.com/v4/letter/l/c57346/32.png) [@Lattice](https://forums.openmv.io/u/Lattice)\
**Post date:** [August 25, 2021, 7:40am UTC](https://forums.openmv.io/t/usb-vcp-data-transfer-issue/6242/3 "2021-08-25T07:40:03Z")

</div>

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