Wipy 2.0 and save data on my pc, not in flash memory
-
@vflorio94 But how large is 'datiprova_tempo20.txt'? That is the file which grows by about 50kBytes on every execution of your script.
-
@robert-hh said in Wipy 2.0 and save data on my pc, not in flash memory:
You can tell the size ofdatiprova_tempo20.txt with:
import uos
uos.stat('datiprova_tempo20.txt')
Every time you call your script this file will get larger, since you open that in append mode "a". I am just wondering why this file is not shown in the FileZilla screen dump.now I delete also the function 'interval.py' and 'sending.py' but it continue to give me the same error.
-
@vflorio94 You can tell the size ofdatiprova_tempo20.txt with:
import uos
uos.stat('datiprova_tempo20.txt')Every time you call your script this file will get larger, since you open that in append mode "a". I am just wondering why this file is not shown in the FileZilla screen dump.
-
@robert-hh I use the command that you wrote and it gives me the message:
import uos print(uos.listdir()) print(uos.getfree("/flash")) >>> ['main.py', 'sending.py', 'sys', 'lib', 'cert', 'boot.py', 'datiprova_tempo20.txt', 'lib_imu.py', 'interval_position.py'] 0 ╝╝>```
but it's incredible, just Yesterday it run. and I don't know what can I do now?!
-
@vflorio94 Filezilla just sends commands to the ftp server of the FiPy.
-
@vflorio94 At the REPL prompt, you can also get the file list and free space with:
import uos
uos.listdir()
uos.getfree("/flash")
-
@robert-hh No, there aren't any file in the subdirectory. But Yesterday it run program and saved them on memory.
after I collected data I deleted immediately file.txt. But now I have this error.
Probably do not filezilla really delete file?
-
@vflorio94 Are there any other files in the subdirectories, like in lib?
-
@robert-hh I delete each file.txt that I write before on the device with Filezilla.
Yesterday and the day before in this condition I can wrote file.txt on the device, but now I can't and it give me this error.
but on the memory there are only those file.py.
-
@vflorio94 Error 28 means: "No space left on device"
So your file system is full. You have to delete some files, or better change your code to save on an SD card. The internal flash file system is pretty small. I do not know why, because most of the FiPy's flash is not used.
-
@robert-hh Hi, sorry for my insistence. I have a new problem
╝Traceback (most recent call last): File "<stdin>", line 24, in <module> OSError: 28 ╝>
but i don't know why, because Yesterday this code run and now it give me this message.
the code is this oneimport machine import pycom from machine import Timer import time import lib_imu from machine import I2C from machine import PWM import gc chrono = Timer.Chrono() lib_imu.set_configmode() time.sleep(0.05) lib_imu.set_units() time.sleep(0.05) lib_imu.set_mode('ndof') # List =[] file_dati = open("datiprova_tempo20.txt", "a") chrono = Timer.Chrono() chrono.start() lap = chrono.read() while lap <= 1200: #eul = lib_imu.get_euler() file_dati.write(repr(lap) + "\t ") file_dati.write(repr(lib_imu.get_euler()[0]) + "\t ") time.sleep(0.02) lap = chrono.read() file_dati.close() print("fine") chrono.stop()
Can you help me please?
-
@robert-hh Thank you very much for your help. I've never scheduled with Python, so for me is very difficult and I have to do this for my master thesis. For me you were very valuable.
thank you.
-
@vflorio94 Taking the measurement and writing takes time too. Now you know, it's about 0.015s.
-
@robert-hh Thank you, I did in this way and the code run, but the real sample isn't 0.02 s but each 0.035 s. And I don't know why?!
-
@vflorio94 The code could look like:
import machine import pycom from machine import Timer import time import lib_imu from machine import I2C from machine import PWM chrono = Timer.Chrono() lib_imu.set_configmode() time.sleep(0.07) lib_imu.set_units() time.sleep(0.3) lib_imu.set_mode('ndof') with open("dati360.txt", "w") as file_dati: chrono.start() lap = chrono.read() while lap < 1200 file_dati.write(repr(lib_imu.get_euler()[0])) time.sleep(0.02) lap = chrono.read() print("fine") chrono.stop()
-
@vflorio94 You should collect & write at the same time. Since the writikng is buffered, most of the write operations will not take long.
-
@robert-hh So, if i want to collect as more possible data in 1200 s how frequently can i take values?
-
@vflorio94 So you want first to collect for 1200 seconds data, with a delay of 20 ms each. I do not know how long taking a value needs, if have someting in mind like ~100 ms, which give a list of 10000 entries, and then you want to store that. AFAIK, the basic mp object type needs 8 bytes/entry, so you need 80kbytes for the fill table. Being already low on memory, the list append fails soon, when the runtime engine of micropython wants to allocate more memory for the list, roughly after 128 cycles.
So no, you simply cannot do that with a WiPY2. You have to write to SD in shorter cycles, even if that would interrupt your data acquisition.
Alternatively, use a device with more memory, like a WiPy3.
-
@robert-hh Sorry, but I need your help one more if is possible.
I have to acquire data from IMU for a long time ( 20 minuts) and write the data on file.
but also this time I have the error╝Traceback (most recent call last): File "<stdin>", line 22, in <module> MemoryError: memory allocation failed, allocating 2048 bytes ╝>
Here there are the simple code lines that I wrote. This error is terrible for me, probably I make an error on how to do this . please , can you Help me please?
import machine import pycom from machine import Timer import time import lib_imu from machine import I2C from machine import PWM chrono = Timer.Chrono() lib_imu.set_configmode() time.sleep(0.07) lib_imu.set_units() time.sleep(0.3) lib_imu.set_mode('ndof') List =[] chrono.start() while 1 : lap = chrono.read() if lap <= 1200: eul = lib_imu.get_euler() List.append(eul[0]) time.sleep(0.02) else: print("Salvataggio su file") file_dati = open("dati360.txt", "w") file_dati.write(repr(List[1:len(List)])) file_dati.close() print("fine") chrono.stop() del List break
-
@robert-hh And I 'm not able to use serial terminal