LED all colors blinking after program stops

General discussion about topics related to OpenMV.
desireentz
Posts: 4
Joined: Thu May 25, 2017 7:58 am

LED all colors blinking after program stops

Postby desireentz » Mon Jun 19, 2017 8:04 am

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
desireentz

EDIT:
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:

Code: Select all

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
            img.draw_rectangle(blob.rect())
            self.blobs.append(blob)
        self.sortBlobs()
    
    def findLandmarkCombo(self, bnoAngle, playingTowardsBlue):
            self.findBlobs()
            self.possibleLandmarkIDs = []
            if len(self.blobs) == 0:
                return None
            for blobIndex in range(len(self.blobs)):
                self.possibleLandmarkIDs.append([])
                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 :|)

Hope to hear from you!
User avatar
kwagyeman
Posts: 1078
Joined: Sun May 24, 2015 2:10 pm

Re: LED all colors blinking after program stops

Postby kwagyeman » Mon Jun 19, 2017 11:06 am

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?
Nyamekye,
User avatar
kwagyeman
Posts: 1078
Joined: Sun May 24, 2015 2:10 pm

Re: LED all colors blinking after program stops

Postby kwagyeman » Mon Jun 19, 2017 11:08 am

Getting random attribute errors also please send a sign of memory corruption.
Nyamekye,
desireentz
Posts: 4
Joined: Thu May 25, 2017 7:58 am

Re: LED all colors blinking after program stops

Postby desireentz » Wed Jun 21, 2017 8:23 am

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?
Attachments
BlobAnalyser.py
(17.89 KiB) Downloaded 15 times
readme.txt
(3.09 KiB) Downloaded 15 times
User avatar
kwagyeman
Posts: 1078
Joined: Sun May 24, 2015 2:10 pm

Re: LED all colors blinking after program stops

Postby kwagyeman » Thu Jun 22, 2017 12:31 am

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...
Nyamekye,
User avatar
iabdalkader
Posts: 344
Joined: Sun May 24, 2015 3:53 pm

Re: LED all colors blinking after program stops

Postby iabdalkader » Thu Jun 22, 2017 8:17 am

desireentz wrote:
Wed Jun 21, 2017 8:23 am
I am using the latest firmware version 2.3.0 .
Actually the latest is 2.4.1

https://github.com/openmv/openmv/releases/latest

Return to “General Topics”

Who is online

Users browsing this forum: No registered users and 1 guest