Esp8266 rebooting when GETing a large file
Posted: Sat May 07, 2016 7:39 am
Hi !
I'm trying to make a piece of software that GET a file on a server and displays it on a 128x128 SPI display.
It works well until the file stay small than 20K. Above this size, the ESP reboots.
Not clear why. Any idea ?
function showpic()
file.open("avcp","r")
for x=0,127,2 do
for y=0,127,2 do
r=string.byte(file.read(1))
g=string.byte(file.read(1))
b=string.byte(file.read(1))
disp:setColor(r,g,b)
disp:drawHLine(x,y,2)
disp:drawHLine(x,y+1,2)
end
end
file.close()
end
jdone=0
startload=0
conn=net.createConnection(net.TCP)
conn:on("receive", function(cnn, pl)
if (startload==0) then
print("Got header"..pl.."[[")
startload=1
file.open("avcp","w")
else
l=l+pl:len()
file.write(pl)
print(l)
end
end)
conn:on("sent",function(conn)
print("Envoyé !")
jdone = jdone + 1
end)
conn:on("disconnection",function(conn)
print("Disconnected")
file.close()
collectgarbage()
showpic()
end)
conn:on("connection",function(cnn)
print("Connecté")
cnn:send("GET <my_file> HTTP/1.1\r\nHost: cluster015.ovh.net\r\nConnection: keep-alive\r\nAccept: */*\r\nUser-Agent: Mozilla/4.0\r\n\r\n")
end)
conn:on("sent",function(conn)
print("Sent")
end)
conn:connect(80,'<my_server>')
I'm trying to make a piece of software that GET a file on a server and displays it on a 128x128 SPI display.
It works well until the file stay small than 20K. Above this size, the ESP reboots.
Not clear why. Any idea ?
function showpic()
file.open("avcp","r")
for x=0,127,2 do
for y=0,127,2 do
r=string.byte(file.read(1))
g=string.byte(file.read(1))
b=string.byte(file.read(1))
disp:setColor(r,g,b)
disp:drawHLine(x,y,2)
disp:drawHLine(x,y+1,2)
end
end
file.close()
end
jdone=0
startload=0
conn=net.createConnection(net.TCP)
conn:on("receive", function(cnn, pl)
if (startload==0) then
print("Got header"..pl.."[[")
startload=1
file.open("avcp","w")
else
l=l+pl:len()
file.write(pl)
print(l)
end
end)
conn:on("sent",function(conn)
print("Envoyé !")
jdone = jdone + 1
end)
conn:on("disconnection",function(conn)
print("Disconnected")
file.close()
collectgarbage()
showpic()
end)
conn:on("connection",function(cnn)
print("Connecté")
cnn:send("GET <my_file> HTTP/1.1\r\nHost: cluster015.ovh.net\r\nConnection: keep-alive\r\nAccept: */*\r\nUser-Agent: Mozilla/4.0\r\n\r\n")
end)
conn:on("sent",function(conn)
print("Sent")
end)
conn:connect(80,'<my_server>')