No response from OpenMV as Slave

Hi, I would like to send data from a raspberry pi to a openMV H7 Hand cam plus using the raspberry as a master and the hand cam as a slave. I am currently using this pair of codes

Master:

import rpc
import serial

# Initialize the connection to OpenMV via USB (VCP)
# Change the port to match your OpenMV camera's USB serial port (e.g., /dev/ttyACM0)
usb_port = "/dev/ttyACM0"

# Create an RPC client over USB VCP
client = rpc.rpc_usb_vcp_master(port=usb_port)

while True:
    # Call the 'hello_world' function on OpenMV and get the response
    result = client.call("hello_world")

    # Print the response from OpenMV
    if result is not None:
        print("Response from OpenMV:", result)
    else:
        print("No response from OpenMV.")
        

Slave:

import rpc
import pyb

red_led = pyb.LED(1)
# Initialize the RPC interface (USB Virtual COM Port)
pyb.LED.on(red_led)
pyb.delay(500)
pyb.LED.off(red_led)
pyb.delay(500)
interface = rpc.rpc_usb_vcp_slave()  # For UART use rpc_uart_slave()
pyb.LED.on(red_led)
pyb.delay(500)
pyb.LED.off(red_led)
pyb.delay(500)
## Define a simple function to respond with a message
def hello_world(data):
    return "Hello from OpenMV!"

## Register the hello_world function to be called over RPC
interface.register_callback(hello_world)

## Main loop to keep the RPC server running
pyb.LED.on(red_led)
pyb.delay(500)
pyb.LED.off(red_led)
pyb.delay(500)
interface.loop()  # Continuously listen for RPC commands

I used the red led to troubleshoot sections of the code and it is working fine. However, when running the code on the master side of things I can’t seem to get a response
This is the output recieved

No response from OpenMV.
No response from OpenMV.
No response from OpenMV.

Please help me with this problem and thank you in advance.
Many thanks,
Unscythe

Hi, that code looks correct.

The RPC library may not always work over USB using VCP with another computer. It’s meant for UART/I2C/SPI and depends on a fast serial response from the other side of the connection.

I can’t say the timeout issues is an error in this case though. The Pi is reasonably real time so it should work without issues. Can you make a bug ticket on the OpenMV GitHub and I will try to debug this next week.

In the meantime, you may wish to talk to the camera via this:

import serial
ser = serial.Serial("/dev/ttyACM0", timeout=1, dsrdtr=False)
while True:
    line = ser.readline().strip()
    if line: print(line)

And then print() on the OpenMV Cam to get data on the PC from the camera. This is one way communication but it should definitely work. If this is not functioning then the problem lies elsewhere.