Hi @timreyes,
Thank you for your reply, and your patience waiting for me to investigate this. To answer your questions first:
- MachineID: 95d2ece5-c45f-455b-9955-a8f604ad7bcf
- I’m only using pre-installed analyzers (mostly SPI and I2C).
- I have certainly seen these errors, but I know they can mostly be resolved with lower sample rates. The error is I believe different here, because sometimes there is no error message in the GUI, except for the analyzer error “Failed to keep up“.
After some trial-and-error I managed to write a cut-down version of the software to reproduce the error with a simulated device.
Observation 1: I can manually create the error in GUI with simulation, because I can add e.g. an SPI analyser and THEN start a looping capture, set trim after stopping to 10ms (this is the important part!), and then stopping immediately after start. Interestingly, there is no error showing in the GUI, except from the analyzer error. Increasing the trim time helps: as long as during capture the analyzer data falls behind LESS than the trim time (i.e. at the time of stop the tail of processing is within the trimmed data), then the analyzer completes. I believe this is the main reason.
However, this approach is almost impossible from the API, because I cannot add an analyzer before starting capture (perhaps intentionally). This means I cannot simulate SPI data, because it only appears when simulation has an analyser. Without actual data to analyze the SPI analyzer is faster and able to usually keep up.
Observation 2:
Adding an analyzer while the capture is still running causes the code to wait on the add_analyzer function, until the capture stops. However, the analyzer IS added, and it simply waits for the data returned. This means running for a long time waiting for data causes the analyzer to fall behind. Then if a trigger/stop finally happens, the trimming is applied at the end, and the analyzer shows the error. There is again, no error in the GUI, and the code is still stuck on add_analyzer function. You can try this with a relatively fast SPI channel.
Observation 3:
I get the same behaviour if I stop at a time when there is no activity on any of the lines. You can try this by not connecting to any SPI channels, and just running and stopping with the analyzer enabled. It is a different problem, but sometimes happens with faulty hardware. In most cases however, the add_analyzer returns OK, even though the “Failed to keep up“ error is printed on the GUI.
Building on these observations, I managed to create a python script that calls a simulated device. I have to set an intentionally short trim time (0.1ms) to catch the analyser in a bad state. Obviously this is not practical, but necessary for simulation. The other alternative is to somehow slow down the analyser processing speed, which I couldn’t figure out with simulation, or try with real SPI data.
Note that I start the capture on a thread, just to be able to stop and trim it after a certain time, even if the analyzer is stuck. Here’s the interesting part: sometimes the add_analyzer returns, sometimes it’s stuck, on average every 5th fails, so I added a loop to re-try. I cannot figure what’s the difference, in both capture files there is an analyzer error. When it is stuck, I can manually go into the GUI and restart the last capture’s analyzer, then the loop continues.
_saleae_analyzer_error.py (1.9 KB)
Hope this helps debugging this, and maybe you can help me understand this behaviour better, e.g. why it happens when it happens and what can I change to avoid it.
Many thanks,
Daniel