Hi,
I want my OpenMV H7 (slave) to communicate with STM32f407 (master). For now I only want to send and receive simple data, just to check if spi works as it should. Sending data by H7 works, but when I try to receive I almost always get an error.
Also I heard that I should try to use RPC library, but I’m now really sure how, because I dont want to send frames, just simple data (like 0xAA in my code).
Thanks, and have a nice day.
Please use our RPC library. I will not provide help support for trying to use the RAW SPI interface anymore since I’ve already created a very robust system to send data and written libraries for the Arduino toe receive the data.
The RPC library literally handles all kinds of issues and just works. It’s completely robust to disconnect issues and starts working immediately if you loose and reconnect a wire.
Hi, I am having the exact same problem. Forgive me I am not the best at programming.
Where can you get this RPC library? How do you implement it? Does the RPC library work with STM32 boards as well? Would It be to much to ask for an example how a standard fullduplex SPI communication would look like with the RPC library.
Docs: rpc — rpc library — MicroPython 1.15 documentation
The example is under: File>Examples>OpenMV>Remote Control> (for example) image_transfer_raw_as_the_remote_device_1.py
My problem is also that this example is more complex than I need. I would like to see just the simplest example of how to send and receive bytes, nothing more .
And before you ask, I’ve read the docs and tried using it but I didn’t manage to succeed.
I just want to read this buffer on OpenMV side and do something with the data.
I was thinking about using rpc.get_bytes or rpc.stream_reader and I tried that, the thing is nothing works and I’m not sure where to look for solution.
From what I’ve seen from Arduino example it looks like I can execute callbacks by calling interface.call(). So it looks like I need to use rpc also on master side, to call for an function etc. But is there a library for STM32? Or if not, what should I transmit on master side so that OpenMV would understand and go into a callback function?
This simple receive program works with the default spi example in the OpenMV IDE (arduino_spi_slave)
It doesn’t work well but it works.
So for better performance I am trying now to implement the RPC library. From the documentation and provided examlpes I made a program on the OpenMV IDE that looks like something like this.
That’s a lot to debug. Can you just port the Arduino RPC library to the STM32?
You just need to define a new class for SPI that works on your STM32 board.
And then add the get/put methods.
Otherwise… you can’t use the RPC library on the OpenMV Cam with base level SPI code on the STM32. So, you’re going to have to implement your own serial protocol and etc.
…
Here are your options.
#1 - Port the RPC library to run on the STM32. This just means fixing the SPI stuff above and then implementing something for time to replace millis().
#2 - Use the SPI Module on the OpenMV Cam directly. This will give you low-level SPI control on the camera. However, you’re going to have to deal with the syncing issues with are non-trivial.
If you want to avoid using the RPC library and just use the low-level code I recommend UARTs as you won’t have any sync issues. If you are trying to use SPI it will be much harder.
I am getting a signal out of TX on my camera, but I can’t read it. Here is a picture form my osciloscope, of the signal that the above program is making:
To me, it just looks like, the camera has some strange logic of putting bits together.
Going from when I was trying to make the SPI work, when I looked at the SPI signal, I could tell what kind of message it was just from looking at the osciloscope image. every bit was in the correct spot.
just for reference, here is a another image when the message in the OpenMV code is 11110101:
Ah yes, I saw my error. it should have been 0b00011111. I forgot the “0b”. Thank you very much. From the look of things, in my test run, everything is working as it should. Now I need to implement this into the main program and see if it is fast enough.