onzeq
1
Hello everyone,
I have seen, that ff_stdio.h provides the stdioSET_FF_ERROR()
and the appropriate getter-function but they are used nowhere.
Is there an intended way of using those functions to have access to the internal error codes?
I would like to use the API and in case of an error, have access to the error codes in my application.
Thank you.
carlk3
(Carl Kugler III)
2
For the FreeRTOS-Plus-FAT Native API, I set ffconfigDEBUG
in FreeRTOSFATConfig.h
and then do things like
FF_Error_t xError = FF_Mount(pxDisk, PARTITION_NUMBER);
if (FF_isERR(xError) != pdFALSE) {
FF_PRINTF("FF_Mount: %s (0x%08x)\n", (const char*) FF_GetErrMessage(xError), (unsigned)xError);
}
For the FreeRTOS-Plus-FAT Standard API, I use stdioGET_ERRNO()
; e.g.:
int iReturned = ff_findfirst(path ? path : "", &xFindStruct);
if (FF_ERR_NONE != iReturned) {
FF_PRINTF("ff_findfirst error: %s (%d)\n", strerror(stdioGET_ERRNO()),
stdioGET_ERRNO());
return;
}
htibosch
(Hein Tibosch)
3
I have seen, that ff_stdio.h provides the stdioSET_FF_ERROR()
and the appropriate getter-function but they are used nowhere.
The function stdioSET_FF_ERROR()
is called in one important occasion: when stdio translates the internal code to an errno: stdioSET_FF_ERROR()
:
stdioSET_ERRNO( prvFFErrorToErrno( xError ) );
Your app can retrieve the internal code by calling stdioGET_FF_ERROR()
. This only works when one of the stdio functions was called.
This is how you can use stdioGET_FF_ERROR()
:
int iReturned = ff_findfirst(path ? path : "", &xFindStruct);
if( iReturned != 0 ) {
FF_Error_t xError = stdioGET_FF_ERROR();
FF_PRINTF( "ff_findfirst error: %s (%d)\n",
( const char * ) FF_GetErrMessage( xError ),
( unsigned ) xError );
return;
}
A function like FF_FormatDisk()
returns the internal code and you can use it for logging.
PS. I also prefer to use the internal error codes because they give more precise information then the errno’s.