I am using fscanf function to get values from the afe.csv file stored in SD card reader.
i am not able to read the values and getting 0 for all parameters when printed on screen.
please find below the code for reference.
void read_file()
{
FILE *tmp;
tmp= fopen("/sd/afetest.csv", "r");
if(tmp==NULL) represent file is present
{
serial.printf("file not present\n");
}
{
while(!feof(tmp))
{
int z=0;
z = vfscanf(tmp,"%f,%f,%f,%f,%f,%f,%f,%f,%f,%f,%f,%f,%f,%f,%f,%f,%f,%f,%f,%f,%f,%f,%f \r\n",&Total_loop_time1,&cellvolt[0],&cellvolt[1],&cellvolt[2],&cellvolt[3],&cellvolt[4],&cellvolt[5],&cellvolt[6],&cellvolt[7],&cellvolt[8],&cellvolt[9],&cellvolt[10],&cellvolt[11],&cellvolt[12],&cellvolt[13],&cellvolt[14], &bat_volt,&battery_current,&Bat_Ah,&soc,&temp_deg3,&temp_deg2,&temp_deg1);
serial.printf("\n\n z is %d \r\n ", z);
{
}
}
}
fclose(tmp);
}
I am using fscanf function to get values from the afe.csv file stored in SD card reader.
i am not able to read the values and getting 0 for all parameters when printed on screen.
please find below the code for reference.
void read_file()
{ FILE *tmp; tmp= fopen("/sd/afetest.csv", "r"); if(tmp==NULL) represent file is present { serial.printf("file not present\n"); } {
while(!feof(tmp)) { int z=0; z = vfscanf(tmp,"%f,%f,%f,%f,%f,%f,%f,%f,%f,%f,%f,%f,%f,%f,%f,%f,%f,%f,%f,%f,%f,%f,%f \r\n",&Total_loop_time1,&cellvolt[0],&cellvolt[1],&cellvolt[2],&cellvolt[3],&cellvolt[4],&cellvolt[5],&cellvolt[6],&cellvolt[7],&cellvolt[8],&cellvolt[9],&cellvolt[10],&cellvolt[11],&cellvolt[12],&cellvolt[13],&cellvolt[14], &bat_volt,&battery_current,&Bat_Ah,&soc,&temp_deg3,&temp_deg2,&temp_deg1); serial.printf("\n\n z is %d \r\n ", z); {
} } } fclose(tmp); }