I have some strange behavior on my OpenMV board when trying to play with remote controlling and callbacks by being inspired by provided examples. I might not have well understood how it works so I tried to oversimplify my script in order to check the basis.
Here is the code on the PC side:
import rpc
interface = rpc.rpc_usb_vcp_master('COM5')
result = interface.call("two")
print(result)
I modified the code in order to be able to run several times the call until it succeeds but still after 150+ attempts, it doesn’t work.
The camera is plugged to the computer and powered, main is saved on the drive and camera has been reset. It looks like there is something preventing the camera to run the main.py properly. It drives me hazy.
Here is the modified code (PC side), just in case
import rpc
interface = rpc.rpc_usb_vcp_master('COM5')
result = None
i = 0
while result is None:
result = interface.call("two")
i += 1
if i%10 == 0:
print(i)
print(result)
I don’t know if it can help, but it might be linked to the above mentioned issue. When connecting to the camera via Putty, in order to access the interpreter, I have need to press enter key and I got the following error (then it comes back to the python interpreter):
Mmm, something is broken. I can’t get your example to work either. I do notice that the camera led flashes red after the computer connects which implies an exception happened. If you were able to view the exception message then it would be easy to fix.
The last time I got this working I had to debug with a usb protocol analyzer. Using the VCP port is a real pain. I would suggest using the COM port over hardware serial and only switching to VCP once the code is fully debugged.
…
Oddly, image streaming works fine with our default example script.
…
There might be some issue with not starting the camera. Can you start from the jpg image streaming example script and work backwards from there?
I’m not certain if this is your only issue, but you need to have a memoryview object defined in the definition of your fcn even if you aren’t using it. It appears to be an Openmv rpc requirement. Try the following and let us know if that resolves your issue.
def two(data):
return "2".encode()
The docs offer the following on the topic: “The call back should take one argument which will be a memoryview object and it should return a bytes() like object as the result. The call back should return in less than 1 second if possible”
Thanks for your help! Indeed the argument issue was the one blocking the callback from being executed.
Now I got it working. Let’s build something more serious with scheduled callbacks then.