lemariva / micropython-camera-driver

add camera support to MicroPython
https://lemariva.com
Apache License 2.0
462 stars 99 forks source link

Error while trying to write files in the virutal file system. #36

Closed ncotti closed 2 years ago

ncotti commented 2 years ago

Hi, I recently upgraded the firmware to the new version you provided, but i've encountered a strange bug.

My code looks like this:

with open("/log.txt" , "a+") as file:
    pass

camera.init(0, format=camera.JPEG)

for i in range(0,100):
    with open("/log.txt", 'a+') as log_file:
        print ("Test " + str(i))
        log_file.write("Test " + str(i) + "\n")

As you can see, after initializing the camera, I try to perform multiple write operations on a single file. However, after an undefined amount of these operations, the program execution blocks in the "write" statement and never leaves. I present to you some terminal output examples:

Test 0
Test 1
Test 0
Test 1
Test 2

After further examination, i have discovered that this issue only happens if the file, in this example "/log.txt`, existed before resetting the ESP32. What I mean is that doing this kind of operation works fine as long as the file is created in the same execution instance. However, if the file existed before powering on the ESP32, the writing operation will block.

lemariva commented 2 years ago

Can you check out the latest firmware? I think that could be a problem with the HEAP. Now it's better managed.

ncotti commented 2 years ago

Yeah, as you said, after updating the firmware the problem seems to have dissappeared. Thanks for the update, good job!

lemariva commented 2 years ago

Thanks for reaching out! I close the issue then.