Differentiate between IDE & VCP connections

In the python program, how to tell if the camera is connected to IDE or USBVCP? I tried to use USB_VCP.isconnected(), but it returns True even the cam is connected to IDE. During development and testing, my cam will normally connect to IDE. However, the cam will be connected to a linux box during production. I need a way to distinguish between these 2 cases.

Hi, um, you can’t use the VCP port when the IDE is connected to the camera because the IDE uses that. I’d recommend using the hardware UART for testing purposes and then switch to the VCP port once you think your code is ready.

I fully understand that I can’t use the VCP port when the IDE is connected to the camera. I’m not trying to connect the camera to IDE and use the VCP port at the same time.

All I am asking is there an API in the OpenMV library which can tell me if I’m currently connected to IDE or using VCP as a serial terminal? During development, the Camera will connect to a Mac running IDE. As for production, the camera will connect to a Linux box and communicate to a Java program via VCP. And the Camera will switch between these 2 environments very often. The handling of the Python program will be different in these 2 scenarios. I can modify the program each time when I switch environments, but this is not ideal. I would expect there is a way to tell which connection it’s currently using programmatically.

As for the USB_VCP.isconnected() API in the OpenMV, why does it return “True” when the Python program is running under IDE? Is this a bug? My expected behaviour of this API is to return “True” when connected via VCP, and “False” when connected to IDE. If this API works, it will serve my purpose.

Mmm, it probably is a bug. Mostly related to the way our IDE connects to the cam. Please submit a bug request to our GitHub.

I’ve submitted a bug report to Github. Besides the USB_VCP.isconnected() API, is there any other API that I can use to detect if the OpenMV cam is connected to IDE? If I’m not mistaken, the OpenMV cam connects to IDE with 921600 BPS. Is this the way the firmware detects if the IDE is connected by checking the baud rate? Is there any OpenMV API that I can use to check the USB VCP port baud rate?

Hi, I’ve added a new function for that (see github issue), it will be available in the next release.

I’ve compiled the firmware and tested the new debug_mode_enabled() API. It’s working perfectly. The technical support that you’ve provided for the product is incredible. Thank you so much! :slight_smile: