aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Embedded_SW/Embedded/Common/SWUpdate/FileSystem.c
diff options
context:
space:
mode:
Diffstat (limited to 'Software/Embedded_SW/Embedded/Common/SWUpdate/FileSystem.c')
-rw-r--r--Software/Embedded_SW/Embedded/Common/SWUpdate/FileSystem.c20
1 files changed, 20 insertions, 0 deletions
diff --git a/Software/Embedded_SW/Embedded/Common/SWUpdate/FileSystem.c b/Software/Embedded_SW/Embedded/Common/SWUpdate/FileSystem.c
index 1e02283e0..f4c52f000 100644
--- a/Software/Embedded_SW/Embedded/Common/SWUpdate/FileSystem.c
+++ b/Software/Embedded_SW/Embedded/Common/SWUpdate/FileSystem.c
@@ -62,6 +62,7 @@ uint32_t WrittenBytes = 0;
uint32_t ReadBytes = 0;
Task_Handle CommRxTaskHandle;
+extern Semaphore_Handle FFS_Sem;
ErrorCode getErrorCode(FRESULT Fresult)
{
@@ -97,6 +98,7 @@ uint32_t FileUploadRequestFunc(MessageContainer* requestContainer)
Fresult = FR_DENIED;
else
{
+ Semaphore_pend(FFS_Sem, BIOS_WAIT_FOREVER);
Fresult = f_open(UploadFileHandle,request->path,FA_READ | FA_WRITE | FA_OPEN_ALWAYS | FA_CREATE_ALWAYS);
if (Fresult == FR_OK)
{
@@ -113,6 +115,7 @@ uint32_t FileUploadRequestFunc(MessageContainer* requestContainer)
{
my_free (UploadFileHandle);
UploadFileHandle = 0;
+ Semaphore_post(FFS_Sem);
}
}
@@ -219,6 +222,7 @@ uint32_t FileChunkUploadRequestFunc(MessageContainer* requestContainer)
{
Task_setPri(CommRxTaskHandle, 9);
GeneralHwReady = true;
+ Semaphore_post(FFS_Sem);
//Report("Task_setPri", __FILE__, __LINE__, 9, RpWarning, (int)CommRxTaskHandle, 0);
}
return OK;
@@ -252,6 +256,7 @@ uint32_t FileDownloadRequestFunc(MessageContainer* requestContainer)
Fresult = FR_DENIED;
else
{
+ Semaphore_pend(FFS_Sem, BIOS_WAIT_FOREVER);
Fresult = f_open(DownloadFileHandle,request->filename,FA_READ );
if (Fresult == FR_OK)
{
@@ -309,6 +314,7 @@ uint32_t FileChunkDownloadRequestFunc(MessageContainer* requestContainer)
{
REPORT_MSG (FileSentLength,"file download ended successfully");
f_close(SentFileHandle);
+ Semaphore_post(FFS_Sem);
my_free (DownloadFileHandle);
FileSentLength = 0;
}
@@ -318,6 +324,7 @@ uint32_t FileChunkDownloadRequestFunc(MessageContainer* requestContainer)
{
REPORT_MSG (FileSentLength,"file download too much data!");
f_close(SentFileHandle);
+ Semaphore_post(FFS_Sem);
my_free (DownloadFileHandle);
FileSentLength = 0;
}
@@ -414,6 +421,7 @@ uint32_t CreateRequestFunc(MessageContainer* requestContainer)
Fresult = FR_DENIED;
else
{
+ Semaphore_pend(FFS_Sem, BIOS_WAIT_FOREVER);
Fresult = f_open(UploadFileHandle,request->path,FA_CREATE_NEW);
if (Fresult == FR_OK)
{
@@ -422,6 +430,7 @@ uint32_t CreateRequestFunc(MessageContainer* requestContainer)
Fresult = FR_LOCKED;
}
}
+ Semaphore_post(FFS_Sem);
}
}
if (Fresult != FR_OK)
@@ -461,7 +470,9 @@ uint32_t DeleteRequestFunc(MessageContainer* requestContainer)
//int NumOfFiles = 0;
FRESULT Fresult = FR_OK;
+ Semaphore_pend(FFS_Sem, BIOS_WAIT_FOREVER);
Fresult = f_unlink(request->path);
+ Semaphore_post(FFS_Sem);
REPORT_MSG(Fresult, "File Delete");
responseContainer = createContainer(MESSAGE_TYPE__DeleteResponse, requestContainer->token, false, &response, &delete_response__pack, &delete_response__get_packed_size);
@@ -543,9 +554,11 @@ uint32_t GetFilesRequestFunc(MessageContainer* requestContainer)
int i,NumOfFiles = 0;
FRESULT Fresult = FR_OK;
+ Semaphore_pend(FFS_Sem, BIOS_WAIT_FOREVER);
Fresult |= f_opendir(&dir, g_cCwdBuf);
if(Fresult != FR_OK)
{
+ Semaphore_post(FFS_Sem);
return(Fresult);
}
@@ -574,6 +587,7 @@ uint32_t GetFilesRequestFunc(MessageContainer* requestContainer)
}
}
}
+ Semaphore_post(FFS_Sem);
if ((Fresult == FR_OK)&&(NumOfFiles))
{
@@ -643,6 +657,8 @@ FRESULT FileWrite(void * buffer, uint16_t size,char *path)
Fresult = FR_DENIED;
else
{
+ Semaphore_pend(FFS_Sem, BIOS_WAIT_FOREVER);
+
Fresult = f_open(FileHandle,path,FA_WRITE | FA_OPEN_ALWAYS);
if (Fresult == FR_OK)
{
@@ -657,6 +673,7 @@ FRESULT FileWrite(void * buffer, uint16_t size,char *path)
{
LOG_ERROR (Fresult,"fopen error");
}
+ Semaphore_post(FFS_Sem);
my_free(FileHandle);
}
}
@@ -686,6 +703,7 @@ FRESULT FileRead(char *path, uint32_t *Size, void **Buffer)
Fresult = FR_DENIED;
else
{
+ Semaphore_pend(FFS_Sem, BIOS_WAIT_FOREVER);
Fresult = f_open(FileHandle,path,FA_READ);
if (Fresult == FR_OK)
{
@@ -701,6 +719,7 @@ FRESULT FileRead(char *path, uint32_t *Size, void **Buffer)
my_free (buffer);
}
f_close(FileHandle);
+ Semaphore_post(FFS_Sem);
}
else
{
@@ -739,6 +758,7 @@ FRESULT FileOpen(char *path, uint32_t *Size, FIL *FileHandle)
if (FileHandle == 0)
Fresult = FR_DENIED;
else
+ Semaphore_pend(FFS_Sem, BIOS_WAIT_FOREVER);
Fresult = f_open(FileHandle,path,FA_READ);
}
else