From c72eff42c5aec18513b3ec9d92486ec02a6a716b Mon Sep 17 00:00:00 2001 From: Shlomo Hecht Date: Sun, 3 Feb 2019 08:54:15 +0200 Subject: file names short form --- .../Embedded/Common/SWUpdate/FileSystem.c | 55 ++++++++++++---------- 1 file changed, 30 insertions(+), 25 deletions(-) (limited to 'Software/Embedded_SW/Embedded/Common/SWUpdate/FileSystem.c') diff --git a/Software/Embedded_SW/Embedded/Common/SWUpdate/FileSystem.c b/Software/Embedded_SW/Embedded/Common/SWUpdate/FileSystem.c index dc9bac054..ce36f57e6 100644 --- a/Software/Embedded_SW/Embedded/Common/SWUpdate/FileSystem.c +++ b/Software/Embedded_SW/Embedded/Common/SWUpdate/FileSystem.c @@ -91,6 +91,11 @@ uint32_t FileUploadRequestFunc(MessageContainer* requestContainer) strcpy(FileHandleChar, "1234"); response.uploadid = FileHandleChar; //supporting only single file at each time. } + else + { + free (FileHandle); + FileHandle = 0; + } } @@ -382,6 +387,7 @@ uint32_t GetStorageInfoRequestFunc(MessageContainer* requestContainer) response.capacity = tot_sect/2; response.has_freespace = true; response.freespace = fre_sect/2; + response.root = "0:"; } @@ -413,6 +419,7 @@ uint32_t GetFilesRequestFunc(MessageContainer* requestContainer) #define MAX_NUM_OF_FILES 10 DIR dir; FILINFO* fno[MAX_NUM_OF_FILES]; + char FullPath[MAX_NUM_OF_FILES][50]; int i,NumOfFiles = 0; FRESULT Fresult = FR_OK; @@ -429,36 +436,24 @@ uint32_t GetFilesRequestFunc(MessageContainer* requestContainer) fno[0] = my_malloc(sizeof(FILINFO)); memset (fno[0],0,sizeof(FILINFO)); - Fresult = f_stat(request->path,fno[0]); - if (Fresult == FR_OK) - { - if (isDirectory(fno[0]->fattrib)) - { - NumOfFiles++; - //============================ - Fresult = f_opendir(&dir, request->path); /* Open the directory */ + //============================ + Fresult = f_opendir(&dir, request->path); /* Open the directory */ + if (Fresult == FR_OK) + { + for (NumOfFiles = 1;NumOfFiles < MAX_NUM_OF_FILES;NumOfFiles++) + { + fno[NumOfFiles] = my_malloc(sizeof(FILINFO)); + memset (fno[NumOfFiles],0,sizeof(FILINFO)); + Fresult = f_readdir(&dir, fno[NumOfFiles]); /* Read a directory item */ if (Fresult == FR_OK) { - for (NumOfFiles = 1;NumOfFiles < MAX_NUM_OF_FILES;NumOfFiles++) + if(fno[NumOfFiles]->fname[0] ==0) { - fno[NumOfFiles] = my_malloc(sizeof(FILINFO)); - memset (fno[NumOfFiles],0,sizeof(FILINFO)); - Fresult = f_readdir(&dir, fno[NumOfFiles]); /* Read a directory item */ - if (Fresult == FR_OK) - { - if(fno[NumOfFiles]->fname[0] ==0) - { - break; - } - } + break; } } - } - else - { - Fresult = FR_DENIED; - } - } + } + } if ((Fresult == FR_OK)&&(NumOfFiles)) { @@ -474,6 +469,16 @@ uint32_t GetFilesRequestFunc(MessageContainer* requestContainer) Data[i].length = fno[i]->fsize; Data[i].lastmodifieddate = fno[i]->fdate; Data[i].lastmodifiedtime = fno[i]->ftime; + //strcpy(FullPath[i],request->path); + //strcat(FullPath[i],'\\'); + //strcat(FullPath[i],&fno[i]->fname); + //sprintf (FullPath[i], "%s/%s", request->path, &fno[i]->fname); + if (i==0) + usnprintf(&FullPath[i], 50, "%s", request->path); + else + usnprintf(&FullPath[i], 50, "%s%c%c%s", request->path,'\\','\\'/*"/"*/, fno[i]->fname); + Data[i].fullpath = &FullPath[i]; + } response.n_items = NumOfFiles; response.items = FilesInfo; -- cgit v1.3.1 From 0a1c6b4b11e09c25387782f6dd9498c67bb3bff9 Mon Sep 17 00:00:00 2001 From: Shlomo Hecht Date: Sun, 3 Feb 2019 13:00:47 +0200 Subject: file system improvement --- .../Embedded/Common/SWUpdate/FileSystem.c | 91 ++++++++++++++-------- .../Embedded_SW/Embedded/Communication/Container.c | 6 ++ .../Embedded/Drivers/FPGA/FPGA_GPIO/FPGA_GPIO.c | 9 +-- .../Embedded/Drivers/FPGA/FPGA_GPIO/FPGA_GPIO.h | 6 +- 4 files changed, 68 insertions(+), 44 deletions(-) (limited to 'Software/Embedded_SW/Embedded/Common/SWUpdate/FileSystem.c') diff --git a/Software/Embedded_SW/Embedded/Common/SWUpdate/FileSystem.c b/Software/Embedded_SW/Embedded/Common/SWUpdate/FileSystem.c index ce36f57e6..6c7ee97a4 100644 --- a/Software/Embedded_SW/Embedded/Common/SWUpdate/FileSystem.c +++ b/Software/Embedded_SW/Embedded/Common/SWUpdate/FileSystem.c @@ -44,7 +44,8 @@ ErrorCode FileError_to_ErrorCode[FR_INVALID_PARAMETER+1] = {ERROR_CODE__NONE,ERR ERROR_CODE__FILE_REQUEST_INVALID_PARAMETER}; -FIL *FileHandle = 0; //the system supports a single active file +FIL *UploadFileHandle = 0; //the system supports a single active file +FIL *DownloadFileHandle = 0; //the system supports a single active file char FileHandleChar[5]; char ErrorMsg[100]; #define MAX_CHUNK_LENGTH 2000 @@ -77,12 +78,12 @@ uint32_t FileUploadRequestFunc(MessageContainer* requestContainer) FileUploadResponse response = FILE_UPLOAD_RESPONSE__INIT; WrittenBytes=0; - FileHandle = my_malloc(sizeof(FIL)); - if (FileHandle == 0) + UploadFileHandle = my_malloc(sizeof(FIL)); + if (UploadFileHandle == 0) Fresult = FR_DENIED; else { - Fresult = f_open(FileHandle,request->path,FA_READ | FA_WRITE | FA_OPEN_ALWAYS ); + Fresult = f_open(UploadFileHandle,request->path,FA_READ | FA_WRITE | FA_OPEN_ALWAYS ); if (Fresult == FR_OK) { FileLength = request->length; @@ -93,8 +94,8 @@ uint32_t FileUploadRequestFunc(MessageContainer* requestContainer) } else { - free (FileHandle); - FileHandle = 0; + free (UploadFileHandle); + UploadFileHandle = 0; } } @@ -131,7 +132,7 @@ uint32_t FileChunkUploadRequestFunc(MessageContainer* requestContainer) FIL *ReceivedFileHandle; //the system supports a single active file // if (request->uploadid == 1) - ReceivedFileHandle = FileHandle; + ReceivedFileHandle = UploadFileHandle; // memcpy (&ReceivedFileHandle,request->uploadid,sizeof(ReceivedFileHandle)); //if (ReceivedFileHandle == FileHandle) //{ @@ -147,7 +148,8 @@ uint32_t FileChunkUploadRequestFunc(MessageContainer* requestContainer) { REPORT_MSG (FileReceivedLength,"file upload ended successfully"); f_close(ReceivedFileHandle); - free (FileHandle); + free (UploadFileHandle); + FileReceivedLength = 0; } else { @@ -155,7 +157,8 @@ uint32_t FileChunkUploadRequestFunc(MessageContainer* requestContainer) { REPORT_MSG (FileReceivedLength,"file upload too much data!"); f_close(ReceivedFileHandle); - free (FileHandle); + free (UploadFileHandle); + FileReceivedLength = 0; } } } @@ -251,15 +254,15 @@ uint32_t CreateRequestFunc(MessageContainer* requestContainer) } else { - FileHandle = my_malloc(sizeof(FIL)); - if (FileHandle == 0) + UploadFileHandle = my_malloc(sizeof(FIL)); + if (UploadFileHandle == 0) Fresult = FR_DENIED; else { - Fresult = f_open(FileHandle,request->path,FA_CREATE_NEW); + Fresult = f_open(UploadFileHandle,request->path,FA_CREATE_NEW); if (Fresult == FR_OK) { - if (f_close (FileHandle)!= FR_OK) + if (f_close (UploadFileHandle)!= FR_OK) { Fresult = FR_LOCKED; } @@ -272,7 +275,7 @@ uint32_t CreateRequestFunc(MessageContainer* requestContainer) usnprintf(ErrorMsg, 100, "File Operation failed error code %d",Fresult); } - free (FileHandle); + free (UploadFileHandle); responseContainer = createContainer(MESSAGE_TYPE__CreateResponse, requestContainer->token, false, &response, &create_response__pack, &create_response__get_packed_size); if (Fresult!= OK) @@ -304,7 +307,7 @@ uint32_t DeleteRequestFunc(MessageContainer* requestContainer) //int NumOfFiles = 0; FRESULT Fresult = FR_OK; - Fresult |= f_opendir(&dir, g_cCwdBuf); + /*Fresult |= f_opendir(&dir, g_cCwdBuf); if(Fresult != FR_OK) { LOG_ERROR (Fresult,"f_write error"); @@ -320,10 +323,10 @@ uint32_t DeleteRequestFunc(MessageContainer* requestContainer) if (isDirectory(fno->fattrib)) { //============================ - Fresult = f_opendir(&dir, request->path); /* Open the directory */ + Fresult = f_opendir(&dir, request->path); if (Fresult == FR_OK) { - Fresult = f_readdir(&dir, &fno); /* Read a directory item */ + Fresult = f_readdir(&dir, &fno); if (Fresult == FR_OK) { if(fno->fname[0] ==0) @@ -343,7 +346,9 @@ uint32_t DeleteRequestFunc(MessageContainer* requestContainer) Fresult = f_unlink(request->path); } } - } + }*/ + Fresult = f_unlink(request->path); + responseContainer = createContainer(MESSAGE_TYPE__DeleteResponse, requestContainer->token, false, &response, &delete_response__pack, &delete_response__get_packed_size); if (Fresult!= OK) { @@ -387,7 +392,7 @@ uint32_t GetStorageInfoRequestFunc(MessageContainer* requestContainer) response.capacity = tot_sect/2; response.has_freespace = true; response.freespace = fre_sect/2; - response.root = "0:"; + response.root = "/"; } @@ -476,7 +481,10 @@ uint32_t GetFilesRequestFunc(MessageContainer* requestContainer) if (i==0) usnprintf(&FullPath[i], 50, "%s", request->path); else - usnprintf(&FullPath[i], 50, "%s%c%c%s", request->path,'\\','\\'/*"/"*/, fno[i]->fname); + if (strlen(request->path)==1) //info under the root + usnprintf(&FullPath[i], 50, "%s%s", request->path, fno[i]->fname); + else + usnprintf(&FullPath[i], 50, "%s%s%s", request->path,"/", fno[i]->fname); Data[i].fullpath = &FullPath[i]; } @@ -514,6 +522,7 @@ uint32_t FileDownloadRequestFunc(MessageContainer* requestContainer) //uint32_t status = OK; FRESULT Fresult = FR_OK; + FILINFO* fno; MessageContainer responseContainer; @@ -522,20 +531,31 @@ uint32_t FileDownloadRequestFunc(MessageContainer* requestContainer) FileDownloadResponse response = FILE_DOWNLOAD_RESPONSE__INIT; WrittenBytes=0; - FileHandle = my_malloc(sizeof(FIL)); - if (FileHandle == 0) + FileReceivedLength = 0; + + fno = my_malloc(sizeof(FILINFO)); + if (fno == 0) Fresult = FR_DENIED; else { - Fresult = f_open(FileHandle,request->filename,FA_READ ); - if (Fresult == FR_OK) + memset (fno,0,sizeof(FILINFO)); + Fresult = f_stat(request->filename,fno); + FileLength = fno->fsize; + DownloadFileHandle = my_malloc(sizeof(FIL)); + if (DownloadFileHandle == 0) + Fresult = FR_DENIED; + else { - 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. + } + } } @@ -562,12 +582,12 @@ uint32_t FileChunkDownloadRequestFunc(MessageContainer* requestContainer) FRESULT Fresult = FR_OK; FIL *ReceivedFileHandle; //the system supports a single active file - ReceivedFileHandle = FileHandle; + ReceivedFileHandle = DownloadFileHandle; char *Buffer = 0; - Buffer = my_malloc (2000); + Buffer = my_malloc (MAX_CHUNK_LENGTH); if (Buffer != NULL) { - Fresult = f_read(ReceivedFileHandle,response.buffer.data,2000,&WrittenBytes ); + Fresult = f_read(ReceivedFileHandle,Buffer,2000,&WrittenBytes ); if(Fresult != FR_OK) { LOG_ERROR (Fresult,"f_write error"); @@ -575,12 +595,14 @@ uint32_t FileChunkDownloadRequestFunc(MessageContainer* requestContainer) else { response.buffer.len = WrittenBytes; + response.buffer.data = Buffer; FileReceivedLength += WrittenBytes; if (FileReceivedLength == FileLength) { REPORT_MSG (FileReceivedLength,"file download ended successfully"); f_close(ReceivedFileHandle); - free (FileHandle); + free (DownloadFileHandle); + FileReceivedLength = 0; } else { @@ -588,7 +610,8 @@ uint32_t FileChunkDownloadRequestFunc(MessageContainer* requestContainer) { REPORT_MSG (FileReceivedLength,"file download too much data!"); f_close(ReceivedFileHandle); - free (FileHandle); + free (DownloadFileHandle); + FileReceivedLength = 0; } } } diff --git a/Software/Embedded_SW/Embedded/Communication/Container.c b/Software/Embedded_SW/Embedded/Communication/Container.c index ba1f8eea9..bb6b82743 100644 --- a/Software/Embedded_SW/Embedded/Communication/Container.c +++ b/Software/Embedded_SW/Embedded/Communication/Container.c @@ -383,6 +383,12 @@ void receive_callback(char* buffer, size_t length) case MESSAGE_TYPE__FileChunkUploadRequest: FileChunkUploadRequestFunc(requestContainer); break; + case MESSAGE_TYPE__FileDownloadRequest: + FileDownloadRequestFunc(requestContainer); + break; + case MESSAGE_TYPE__FileChunkDownloadRequest: + FileChunkDownloadRequestFunc(requestContainer); + break; case MESSAGE_TYPE__ExecuteProcessRequest: ExecuteProcessRequestFunc(requestContainer); break; diff --git a/Software/Embedded_SW/Embedded/Drivers/FPGA/FPGA_GPIO/FPGA_GPIO.c b/Software/Embedded_SW/Embedded/Drivers/FPGA/FPGA_GPIO/FPGA_GPIO.c index 51b00c235..68c721368 100644 --- a/Software/Embedded_SW/Embedded/Drivers/FPGA/FPGA_GPIO/FPGA_GPIO.c +++ b/Software/Embedded_SW/Embedded/Drivers/FPGA/FPGA_GPIO/FPGA_GPIO.c @@ -545,17 +545,12 @@ void WHS_Read_GPI_Registers() F3_GPI_01_Reg.ushort = F3_GPI_01_D; } -//bool WHS_GET_GPI_AIRFLOW_FLAP() -//{ -// return F2_GPI_Reg.bits.F2_GPI_AIRFLOW_FLAP; -//} - bool WHS_GPI_CHILLER_FAULT() { return F2_GPI_Reg.bits.F2_GPI_CHILLER_FAULT; } -bool Waste_OverFull() +bool WHS_GPI_WASTE_OVERFULL() { return F2_GPI_Reg.bits.F2_WASTE_OVERFULL_NO; } @@ -575,7 +570,7 @@ bool WHS_GPI_WCONTAINER_WARN() return F3_GPI_01_Reg.bits.F3_GPI_WCONTAINER_WARN; } -bool Waste_Flow_Switch() +bool WHS_GPI_WASTE_FLOW_SWITCH() { return F2_GPI_Reg.bits.F2_WASTE_FLOW_SW_NO; } diff --git a/Software/Embedded_SW/Embedded/Drivers/FPGA/FPGA_GPIO/FPGA_GPIO.h b/Software/Embedded_SW/Embedded/Drivers/FPGA/FPGA_GPIO/FPGA_GPIO.h index 47dc04bb5..1bb5ab6ce 100644 --- a/Software/Embedded_SW/Embedded/Drivers/FPGA/FPGA_GPIO/FPGA_GPIO.h +++ b/Software/Embedded_SW/Embedded/Drivers/FPGA/FPGA_GPIO/FPGA_GPIO.h @@ -202,10 +202,10 @@ uint32_t DeActivateAllSSR(); uint32_t ReadBreakSensor(); void WHS_Read_GPI_Registers(); -bool WHS_GET_GPI_AIRFLOW_FLAP(); bool WHS_GPI_CHILLER_FAULT(); -bool Waste_OverFull(); -bool Waste_Flow_Switch(); +bool WHS_GPI_CHILLER_STAT1(); +bool WHS_GPI_WASTE_FLOW_SWITCH(); +bool WHS_GPI_WASTE_OVERFULL(); bool WHS_GPI_SW_FILTER_PRES(); bool WHS_GPI_WCONTAINER_FULL(); bool WHS_GPI_WCONTAINER_WARN(); -- cgit v1.3.1 From ec8a06ff2b7dbf10fa6aebb25b1ed5be18faed80 Mon Sep 17 00:00:00 2001 From: Shlomo Hecht Date: Sun, 3 Feb 2019 21:16:59 +0200 Subject: blower gradual increase, stop/release motrs lock, file system fixes --- .../Embedded/Common/SWUpdate/FileSystem.c | 238 +++++++++++---------- .../Embedded/Drivers/FPGA/FPGA_SPI_Comm.c | 9 + .../Drivers/I2C_Communication/DAC/Blower.c | 55 +++++ .../Drivers/I2C_Communication/DAC/Blower.h | 2 +- .../Embedded/Modules/Heaters/Heaters_print.c | 4 +- .../Embedded/Software Release Notes.txt | 11 + 6 files changed, 199 insertions(+), 120 deletions(-) create mode 100644 Software/Embedded_SW/Embedded/Software Release Notes.txt (limited to 'Software/Embedded_SW/Embedded/Common/SWUpdate/FileSystem.c') diff --git a/Software/Embedded_SW/Embedded/Common/SWUpdate/FileSystem.c b/Software/Embedded_SW/Embedded/Common/SWUpdate/FileSystem.c index 6c7ee97a4..a12c02867 100644 --- a/Software/Embedded_SW/Embedded/Common/SWUpdate/FileSystem.c +++ b/Software/Embedded_SW/Embedded/Common/SWUpdate/FileSystem.c @@ -51,8 +51,11 @@ char ErrorMsg[100]; #define MAX_CHUNK_LENGTH 2000 int FileLength = 0; int FileReceivedLength = 0; +int FileSentLength = 0; static char g_cCwdBuf[50] = "/"; uint32_t WrittenBytes = 0; +uint32_t ReadBytes = 0; + ErrorCode getErrorCode(FRESULT Fresult) { @@ -116,7 +119,6 @@ uint32_t FileUploadRequestFunc(MessageContainer* requestContainer) return OK; } - uint32_t FileChunkUploadRequestFunc(MessageContainer* requestContainer) { //uint32_t status = OK; @@ -186,6 +188,124 @@ uint32_t FileChunkUploadRequestFunc(MessageContainer* requestContainer) return OK; } +uint32_t FileDownloadRequestFunc(MessageContainer* requestContainer) +{ + //uint32_t status = OK; + + FRESULT Fresult = FR_OK; + FILINFO* fno; + + MessageContainer responseContainer; + + FileDownloadRequest* request = file_download_request__unpack(NULL, requestContainer->data.len, requestContainer->data.data); + + FileDownloadResponse response = FILE_DOWNLOAD_RESPONSE__INIT; + + ReadBytes=0; + FileSentLength = 0; + + fno = my_malloc(sizeof(FILINFO)); + if (fno == 0) + Fresult = FR_DENIED; + else + { + memset (fno,0,sizeof(FILINFO)); + Fresult = f_stat(request->filename,fno); + FileLength = fno->fsize; + DownloadFileHandle = my_malloc(sizeof(FIL)); + if (DownloadFileHandle == 0) + Fresult = FR_DENIED; + else + { + 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. + } + + } + } + + + responseContainer = createContainer(MESSAGE_TYPE__FileDownloadResponse, requestContainer->token, false, &response, &file_download_response__pack, &file_download_response__get_packed_size); + if (Fresult!= FR_OK) + { + responseContainer.error = getErrorCode(Fresult); + responseContainer.errormessage = "File operation error"; + } + responseContainer.continuous = false; + uint8_t* container_buffer = my_malloc(message_container__get_packed_size(&responseContainer)); + size_t container_size = message_container__pack(&responseContainer, container_buffer); + my_free(responseContainer.data.data); + file_download_request__free_unpacked(request,NULL); + SendChars(container_buffer, container_size); + my_free(fno); + + return OK; +} +uint32_t FileChunkDownloadRequestFunc(MessageContainer* requestContainer) +{ + MessageContainer responseContainer; + FileChunkDownloadRequest* request = file_chunk_download_request__unpack(NULL, requestContainer->data.len, requestContainer->data.data); + FileChunkDownloadResponse response = FILE_CHUNK_DOWNLOAD_RESPONSE__INIT; + FRESULT Fresult = FR_OK; + FIL *SentFileHandle; //the system supports a single active file + + SentFileHandle = DownloadFileHandle; + char *Buffer = 0; + Buffer = my_malloc (MAX_CHUNK_LENGTH); + if (Buffer != NULL) + { + Fresult = f_read(SentFileHandle,Buffer,2000,&ReadBytes ); + if(Fresult != FR_OK) + { + LOG_ERROR (Fresult,"f_write error"); + } + else + { + response.has_buffer = true; + response.buffer.len = ReadBytes; + response.buffer.data = Buffer; + FileSentLength += ReadBytes; + if (FileSentLength == FileLength) + { + REPORT_MSG (FileSentLength,"file download ended successfully"); + f_close(SentFileHandle); + free (DownloadFileHandle); + FileSentLength = 0; + } + else + { + if (FileSentLength > FileLength) + { + REPORT_MSG (FileSentLength,"file download too much data!"); + f_close(SentFileHandle); + free (DownloadFileHandle); + FileSentLength = 0; + } + } + } + } + + responseContainer = createContainer(MESSAGE_TYPE__FileChunkDownloadResponse, requestContainer->token, false, &response, &file_chunk_download_response__pack, &file_chunk_download_response__get_packed_size); + if (Fresult!= OK) + { + responseContainer.error = getErrorCode(Fresult); + responseContainer.errormessage = "File operation error"; + } + responseContainer.continuous = false; + uint8_t* container_buffer = my_malloc(message_container__get_packed_size(&responseContainer)); + size_t container_size = message_container__pack(&responseContainer, container_buffer); + file_chunk_download_request__free_unpacked(request,NULL); + my_free(responseContainer.data.data); + my_free(Buffer); + SendChars(container_buffer, container_size); + + return OK; +} uint32_t ExecuteProcessRequestFunc(MessageContainer* requestContainer) { uint32_t status = OK; @@ -517,122 +637,6 @@ uint32_t GetFilesRequestFunc(MessageContainer* requestContainer) } return Fresult; } -uint32_t FileDownloadRequestFunc(MessageContainer* requestContainer) -{ - //uint32_t status = OK; - - FRESULT Fresult = FR_OK; - FILINFO* fno; - - MessageContainer responseContainer; - - FileDownloadRequest* request = file_download_request__unpack(NULL, requestContainer->data.len, requestContainer->data.data); - - FileDownloadResponse response = FILE_DOWNLOAD_RESPONSE__INIT; - - WrittenBytes=0; - FileReceivedLength = 0; - - fno = my_malloc(sizeof(FILINFO)); - if (fno == 0) - Fresult = FR_DENIED; - else - { - memset (fno,0,sizeof(FILINFO)); - Fresult = f_stat(request->filename,fno); - FileLength = fno->fsize; - DownloadFileHandle = my_malloc(sizeof(FIL)); - if (DownloadFileHandle == 0) - Fresult = FR_DENIED; - else - { - 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. - } - - } - } - - - responseContainer = createContainer(MESSAGE_TYPE__FileDownloadResponse, requestContainer->token, false, &response, &file_download_response__pack, &file_download_response__get_packed_size); - if (Fresult!= FR_OK) - { - responseContainer.error = getErrorCode(Fresult); - responseContainer.errormessage = "File operation error"; - } - responseContainer.continuous = false; - uint8_t* container_buffer = my_malloc(message_container__get_packed_size(&responseContainer)); - size_t container_size = message_container__pack(&responseContainer, container_buffer); - my_free(responseContainer.data.data); - file_download_request__free_unpacked(request,NULL); - SendChars(container_buffer, container_size); - - return OK; -} -uint32_t FileChunkDownloadRequestFunc(MessageContainer* requestContainer) -{ - MessageContainer responseContainer; - FileChunkDownloadRequest* request = file_chunk_download_request__unpack(NULL, requestContainer->data.len, requestContainer->data.data); - FileChunkDownloadResponse response = FILE_CHUNK_DOWNLOAD_RESPONSE__INIT; - FRESULT Fresult = FR_OK; - FIL *ReceivedFileHandle; //the system supports a single active file - - ReceivedFileHandle = DownloadFileHandle; - char *Buffer = 0; - Buffer = my_malloc (MAX_CHUNK_LENGTH); - if (Buffer != NULL) - { - Fresult = f_read(ReceivedFileHandle,Buffer,2000,&WrittenBytes ); - if(Fresult != FR_OK) - { - LOG_ERROR (Fresult,"f_write error"); - } - else - { - response.buffer.len = WrittenBytes; - response.buffer.data = Buffer; - FileReceivedLength += WrittenBytes; - if (FileReceivedLength == FileLength) - { - REPORT_MSG (FileReceivedLength,"file download ended successfully"); - f_close(ReceivedFileHandle); - free (DownloadFileHandle); - FileReceivedLength = 0; - } - else - { - if (FileReceivedLength > FileLength) - { - REPORT_MSG (FileReceivedLength,"file download too much data!"); - f_close(ReceivedFileHandle); - free (DownloadFileHandle); - FileReceivedLength = 0; - } - } - } - } - - responseContainer = createContainer(MESSAGE_TYPE__FileChunkDownloadResponse, requestContainer->token, false, &response, &file_chunk_download_response__pack, &file_chunk_download_response__get_packed_size); - if (Fresult!= OK) - { - responseContainer.error = getErrorCode(Fresult); - responseContainer.errormessage = "File operation error"; - } - responseContainer.continuous = false; - uint8_t* container_buffer = my_malloc(message_container__get_packed_size(&responseContainer)); - size_t container_size = message_container__pack(&responseContainer, container_buffer); - file_chunk_download_request__free_unpacked(request,NULL); - my_free(responseContainer.data.data); - my_free(Buffer); - SendChars(container_buffer, container_size); - - return OK; -} FRESULT FileWrite(void * buffer, uint16_t size,char *path) { FRESULT Fresult = FR_OK; diff --git a/Software/Embedded_SW/Embedded/Drivers/FPGA/FPGA_SPI_Comm.c b/Software/Embedded_SW/Embedded/Drivers/FPGA/FPGA_SPI_Comm.c index 06f082bca..c984f2c48 100644 --- a/Software/Embedded_SW/Embedded/Drivers/FPGA/FPGA_SPI_Comm.c +++ b/Software/Embedded_SW/Embedded/Drivers/FPGA/FPGA_SPI_Comm.c @@ -677,6 +677,15 @@ uint32_t FPGA_MotorConfig_callback(TimerMotors_t _motorId, uint32_t ReadValue) break; } break; + case MOTOR_CONFIG_END: + { + temp = x_HARD_HIZ; + temp = temp << 24; + + MillisecWriteToMotor(_motorId, temp, 4, FPGA_MotorConfig_callback); + ConfigStages[_motorId]++; + } + break; default: return ERROR; } diff --git a/Software/Embedded_SW/Embedded/Drivers/I2C_Communication/DAC/Blower.c b/Software/Embedded_SW/Embedded/Drivers/I2C_Communication/DAC/Blower.c index 566cb1cc6..38b029925 100644 --- a/Software/Embedded_SW/Embedded/Drivers/I2C_Communication/DAC/Blower.c +++ b/Software/Embedded_SW/Embedded/Drivers/I2C_Communication/DAC/Blower.c @@ -22,6 +22,7 @@ #include "driverlib/i2c.h" #include "drivers/I2C_Communication/I2C.h" #include "Blower.h" +#include "modules/control/control.h" DAC_Union DAC; @@ -159,6 +160,60 @@ uint32_t Turn_the_Blower_Off() return status; } +uint32_t mInitial_mV, mTarget_mV; +uint32_t mInterval = eOneSecond*20; +uint32_t BlowerControlId = 0xFF; + +uint32_t Gradual_Increase_Blower_Callback(uint32_t DispenserId, uint32_t ReadValue) +{ + if ((mTarget_mV-mInitial_mV)<100) + { + Control_Voltage_To_Blower(mTarget_mV); + Report("Finished Increasing blower",__FILE__,__LINE__,(int)mTarget_mV,RpWarning,(int)millisecondCounter,0); + if (RemoveControlCallback(BlowerControlId, Gradual_Increase_Blower_Callback )==OK) + { + Report("Remove control callback",__FILE__,__LINE__,(int)1,RpWarning,(int)BlowerControlId,0); + BlowerControlId = 0xFF; + } + else + { + Report("Fixing Remove control ",__FILE__,__LINE__,(int)GetControlLowDevice_i(),RpWarning,(int)BlowerControlId,0); + if (RemoveControlCallback(GetControlLowDevice_i(),Gradual_Increase_Blower_Callback)==OK) + { + Report("Remove control callback fixed",__FILE__,__LINE__,(int)1,RpWarning,(int)BlowerControlId,0); + BlowerControlId = 0xFF; + } + else + Report("Remove control callback failed",__FILE__,__LINE__,(int)1,RpWarning,(int)BlowerControlId,0); + } + return OK; + } + mInitial_mV = mInitial_mV+100; + Control_Voltage_To_Blower(mInitial_mV); + Report("Increasing blower",__FILE__,__LINE__,(int)mInitial_mV,RpWarning,(int)millisecondCounter,0); + return OK; +} + +uint32_t Gradual_Increase_Blower(uint32_t Initial_mV,uint32_t Target_mV) +{ + mInitial_mV = Initial_mV; + mTarget_mV = Target_mV; + if ((mTarget_mV-mInitial_mV)<100) + { + Control_Voltage_To_Blower(mTarget_mV); + Report("Finished Increasing blower",__FILE__,__LINE__,(int)mTarget_mV,RpWarning,(int)millisecondCounter,0); + return OK; + } + mInitial_mV = Initial_mV+100; + Control_Voltage_To_Blower(mInitial_mV); + Report("Increasing blower",__FILE__,__LINE__,(int)mInitial_mV,RpWarning,(int)millisecondCounter,0); + BlowerControlId = AddControlCallback( Gradual_Increase_Blower_Callback, mInterval,getBlowerState ,0, 0, 0 ); + if (BlowerControlId == 0xFF) + { + Report("Add control callback failed",__FILE__,__LINE__,(int)0,RpWarning,(int)BlowerControlId,0); + return ERROR; + } +} diff --git a/Software/Embedded_SW/Embedded/Drivers/I2C_Communication/DAC/Blower.h b/Software/Embedded_SW/Embedded/Drivers/I2C_Communication/DAC/Blower.h index 56a42a885..abe5d8a1a 100644 --- a/Software/Embedded_SW/Embedded/Drivers/I2C_Communication/DAC/Blower.h +++ b/Software/Embedded_SW/Embedded/Drivers/I2C_Communication/DAC/Blower.h @@ -52,7 +52,7 @@ uint32_t Turn_the_Blower_On(); uint32_t Control_Voltage_To_Blower(uint32_t mV); uint32_t Turn_the_Blower_Off(); uint32_t getBlowerState(void); - +uint32_t Gradual_Increase_Blower(uint32_t Initial_mV,uint32_t Target_mV); #endif /* DRIVERS_I2C_COMMUNICATION_DAC_BLOWER_H_ */ diff --git a/Software/Embedded_SW/Embedded/Modules/Heaters/Heaters_print.c b/Software/Embedded_SW/Embedded/Modules/Heaters/Heaters_print.c index d6f661789..29a074fc0 100644 --- a/Software/Embedded_SW/Embedded/Modules/Heaters/Heaters_print.c +++ b/Software/Embedded_SW/Embedded/Modules/Heaters/Heaters_print.c @@ -717,8 +717,8 @@ uint32_t HeaterControlCBFunction(uint32_t IfIndex, uint32_t readValue) { Turn_the_Blower_On();//Turn on with the Default_Voltage if (BlowerCfg.voltage) - Control_Voltage_To_Blower(BlowerCfg.voltage); - + Gradual_Increase_Blower(BlowerCfg.heatingvoltage,BlowerCfg.voltage); + //Control_Voltage_To_Blower(BlowerCfg.voltage); } } return OK; diff --git a/Software/Embedded_SW/Embedded/Software Release Notes.txt b/Software/Embedded_SW/Embedded/Software Release Notes.txt new file mode 100644 index 000000000..dd8679721 --- /dev/null +++ b/Software/Embedded_SW/Embedded/Software Release Notes.txt @@ -0,0 +1,11 @@ +Embedded SW Release note - Version 1.3.7.0 +This version includes massive changes in job handling, files support and hardware changes. also cleans multiple bugs and improves machine handing, cleans and removes unnecessary code from the SW files. +it contains thet basis for improving the process and the operator control ability. +1. file system: File system full handling, SW Upgrade support for FPGA, Load HW Config and embedded parameters from file, Dispensers activity stored in file. +2. alarm handling: new list supports system definitions version 2. overheat/underheat type A/B handled, +3. driver level support for all new HW/Backplan features. initial support for operator buttons. (tamper switches, WHS readout and sensors, buttons, magnet, head and cleaning motors and switches...) +4. additional RAM space in internal RAM for additional development space +5. Initial support for thread insertion fullprocess - not tested yet. +6. bugs solved in control activity, in job handling and more. real time handling improved in main control functions +7. IDS Infrastructure for testing: pressure bulding before job, coordinated activation of motors and valves (motor starts before valve opens, stops after valve closes. + -- cgit v1.3.1