1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2025-02-20 10:54:14 +01:00

OP-267 Flight/UAVObjectManager: Make all references to DFS function depend on

PIOS_USD_SDCARD.  However, this needs to be cleaned up and abstracted out of
the UAVObjectManager who shouldn't care about the storage layer.

git-svn-id: svn://svn.openpilot.org/OpenPilot/trunk@2417 ebee16cc-31ac-478f-84a7-5cbb03baadba
This commit is contained in:
peabody124 2011-01-14 01:38:27 +00:00 committed by peabody124
parent 940792db5c
commit 9cf3ee9fb3
4 changed files with 27 additions and 1 deletions

View File

@ -52,7 +52,7 @@
#define PIOS_INCLUDE_BMP085
#define PIOS_INCLUDE_OPAHRS
#define PIOS_INCLUDE_COM
#define PIOS_INCLUDE_SDCARD
//#define PIOS_INCLUDE_SDCARD
#define PIOS_INCLUDE_SETTINGS
#define PIOS_INCLUDE_FREERTOS
#define PIOS_INCLUDE_GPIO

View File

@ -308,12 +308,14 @@ static void updateSystemAlarms()
AlarmsClear(SYSTEMALARMS_ALARM_STACKOVERFLOW);
}
#if defined(PIOS_INCLUDE_SDCARD)
// Check for SD card
if (PIOS_SDCARD_IsMounted() == 0) {
AlarmsSet(SYSTEMALARMS_ALARM_SDCARD, SYSTEMALARMS_ALARM_WARNING);
} else {
AlarmsClear(SYSTEMALARMS_ALARM_SDCARD);
}
#endif
// Check for event errors
UAVObjGetStats(&objStats);

View File

@ -35,6 +35,13 @@
#define UAVOBJ_ALL_INSTANCES 0xFFFF
#define UAVOBJ_MAX_INSTANCES 1000
// FIXME: All this typedef for SDCARD needs to be abstracted away
#if !defined(PIOS_INCLUDE_SDCARD)
typedef struct {} FILEINFO;
#endif
typedef void* UAVObjHandle;
/**

View File

@ -83,8 +83,11 @@ static ObjectInstList* createInstance(ObjectList* obj, uint16_t instId);
static ObjectInstList* getInstance(ObjectList* obj, uint16_t instId);
static int32_t connectObj(UAVObjHandle obj, xQueueHandle queue, UAVObjEventCallback cb, int32_t eventMask);
static int32_t disconnectObj(UAVObjHandle obj, xQueueHandle queue, UAVObjEventCallback cb);
#if defined(PIOS_USE_SDCARD)
static void objectFilename(ObjectList* obj, uint8_t* filename);
static void customSPrintf(uint8_t* buffer, uint8_t* format, ...);
#endif
// Private variables
static ObjectList* objList;
@ -511,6 +514,7 @@ int32_t UAVObjPack(UAVObjHandle obj, uint16_t instId, uint8_t* dataOut)
*/
int32_t UAVObjSaveToFile(UAVObjHandle obj, uint16_t instId, FILEINFO* file)
{
#if defined(PIOS_USE_SDCARD)
uint32_t bytesWritten;
ObjectList* objEntry;
ObjectInstList* instEntry;
@ -554,6 +558,7 @@ int32_t UAVObjSaveToFile(UAVObjHandle obj, uint16_t instId, FILEINFO* file)
// Done
xSemaphoreGiveRecursive(mutex);
#endif /* PIOS_USE_SDCARD */
return 0;
}
@ -569,6 +574,7 @@ int32_t UAVObjSaveToFile(UAVObjHandle obj, uint16_t instId, FILEINFO* file)
*/
int32_t UAVObjSave(UAVObjHandle obj, uint16_t instId)
{
#if defined(PIOS_USE_SDCARD)
FILEINFO file;
ObjectList* objEntry;
uint8_t filename[14];
@ -606,6 +612,7 @@ int32_t UAVObjSave(UAVObjHandle obj, uint16_t instId)
// Done, close file and unlock
PIOS_FCLOSE(file);
xSemaphoreGiveRecursive(mutex);
#endif /* PIOS_USD_SDCARD */
return 0;
}
@ -616,6 +623,7 @@ int32_t UAVObjSave(UAVObjHandle obj, uint16_t instId)
*/
UAVObjHandle UAVObjLoadFromFile(FILEINFO* file)
{
#if defined(PIOS_INCLUDE_SDCARD)
uint32_t bytesRead;
ObjectList* objEntry;
ObjectInstList* instEntry;
@ -687,6 +695,9 @@ UAVObjHandle UAVObjLoadFromFile(FILEINFO* file)
// Unlock
xSemaphoreGiveRecursive(mutex);
return obj;
#else
return NULL;
#endif
}
/**
@ -699,6 +710,7 @@ UAVObjHandle UAVObjLoadFromFile(FILEINFO* file)
*/
int32_t UAVObjLoad(UAVObjHandle obj, uint16_t instId)
{
#if defined(PIOS_INCLUDE_SDCARD)
FILEINFO file;
ObjectList* objEntry;
UAVObjHandle loadedObj;
@ -748,6 +760,7 @@ int32_t UAVObjLoad(UAVObjHandle obj, uint16_t instId)
// Done, close file and unlock
PIOS_FCLOSE(file);
xSemaphoreGiveRecursive(mutex);
#endif /* PIOS_USE_SDCARD */
return 0;
}
@ -759,6 +772,7 @@ int32_t UAVObjLoad(UAVObjHandle obj, uint16_t instId)
*/
int32_t UAVObjDelete(UAVObjHandle obj, uint16_t instId)
{
#if defined(PIOS_USE_SDCARD)
ObjectList* objEntry;
uint8_t filename[14];
@ -782,6 +796,7 @@ int32_t UAVObjDelete(UAVObjHandle obj, uint16_t instId)
// Done
xSemaphoreGiveRecursive(mutex);
#endif /* PIOS_USD_SDCARD */
return 0;
}
@ -1472,6 +1487,7 @@ static int32_t disconnectObj(UAVObjHandle obj, xQueueHandle queue, UAVObjEventCa
return -1;
}
#if defined(PIOS_USE_SDCARD)
/**
* Wrapper for the sprintf function
*/
@ -1489,6 +1505,7 @@ static void objectFilename(ObjectList* obj, uint8_t* filename)
{
customSPrintf(filename, (uint8_t*)"%X.obj", obj->id);
}
#endif /* PIOS_USD_SDCARD */