Current Lua downloadable firmware will be posted here

User avatar
By kwis2
#52710 I have trying to program ESP8266-1 in lua for a few days, so it could be problem that I'm doing something wrong. I have written simple program to test files.
Idea was to get as much data as I could from sensor. It mean that I was going to write data to file, and when filesystem would be full delete oldest file.

after several runs (about 340) my module hangs, reset with reset code 2 !!! what was impossible. Reset pin pulled.

curr file 348 file to del 51
Waiting answer from ESP - Timeout reached. Command aborted.

ets Jan 8 2013,rst cause:2, boot mode:(3,6)

load 0x40100000, len 25952, room 16
tail 0
chksum 0xe0
load 0x3ffe8000, len 2256, room 8
tail 8
chksum 0xf3
load 0x3ffe88d0, len 8, room 0
tail 8
chksum 0xbf
csum 0xbf


module doesn't respond to Esplorer even when I try to change lua file

>
file.remove("meas.lua");
> file.open("meas.lua","w+");
Waiting answer from ESP - Timeout reached. Command aborted.> w = file.writeline
>


but after format module work OK.

Question is if there is a bug or am I doing sth wrong

my module ESP8266-1,
NodeMCU custom build by frightanic.com
branch: master
commit: 98d3b46e2c11068f361154a564ce75a048c9dadc
SSL: true
modules: adc,bit,file,gpio,http,i2c,net,node,ow,rtcfifo,rtcmem,rtctime,sntp,spi,tmr,uart,wifi
build built on: 2016-08-05 08:59
powered by Lua 5.1.4 on SDK 1.5.4.1(39cb9a32)

there is my code

Code: Select allif singleLua==nil then
    singleLua=0
    print ("init")
    FileCurrNumber=0
    FileDelNumber=1
end

dane=FileCurrNumber
    for num=0, 100, 1   --init data file
    do
        dane=dane.." aazzaaax"
    end

if singleLua~=0 then
    singleLua=singleLua+1
    if singleLua>3 then
        singleLua=0
    end
    print(singleLua.." meas ")
    return
end

singleLua=1

maxFileNr=500        --OK
FileName='awyn'     --OK
FileExt='.dat'     --OK

    r,u,t=file.fsinfo() print("Total : "..t.." bytes\r\nUsed  : "..u.." bytes\r\nRemain: "..r.." bytes\r\n")
    if(r<20000) then --less than 20k free
    maxFileNr=1    --delete one file
    end
     r=nil u=nil t=nil

print("curr file "..FileCurrNumber.." file to del "..FileDelNumber)

FileCurrNumber=FileCurrNumber+1
fileCntr=FileCurrNumber+1-FileDelNumber

fileCurrName=tostring(FileName..FileCurrNumber..FileExt)

file.open(fileCurrName ,"w+")
file.write(dane)
--wyn=file.seek()
--print('dlugosc = '..wyn)
file.flush()
file.close()

print (fileCurrName)
print (fileCntr)

if fileCntr>maxFileNr then
    fileDelName=tostring(FileName..FileDelNumber..FileExt)
    file.remove(fileDelName)
    FileDelNumber=FileDelNumber+1
end
singleLua=0


Best regards
Kamil
User avatar
By devsaurus
#52791
kwis2 wrote:Total : 397082 bytes
Used : 376249 bytes
Remain: 20833 bytes

Wow, you're really dumping a lot of stuff onto the flash :shock: But that shouldn't render the file system unusable.
In any case, it might be that the loop prevents the watchdog timer from being serviced. If it's running for more than 5 seconds, then the ESP will be reset by WDT. Please try to add tmr.wdclr() and report the results here.
User avatar
By kwis2
#52793 with tmr.wdclr() there was record with 385 file runs.

Total : 397082 bytes
Used : 377253 bytes
Remain: 19829 bytes

curr file 385 file to del 87
PANIC: unprotected error in call to Lua API (meas.lua:45: open a file first)

ets Jan 8 2013,rst cause:2, boot mode:(3,6)

load 0x40100000, len 25952, room 16
tail 0
chksum 0xe0
load 0x3ffe8000, len 2256, room 8
tail 8
chksum 0xf3
load 0x3ffe88d0, len 8, room 0
tail 8
chksum 0xbf
csum 0xbf


while line 45 mean:

[code
44 file.open(fileCurrName ,"w+")
45 file.write(dane)
46 --wyn=file.seek()
47 --print('dlugosc = '..wyn)
48 file.flush()
49 file.close()[/code]

So clear of wdt could a little help but not solve problem.

I have tested work on 5 different modules ESP8266-01 from different shops, but I have only current build, and results are the same.
Question is if you could test program with your modules - code from post #1 is complete file - I wasn't able to attach lua file. I have run file with timer every 1 second