I have both LPC1768 & LPC2368,
I have found a curious anomaly with the LPC1768, i am basically using this as a data logger, generating a .CSV file,
the file name can change periodically, so I test if the file exists, (by attempting to READ from it), if not, then I close the file,
and set a flag, then RE-Open, and write a header, followed by the data.
this works with LPC2368, but crashes LPC1768
any thoughts ?
--------
sprintf (FName, "NewFile.txt");
pc.printf ("\r\n - - Save name = %s<>",FName);
FILE * fpCSV; = fopen (FName , "a");
fpCSV = fopen (FName , "r"); Test if file Exists ??
if(!fpCSV)
{
pc.printf ("\r\n\r\nNO file Exists\r\n\r\n"); ****** Does this printf, and stops **
HeadderRequired = 1;
}
else
{
pc.printf ("\r\n\r\nFile Exists\r\n\r\n");
HeadderRequired = 0;
}
fclose(fpCSV);
pc.printf ("\r\n\r\nFile CLOSED\r\n\r\n");
-----------
fpCSV = fopen (FName , "a");
pc.printf ("\r\n\r\nFile Opend\r\n\r\n");
if(!fpCSV)
{
printf( "\r\nError: The message file cannot be accessed .. CSV.TXT \r\n" );
GLCD_String (0,5, "Save WRITE FAIL:(");
}
else
{
? Head
if (HeadderRequired)
{
fprintf (fpCSV, "Press Name, User Name, Date, Time, Ch1, Ch2, Ch3, Ch4, Ch5, Ch6");
HeadderRequired = 0;
}
sprintf (Line,"\r\n%s, %s, %s, %s",StrPN, StrUN,DT, ADC_Txt); * My data *
pc.printf ("\r\n-> going to write this .. %s ..",Line);
fprintf (fpCSV, Line);
fclose(fpCSV);
}
I have both LPC1768 & LPC2368,
I have found a curious anomaly with the LPC1768, i am basically using this as a data logger, generating a .CSV file, the file name can change periodically, so I test if the file exists, (by attempting to READ from it), if not, then I close the file, and set a flag, then RE-Open, and write a header, followed by the data.
this works with LPC2368, but crashes LPC1768
any thoughts ?
--------Code ..
sprintf (FName, "NewFile.txt"); pc.printf ("\r\n - - Save name = %s<>",FName);
FILE * fpCSV; = fopen (FName , "a");
fpCSV = fopen (FName , "r"); Test if file Exists ??
if(!fpCSV) { pc.printf ("\r\n\r\nNO file Exists\r\n\r\n"); ****** Does this printf, and stops ** HeadderRequired = 1;
} else { pc.printf ("\r\n\r\nFile Exists\r\n\r\n"); HeadderRequired = 0; } fclose(fpCSV);
pc.printf ("\r\n\r\nFile CLOSED\r\n\r\n");
-----------fpCSV = fopen (FName , "a");
pc.printf ("\r\n\r\nFile Opend\r\n\r\n");
if(!fpCSV) { printf( "\r\nError: The message file cannot be accessed .. CSV.TXT \r\n" ); GLCD_String (0,5, "Save WRITE FAIL:("); } else {
? Head if (HeadderRequired) { fprintf (fpCSV, "Press Name, User Name, Date, Time, Ch1, Ch2, Ch3, Ch4, Ch5, Ch6"); HeadderRequired = 0; } sprintf (Line,"\r\n%s, %s, %s, %s",StrPN, StrUN,DT, ADC_Txt); * My data *
pc.printf ("\r\n-> going to write this .. %s ..",Line); fprintf (fpCSV, Line);
fclose(fpCSV); }