diff options
| author | Shlomo Hecht <shlomo@twine-s.com> | 2019-01-24 08:41:39 +0200 |
|---|---|---|
| committer | Shlomo Hecht <shlomo@twine-s.com> | 2019-01-24 08:41:39 +0200 |
| commit | 91d4a6eceb00882a0898016e743130d62156e33b (patch) | |
| tree | 65afc01dc073db62daf7aae7c06f02508039fe55 /Software/Embedded_SW/Embedded/Common/SWUpdate/FileSystem.c | |
| parent | fcf4662cdd456796d0572b6bc4e27769bae8e45a (diff) | |
| download | Tango-91d4a6eceb00882a0898016e743130d62156e33b.tar.gz Tango-91d4a6eceb00882a0898016e743130d62156e33b.zip | |
1.3.5.0 changes
====================================
1. preparations for keeping data in internal flash
2. keep applicative data in external flash: software parameters, dispensers data, etc.
3. moved to new alarms definitions, tamper alarms, improved temperature alarms, cone presence alarm,
4. support for Machine Studio 4
5. some tests for memory allocations
6. thread load proto code
7. Hardware: doors tampering switches, drier fan, blower PWM control, new backplane support, new motor drivers support,
8. FPGA jtag code loading
9. Heaters: alarms on set temperature band. test facilities.
10. motors - additional complex actions for thread load support. new drivers support
11. preparations for control debugging
12. read motor status and mid tank level
13. collect and store dispenser usage data
14. IDS - controlled operation of motor and valve. backlash movement after refill
15. bug fixes in job handling
Diffstat (limited to 'Software/Embedded_SW/Embedded/Common/SWUpdate/FileSystem.c')
| -rw-r--r-- | Software/Embedded_SW/Embedded/Common/SWUpdate/FileSystem.c | 100 |
1 files changed, 96 insertions, 4 deletions
diff --git a/Software/Embedded_SW/Embedded/Common/SWUpdate/FileSystem.c b/Software/Embedded_SW/Embedded/Common/SWUpdate/FileSystem.c index 0b19f2454..3d4404f99 100644 --- a/Software/Embedded_SW/Embedded/Common/SWUpdate/FileSystem.c +++ b/Software/Embedded_SW/Embedded/Common/SWUpdate/FileSystem.c @@ -76,7 +76,7 @@ uint32_t FileUploadRequestFunc(MessageContainer* requestContainer) FileUploadResponse response = FILE_UPLOAD_RESPONSE__INIT; WrittenBytes=0; - FileHandle = malloc(sizeof(FIL)); + FileHandle = my_malloc(sizeof(FIL)); if (FileHandle == 0) Fresult = FR_DENIED; else @@ -245,7 +245,7 @@ uint32_t CreateRequestFunc(MessageContainer* requestContainer) } else { - FileHandle = malloc(sizeof(FIL)); + FileHandle = my_malloc(sizeof(FIL)); if (FileHandle == 0) Fresult = FR_DENIED; else @@ -516,7 +516,7 @@ uint32_t FileDownloadRequestFunc(MessageContainer* requestContainer) FileDownloadResponse response = FILE_DOWNLOAD_RESPONSE__INIT; WrittenBytes=0; - FileHandle = malloc(sizeof(FIL)); + FileHandle = my_malloc(sizeof(FIL)); if (FileHandle == 0) Fresult = FR_DENIED; else @@ -558,7 +558,7 @@ uint32_t FileChunkDownloadRequestFunc(MessageContainer* requestContainer) ReceivedFileHandle = FileHandle; char *Buffer = 0; - Buffer = malloc (2000); + Buffer = my_malloc (2000); if (Buffer != NULL) { Fresult = f_read(ReceivedFileHandle,response.buffer.data,2000,&WrittenBytes ); @@ -604,3 +604,95 @@ uint32_t FileChunkDownloadRequestFunc(MessageContainer* requestContainer) return OK; } +FRESULT FileWrite(void * buffer, uint16_t size,char *path) +{ + FRESULT Fresult = FR_OK; + FIL *FileHandle = 0; //the system supports a single active file + uint32_t Bytes = 0; + + if (buffer) + { + FileHandle = my_malloc(sizeof(FIL)); + if (FileHandle == 0) + Fresult = FR_DENIED; + else + { + Fresult = f_open(FileHandle,path,FA_WRITE | FA_OPEN_ALWAYS); + if (Fresult == FR_OK) + { + Fresult = f_write(FileHandle,buffer,size,&Bytes ); + if(Fresult != FR_OK) + { + LOG_ERROR (Fresult,"fread error"); + } + f_close(FileHandle); + } + else + { + LOG_ERROR (Fresult,"fopen error"); + } + my_free(FileHandle); + } + } + return Fresult; +} +FRESULT FileRead(char *path, uint32_t *Size, void **Buffer) +{ + FRESULT Fresult = FR_OK; + FIL *FileHandle = 0; //the system supports a single active file + FILINFO* fno = 0; + void* buffer = NULL; + uint32_t Bytes = 0; + uint32_t status = 0; + + fno = my_malloc(sizeof(FILINFO)); + if (fno == 0) + return ERROR; + memset (fno,0,sizeof(FILINFO)); + Fresult = f_stat(path,fno); + if (Fresult == FR_OK) + { + buffer = my_malloc (fno->fsize); + if (buffer) + { + FileHandle = my_malloc(sizeof(FIL)); + if (FileHandle == 0) + Fresult = FR_DENIED; + else + { + Fresult = f_open(FileHandle,path,FA_READ); + if (Fresult == FR_OK) + { + Fresult = f_read(FileHandle,buffer,fno->fsize,&Bytes ); + if(Fresult == FR_OK) + { + *Buffer = buffer; + *Size = (uint32_t)fno->fsize; + } + else + { + LOG_ERROR (Fresult,"fread error"); + my_free (buffer); + } + f_close(FileHandle); + } + else + { + LOG_ERROR (Fresult,"fopen error"); + my_free (buffer); + } + my_free(FileHandle); + } + } + else + { + LOG_ERROR (Fresult,"malloc error"); + } + } + else + { + LOG_ERROR (Fresult,"f_stat error"); + } + my_free(fno); + return Fresult; +} |
