Closed Ruben0595 closed 11 months ago
Code, please.
sure!
The code is uploading files when it is connected to the internet (not in the code below) and delete files older than a day.
I masked my ftp servers info and got rid of the gc.collect() mentioned above, since it did not help. block size is a bit arbitrarily trying to get stuff working, by filling in random numbers, but used to be 2048. thanks a lot for helping.
today = str(time.localtime()[0])[2:]+ '-' + str(time.localtime()[1]) + '-' + str(time.localtime()[2])
filepath_today = 'database/' + today + '.csv'
ftp = FTP_TLS('webMASKED.MASKED.nl') #masked informatin, since it is not a public test server
ftp.login(ship_info.mmsi + ship_info.name + '@MASKED', ship_info.ftp_pwd) #inlog name and pwd are from ship_info file
#ftp.retrlines('LIST')
for filename in os.listdir('database'): #for loop iterates over saved files, each with a date.
try:
data = 'database/'+filename
print('uploading ' + filename)
tim0.init(period=600000, mode=Timer.ONE_SHOT, callback=time_out) #start interrupt timer, so it gets out of a freeze
upload_fail = True #used in further code to let user know if file upload failed
upload(ftp, data, blocksize = 512) #upload
upload_fail = False #upload succeed
tim0.deinit() #de init timer
filer.log(filename +' uploaded') #log that a file has been uploaded
if filename != today+'.csv': #delete the uploaded file if it is older than a day
print('data removed ' +filename)
os.remove(data)
filer.log(filename +' deleted')
except Exception as e:
print(e)
filer.log('file upload failed ' + str(e))
upload_fail = True
Where does it fail in the upload
function? (I guess that's the one from ftpupload.py
?) Any traceback? Or error messages? Have you tried to set ftp.set_debuglevel(1)
?
it is indeed the upload function from ftpupload.py, which calls storbinary function from ftplib.py. it seems to be just frozen somewhere in the while loop of the storbinary function, which does not have a traceback. when I terminate it, the error: [Errno 113] ECONNABORTED, but this is probably because of terminating it. when trying to set ftp.set_debuglevel(1), error: AttributeError: 'FTP_TLS' object has no attribute 'set_debuglevel'
Ah, ok, you are using the esp
variant. Which doesn't have the debugging commands. I can only suggest inserting strategic print commands into FTP.ntransfercmd
to find out what's going on.
all of the sudden it started working fine, Will just use it and if the problem rises again I will raise the issue again. thanks a lot for helping!!
I still have issues with sending the files. it just crashes the entire esp every once in a while.
Thanks for the heads up. But I'm afraid without further debugging on your part I won't be able to get to the bottom of this.
I can only re-iterate what I said before:
I can only suggest inserting strategic print commands into
FTP.ntransfercmd
to find out what's going on.
first of all: thanks a lot, your contributions are truly invaluable. I'm trying to recreate the problem, but it seems to work perfectly fine.. it's a bad thing that it works now haha. I'll catch up with you if I can recreate the problem.
When uploading a file larger than ~5kb, my ESP32 freezes. I tried collecting garbage to reduce memory usage, but this did not help. smaller files usually upload fine.