RPC Method called, LEDs flash and stops transmitting?

Hi there, I have a program on my computer (herein referred to as “MAS”) and a program on the H7 (herein referred to as “SLA”) that are modelled after the sample programs that allow for image jpeg streaming through the RPC library. The programs work fine until MAS calls a method on SLA. In MAS’s program it give it time (5 seconds) to begin image streaming before calling the method, but once it’s called the H7 will flash red two times and then white once, and then MAS will continue outputting the most recent fps reading and the video will be frozen.

The method on SLA has logic to return either true or false, which I may be doing wrong since I’m new to python also. Depending on the state of the code, I have SLA setting “status” = False or = True, and returning “struct.pack(”?“, status)” to return a bool.

Any advice?

As a new finding, this LED flashing also happens if I try to turn the green LED ON before entering the loop function (pyb.led(2).on() before interface.loop()).

It’s really hard to have any advice without some kind of specific debugging on your part. The issue could be anything.

Of note… people have founds issues with the timeouts on the USB VPC based RPC stream and have not found it to be that reliable. It works on some PCs and not on others. You might try to update the basic timeouts for it.

The library was written specifically for UART/I2C/SPI interfaces. However, while it can be used on any interface, the fact that the computer doesn’t respond in a timely manner is a challenge for the RPC library which assumes the link partner is real-time ish.

@kwagyeman , Thanks for the info! I guess a more specific question for this would be does the LED flashing red twice have a significance / is it a type of error code that’s built in to the system?

I did a little debugging and I was drawn to the timeouts also, I found that my procedure on SLA would return normally after around 115-140 ms depending on the logic. I tried adjusting the timeouts in the RPC Library from 1000 to 3000 in the “call” function within the “rpc_master” class and the “loop” function within the “rpc_slave” class with no luck. I understand that the remote call is returning “None”, which means there is some trouble communicating with the camera, but I’m confused because it communicates fine before the function is called. I’m not sure how to debug my one procedure, as it runs as a stand-alone function when called from the main loop.

The most confusing thing to me was that the same LED Flash code would happen if I tried to just turn on the green LED before calling interface.loop().

Do you have wireshark for USB? It’s really easy to see the issue if you use that. You can see the RPC packets being sent by the library and the camera’s responses and then you can see where the timeouts don’t align.

I’m sorry that I don’t have time to debug this right now. Know this, the protocol is fine. However, the timeouts are kinda based on a real-time MCU responding in 1ms or less time intervals and PC’s don’t do this. So, while UART/I2C/SPI comms are solid the WiFi/USB stuff is a little bit more tricky.

1 Like

Just as an update, I was able to use Wireshark for a bit of debugging! I’m not very fluent in its software or the USB protocol but I was able to see that the cam was throwing an error once the data was passed to/from SLA. I changed what SLA was returning from a bool to a signed char (return struct.pack(“<b”, status)) with it returning 0 or 1 and that seemed to let everything fall into place. Thanks for the suggestions!