Hello
I’m having some problems creating files on an SD card. I’m using a Niclavision with OPENMV 4.5.1 software. My system collects the values from the IMU at a frequency of 104Hz. It stores the data in array and after two seconds stores the data in a new .txt file on an SD card.
However, I have a few problems:
-
Firstly, each new cycle a new text file is created on the SD card. The more time passes, the longer it takes to create this text file in the SDcard. Are there any solutions to this problem? I got the same probleme when i save à picture into the SDcard with img.save(path)
-
When I try to use os.umount(path), an error is displayed: “AttributeError: ‘VfsFat’ object has no attribute ‘umount’”.
-
Finally, the /vsfat library for vsfat.mount and vsfat.umount is available on openMV?
If you have any idea how to solve the probleme, thank you in advance.
Here is my code :
Blockquote
while(True):
#Init timestamp
if(Valuetime ==1):
i=i+1
tick = time.ticks_ms()
Valuetime =0
print("oui")
#Store IMU data into array
lsm.interrupt()
if INT_MODE:
if INT_FLAG:
RTCAccGyr = rtc.datetime()
Heure.append(RTCAccGyr[4])
Minute.append(RTCAccGyr[5])
Seconde.append(RTCAccGyr[6])
Milliseconde.append(RTCAccGyr[7])
ACCX.append((lsm.accel())[0])
ACCY.append((lsm.accel())[1])
ACCZ.append((lsm.accel())[2])
GYRX.append((lsm.gyro())[0])
GYRY.append((lsm.gyro())[1])
GYRZ.append((lsm.gyro())[2])
INT_FLAG = False
#After 2seconds store the data into a txt file
if(time.ticks_ms() - tick >= 2000):
for x in range(len(ACCX)):
Total = '{:>8.3f},{:>8.3f},{:>8.3f},{:>8.3f},{:>8.3f} {:>8.3f} {:>8.3f} {:>8.3f} {:>8.3f} {:>8.3f} \n'.format(Heure[x] , Minute [x] , Seconde [x] , Milliseconde[x], ACCX[x] ,ACCY[x],ACCZ[x],GYRX[x] ,GYRY[x],GYRZ[x])
List.append(Total)
fn = "/sd/GyrAcc"+str(i)+"_.txt"
#Write IMU data into SDCARD
with open(fn, "w") as f:
f.write('\n'.join(List))
f.close()
#Init
List = list()
ACCX = array.array('f')
ACCY = array.array('f')
ACCZ = array.array('f')
GYRX = array.array('f')
GYRY = array.array('f')
GYRZ = array.array('f')
Heure = array.array('f')
Minute = array.array('f')
Seconde = array.array('f')
Milliseconde = array.array('f')
Valuetime = 1
time.sleep_ms(1000)
Blockquote