Howdy,
I am using an Arduino Uno/Teensy4.1 as the controller to an OpenMV H7 Plus camera microcontroller. I am using the Arduino to test the communication protocol and execution of the script on the OpenMV camera. I have both devices plugged in via USB. I have seen in some of the forums that connection over USB might cause an issue, but I have tested the code and communication via SPI previously and it worked perfectly fine. Integration into the Teensy is for use in an integrated system with a dedicated power source.
The examples from the rpc library were working via SPI and I had no problems. I took a break from the project for a month or so, and when I tried to run the same script the OpenMV camera would stall. I am fairly certain that the wiring between both devices is done properly.
When I terminate the program I get the following traceback message:
Traceback (most recent call last):
File “”, line 26, in
File “rpc.py”, line 358, in loop
File “rpc.py”, line 293, in __get_command
File “rpc.py”, line 90, in _get_packet
File “rpc.py”, line 609, in get_bytes
Exception: IDE interrupt
I have created a smaller script to test the communication between the two boards. The goal of the script is to blink the led (blue) whenever a call to the function is made. Here are those scripts:
Arduino / Teensy Code
#include <openmvrpc.h>
openmv::rpc_scratch_buffer<256> scratch_buffer; // All RPC objects share this buffer.
openmv::rpc_spi_master interface(10, 100000, SPI_MODE2);
void setup() {
interface.begin();
Serial.begin(115200);
}
void exe_blinky()
{
struct { uint16_t val; } res;
Serial.print("Attempting to call blinky \n");
Serial.println(interface.call(F("blinky"), &res, sizeof(res)));
if (interface.call(F("blinky"), &res, sizeof(res))) {
Serial.print(F("Result ["));
Serial.print(res.val);
Serial.println(F("]"));
}
}
void loop() {
exe_blinky();
}
OpenMV Code
import time
import image
import math
import rpc
import sensor
import struct
from machine import LED
sensor.reset()
sensor.set_pixformat(sensor.RGB565)
sensor.set_framesize(sensor.QVGA)
sensor.skip_frames(time=2000)
led = LED("LED_BLUE")
interface = rpc.rpc_spi_slave(cs_pin="P3", clk_polarity=1, clk_phase=0)
def blinky(data):
img = sensor.snapshot()
led.on()
time.sleep_ms(500)
led.off()
time.sleep_ms(500)
return struct.pack("<H", 1)
interface.register_callback(blinky)
interface.loop()
