Please held SPIFFS issue.
Posted: Sat Jul 13, 2019 12:47 pm
Goodday,
Please Guide.
I have upload a binary file (my_micky.bin) to spiffs using upload tool.
the bin file is a uint32_t 2d array contains integer values from 0 - 4294967295 i.e array[100][10];
which i create using C (B/W image to integers)
i want to read values into defined array in sketch.
the problem is I couldn't use fread function to read this data.
i could use fread on arduino uno and sdcard. i migrated to wemos d1 r2 so that i can use wifi and spiffs.
i tried all possible and GOOGLE. i could reach to using readBytes function but i have to use char array not integer.
using fread function i get the following error:
cannot convert 'fs::File' to 'FILE* {aka __sFILE*}' for argument '4' to 'size_t fread(void*, size_t, size_t, FILE*)'
Hoping I explained my problem well.
Please guide if there i other way to get data into the defined array.
Please Guide.
I have upload a binary file (my_micky.bin) to spiffs using upload tool.
the bin file is a uint32_t 2d array contains integer values from 0 - 4294967295 i.e array[100][10];
which i create using C (B/W image to integers)
i want to read values into defined array in sketch.
the problem is I couldn't use fread function to read this data.
i could use fread on arduino uno and sdcard. i migrated to wemos d1 r2 so that i can use wifi and spiffs.
i tried all possible and GOOGLE. i could reach to using readBytes function but i have to use char array not integer.
using fread function i get the following error:
cannot convert 'fs::File' to 'FILE* {aka __sFILE*}' for argument '4' to 'size_t fread(void*, size_t, size_t, FILE*)'
Hoping I explained my problem well.
Please guide if there i other way to get data into the defined array.
Code: Select all
#define FS_NO_GLOBALS
#include<FS.h>
uint32_t arr[100][20];
void setup(){
Serial.begin(115200);
SPIFFS.begin();
//Initialize File System
if(SPIFFS.begin())
{
Serial.println("SPIFFS Initialize....ok");
}
else
{
Serial.println("SPIFFS Initialization...failed");
}
}
void loop() {
fs::File fp = SPIFFS.open("/my_micky.bin","r");
size_t len = fp.size();
Serial.println(len);
if(fp == 0)
{
printf("Error\n");
exit(1);
}
else{
fread(arr, len, 1, fp);
for (int i=0; i<100; i++){
for(int j=0; j<20;j++){
printf("%lu",arr[i][j]); // for unsigned 32bit
printf(",");
}
}
}
}