Does the machine library not support flow control?
referencing : class UART – duplex serial communication bus — MicroPython 1.23 documentation
example:
import sensor, image, time, os
from machine import UART, Pin
#==== hardware UART UART(1) || VCP on UART(3) ====
uart = UART(
1,
baudrate=115200,
bits=8,
parity=None,
stop=1,
timeout=10000,
flow=UART.RTS | UART.CTS,
rts=Pin('P13'),
cts=Pin('P14'),
)
error:
Traceback (most recent call last):
File “”, line 14, in
Yes, but, the API isn’t the same for all cameras for the machine module. You have to look at the C code to get it: micropython/ports/mimxrt/machine_uart.c at 38c1ae3e0d35dfc675bd9a68d1989fe7f136ebae · openmv/micropython
So, specificing the pins is not allowed. Here’s the mapping:
micropython/ports/mimxrt/boards/OPENMV_RT1060/mpconfigboard.h at 38c1ae3e0d35dfc675bd9a68d1989fe7f136ebae · openmv/micropython
0 maps to hardware UART3 and 1 maps to hardware UART1. The flow control pins are specified for talking to the BLE interface on the wifi module. However, there are no exported external flow control pins on the OpenMV Cam RT1062.
That is unfortunate. Transferring large image data to another MCU will not be very fun then.
This is easy to overcome, just use credit flow control counters. See our RPC library:
openmv/scripts/libraries/rpc.py at master · openmv/openmv
openmv/scripts/libraries/rpc.py at master · openmv/openmv
Mimick how this code works or… just use the RPC library in stream mode and you can transfer large blocks of data very efficiency in a robust way. The library works well for MCU to MCU UART transfer.
Better explanation:
rpc — rpc library — MicroPython 1.23 documentation
rpc — rpc library — MicroPython 1.23 documentation
…
Here’s an example on for the OpenMV Cam: openmv/scripts/examples/08-RPC-Library/34-Remote-Control/image_transfer_jpg_streaming_as_the_remote_device_for_your_computer.py at master · openmv/openmv
However, we only have an example for this to the PC which isn’t the most reliable since it’s not a realtime system. For the Arduino, not having MicroPython support makes the method for making this work a little harder. But, it’s doable to receive data in stream mode from the OpenMV Cam.
my stm32 is running C. I will have to rewrite the openmvrpc.cpp. I can try to implement something on my stm32 to work with RPC. On the camera side though, what am I doing wrong?
import sensor, image, time
import rpc
# Initialize sensor first
sensor.reset()
sensor.set_pixformat(sensor.RGB565)
sensor.set_framesize(sensor.VGA)
sensor.skip_frames(time=2000)
def snap(data):
"""
Capture an imag from the sensor, compress it as JPEG/return the byte array
"""
print("[Debug] Starting snap function")
# Take the picture and compress it
img = sensor.snapshot()
print("[Debug] Image captured")
# Compress to JPEG
img.compress(quality=50)
print(f"[Debug] Image compressed, size: {len(img.bytearray())} bytes")
# Return the JPEG data
return img.bytearray()
def main():
print("[Debug] Starting RPC slave")
# Set UART(1) at 115200 baud
interface = rpc.rpc_uart_slave(baudrate=115200, uart_port=1)
print("[Debug] UART interface created")
# Register the callback function?
interface.register_callback(snap)
print("[Debug] Callback registered")
print("[Debug] RPC slave started on UART1 (P4/P5)")
# Enter an infinite loop listening for remote procedure calls
interface.loop()
if __name__ == "__main__":
main()
Traceback (most recent call last):
File “main.py”, line 23, in
File “main.py”, line 21, in main
File “rpc.py”, line 357, in loop
File “rpc.py”, line 292, in __get_command
File “rpc.py”, line 89, in _get_packet
File “rpc.py”, line 651, in get_bytes
OpenMV v4.5.9; MicroPython v1.23.0-r19; OpenMV IMXRT1060-MIMXRT1062DVJ6A
Type “help()” for more information.
What’s the error message? You just posted the stack call trace. Not the actual error.
Hello,
Is this example ([quote=“kwagyeman, post:4, topic:10524”]
openmv/scripts/examples/08-RPC-Library/34-Remote-Control/image_transfer_jpg_streaming_as_the_remote_device_for_your_computer.py
[/quote]) supposed to work with the RT1062 cam ?
Thanks,
Nicolas
It cannot given that the example needs the pyb module which is not available on the RT1062.
However, you can switch the transport to UART and then it can run onboard.