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.c35
1 files changed, 23 insertions, 12 deletions
diff --git a/Software/Embedded_SW/Embedded/Common/SWUpdate/FileSystem.c b/Software/Embedded_SW/Embedded/Common/SWUpdate/FileSystem.c
index 8aabafd2e..1ba656657 100644
--- a/Software/Embedded_SW/Embedded/Common/SWUpdate/FileSystem.c
+++ b/Software/Embedded_SW/Embedded/Common/SWUpdate/FileSystem.c
@@ -100,7 +100,7 @@ uint32_t FileUploadRequestFunc(MessageContainer* requestContainer)
if (Semaphore_pend(FFS_Sem, BIOS_NO_WAIT))
{
CommRxTaskHandle = Task_self();
- Task_setPri(CommRxTaskHandle, 3);
+ Task_setPri(CommRxTaskHandle, 2);
// Report("Task_setPri", __FILE__, __LINE__, 4, RpWarning, (int)CommRxTaskHandle, 0);
//Report("FileUploadRequestFunc 2", __FILE__, __LINE__, msec_millisecondCounter, RpWarning, (int)0, 0);
Fresult = f_open(UploadFileHandle,request->path,FA_READ | FA_WRITE | FA_OPEN_ALWAYS | FA_CREATE_ALWAYS);
@@ -280,16 +280,22 @@ 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)
+ if (Semaphore_pend(FFS_Sem, BIOS_NO_WAIT))
{
- response.has_maxchunklength = true;
- response.maxchunklength = MAX_CHUNK_LENGTH;
- strcpy(FileHandleChar, "1234");
- response.downloadid = FileHandleChar; //supporting only single file at each time.
+ Fresult = f_open(DownloadFileHandle,request->filename,FA_READ );
+ if (Fresult == FR_OK)
+ {
+ response.has_maxchunklength = true;
+ response.maxchunklength = MAX_CHUNK_LENGTH;
+ strcpy(FileHandleChar, "1234");
+ response.downloadid = FileHandleChar; //supporting only single file at each time.
+ Report("data request", __FILE__, 1234, MAX_CHUNK_LENGTH, RpWarning, (int)fno->fsize, 0);
+ }
+ else
+ {
+ Semaphore_post(FFS_Sem);
+ }
}
-
}
}
@@ -323,10 +329,11 @@ uint32_t FileChunkDownloadRequestFunc(MessageContainer* requestContainer)
Buffer = my_malloc (MAX_CHUNK_LENGTH);
if (Buffer != NULL)
{
- Fresult = f_read(SentFileHandle,Buffer,2000,&ReadBytes );
+ Fresult = f_read(SentFileHandle,Buffer,MAX_CHUNK_LENGTH,&ReadBytes );
if(Fresult != FR_OK)
{
- LOG_ERROR (Fresult,"f_write error");
+ LOG_ERROR (Fresult,"f_read error");
+ Semaphore_post(FFS_Sem);
}
else
{
@@ -334,6 +341,7 @@ uint32_t FileChunkDownloadRequestFunc(MessageContainer* requestContainer)
response.buffer.len = ReadBytes;
response.buffer.data = Buffer;
FileSentLength += ReadBytes;
+ Report("sending data to MS", __FILE__, ReadBytes, FileSentLength, RpWarning, (int)FileLength, 0);
if (FileSentLength == FileLength)
{
REPORT_MSG (FileSentLength,"file download ended successfully");
@@ -715,8 +723,10 @@ FRESULT FileWrite(void * buffer, uint16_t size,char *path, uint32_t timeout)
Fresult = f_write(FileHandle,buffer,size,&Bytes );
if(Fresult != FR_OK)
{
- LOG_ERROR (Fresult,"fread error");
+ LOG_ERROR (Fresult,"fwrite error");
}
+ //LOG_ERROR (Bytes,"f_write ok no of bytes");
+ Report("f_write ok no of bytes", __FILE__, __LINE__, Bytes, RpWarning, (int)size, 0);
f_close(FileHandle);
}
else
@@ -762,6 +772,7 @@ FRESULT FileRead(char *path, uint32_t *Size, void **Buffer)
{
*Buffer = buffer;
*Size = (uint32_t)fno->fsize;
+ Report("f_read ok no of bytes", __FILE__, __LINE__, Bytes, RpWarning, (int)fno->fsize, 0);
}
else
{