LED all colors blinking after program stops

Hello there,
I am having the problem that my program stops after some seconds, and a few moments later all three LEDs start blinking continously. Then the IDE disconnects, and Windows is showing the error message, a drive could not be recognized.

I am using OpenMV M4 with external power supply and a 8 GB SD Card in it. I am using it as a SPI Slave.

What meaning do the LEDs have, if they blink fast all at the same time? And what could be the error causing this problem?

I’m looking forward to your answers

I have another problem too where I don’t know the cause, and maybe those errors are connected.
I sometimes, not always, get the error messages:

AttributeError: ‘(arrow sign)’ object has no attribute ‘find_blobs’
AttributeError: ‘’ object has no attribute ‘possibleLandmarkIDs’
AttributeError: ‘int’ object has no attribute ‘find_blobs’
AttributeError: ‘int’ object has no attribute ‘thereshold’

‘int’ ‘(empty)’ and ‘(arrow sign)’ vary randomly.

In this code:

class BlobAnalyser:

    def __init__(self):
    	#some more code
    def findBlobs(self):
        global img
        img = sensor.snapshot()
        allBlobs = img.find_blobs(self.thresholds, pixels_threshold=200, area_threshold=150, merge=True)
        self.blobs = []
        i = 0
        for blob in allBlobs:
            i += 1
    def findLandmarkCombo(self, bnoAngle, playingTowardsBlue):
            self.possibleLandmarkIDs = []
            if len(self.blobs) == 0:
                return None
            for blobIndex in range(len(self.blobs)):
                idGiven = [False] * len(self.queue)
                #and some more code
     #and more functions

This code is executed quite often in an endless loop, and suddenly it throws those errors completely randomly.

One single time I got an error message, could not open E:\discard, unable to read file type (and some file type name, which I cannot remember :neutral_face:)

Hope to hear from you!

All lights flashing means a hard error. Normally this is due to memory corruption. So, one of the functions you are calling likely has a bug in it.

Can you track down the line of code that has the issue? It’s most likely on of our methods, i.e. not general python stuff. Please let me know what is wrong and I will fix.

Note that find blobs has been heavily debugged. That should work. Also, are you using the latest firmware?

Getting random attribute errors also please send a sign of memory corruption.

Thanks for your answer!

I am using the latest firmware version 2.3.0 .

I started logging everything and it came out that both issues are connected - and they are memory issues, and occure when the memory gets full. See readme.txt for logs!

In the attachment I uploaded the sourcecode where the errors occured, see findLandmarkCombo() and findBlobs() (a self - programmed version) for the output, where the letters of the logs are printed.

If I use gc.collect() manually should I disable automatic garbage collection?
BlobAnalyser.py (17.9 KB)
readme.txt (3.09 KB)

Hi, I just got around to looking at this code. Um, so, you can’t use recursive operations on a microcontroller. “findQueueCombinationsRecursive” we don’t have a stack protector since that would reduce performance. Once you go beyond the stack limit you just walk right into the heap. As the case for any C microcontroller you have to be careful with recursive stuff. If a heap memory allocation does fail you’ll get an error however. So, please re-write your recursive operation using a list/queue which you add and remove things to do from.

Note that while the recursion probably succeeds… it walks all over the heap corrupting things which causes failures once heap code looks at the heap again. Using GC collect is just hiding the error by making the heap code not have to look at later portions of the heap which are messed up.

Anyway, that’s some pretty complex code you have there… um, so, do you think you could boil the error you’re getting down to something I can more easily look through if the above issue is not your problem? There’s way to much going on there for me to debug.

Also, that kind of impressive use of the OpenMV Cam makes me want to see you with an M7…

Actually the latest is 2.4.1