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 ++++++++++++++-------- 1 file changed, 57 insertions(+), 34 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; } } } -- 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 From 3f5b0a7636c32582c67dbe965aaac7bf3ac2bdbd Mon Sep 17 00:00:00 2001 From: Avi Levkovich Date: Mon, 4 Feb 2019 13:26:39 +0200 Subject: FileSystem.c change the File Length to int32_t --- Software/Embedded_SW/Embedded/Common/SWUpdate/FileSystem.c | 6 +++--- 1 file changed, 3 insertions(+), 3 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 a12c02867..11fbf86c4 100644 --- a/Software/Embedded_SW/Embedded/Common/SWUpdate/FileSystem.c +++ b/Software/Embedded_SW/Embedded/Common/SWUpdate/FileSystem.c @@ -49,9 +49,9 @@ FIL *DownloadFileHandle = 0; //the system supports a single active file char FileHandleChar[5]; char ErrorMsg[100]; #define MAX_CHUNK_LENGTH 2000 -int FileLength = 0; -int FileReceivedLength = 0; -int FileSentLength = 0; +int32_t FileLength = 0; +int32_t FileReceivedLength = 0; +int32_t FileSentLength = 0; static char g_cCwdBuf[50] = "/"; uint32_t WrittenBytes = 0; uint32_t ReadBytes = 0; -- cgit v1.3.1 From a73a6f639445640123705f3e68e6a7ecd654ef41 Mon Sep 17 00:00:00 2001 From: Shlomo Hecht Date: Wed, 6 Feb 2019 11:30:20 +0200 Subject: flash programming improved, working --- Software/Embedded_SW/Embedded/.cproject | 2 +- .../Embedded/Common/SWUpdate/FileSystem.c | 5 +- .../Embedded/Common/SWUpdate/FirmwareUpgrade.c | 16 ++--- .../Drivers/FPGA/Full_Vme/FPGA_Programming_Up.c | 72 ++++++++++++++++++---- .../Drivers/FPGA/Full_Vme/FPGA_Programming_Up.h | 4 +- .../Drivers/I2C_Communication/DAC/Blower.c | 2 +- .../Embedded/Drivers/USB_Communication/USBCDCD.c | 7 +++ Software/Embedded_SW/Embedded/Embedded.cfg | 6 ++ Software/Embedded_SW/Embedded/Main.c | 6 +- Software/Embedded_SW/Embedded/tm4c129xnczad.cmd | 2 +- 10 files changed, 91 insertions(+), 31 deletions(-) (limited to 'Software/Embedded_SW/Embedded/Common/SWUpdate/FileSystem.c') diff --git a/Software/Embedded_SW/Embedded/.cproject b/Software/Embedded_SW/Embedded/.cproject index 38422568f..89dc72b30 100644 --- a/Software/Embedded_SW/Embedded/.cproject +++ b/Software/Embedded_SW/Embedded/.cproject @@ -169,7 +169,7 @@ - + diff --git a/Software/Embedded_SW/Embedded/Common/SWUpdate/FileSystem.c b/Software/Embedded_SW/Embedded/Common/SWUpdate/FileSystem.c index 11fbf86c4..d39c335ef 100644 --- a/Software/Embedded_SW/Embedded/Common/SWUpdate/FileSystem.c +++ b/Software/Embedded_SW/Embedded/Common/SWUpdate/FileSystem.c @@ -509,9 +509,9 @@ uint32_t GetStorageInfoRequestFunc(MessageContainer* requestContainer) tot_sect = (fs->n_fatent - 2) * fs->csize; fre_sect = fre_clust * fs->csize; response.has_capacity = true; - response.capacity = tot_sect/2; + response.capacity = tot_sect/2*1024; response.has_freespace = true; - response.freespace = fre_sect/2; + response.freespace = fre_sect/2*1024; response.root = "/"; } @@ -588,7 +588,6 @@ uint32_t GetFilesRequestFunc(MessageContainer* requestContainer) FilesInfo[i] = &Data[i]; Data[i].has_attribute = true; Data[i].attribute = fno[i]->fattrib; - Data[i].has_length = true; Data[i].name = fno[i]->fname; Data[i].has_length = true; Data[i].length = fno[i]->fsize; diff --git a/Software/Embedded_SW/Embedded/Common/SWUpdate/FirmwareUpgrade.c b/Software/Embedded_SW/Embedded/Common/SWUpdate/FirmwareUpgrade.c index 35bde3636..dcb8cf8f2 100644 --- a/Software/Embedded_SW/Embedded/Common/SWUpdate/FirmwareUpgrade.c +++ b/Software/Embedded_SW/Embedded/Common/SWUpdate/FirmwareUpgrade.c @@ -24,13 +24,12 @@ #include "drivers/FPGA/Full_Vme/FPGA_Programming_Up.h" #include "Common/SWUpdate/FileSystem.h" - uint32_t ActivateVersionRequestFunc(MessageContainer* requestContainer) { - uint32_t status = OK; void* buffer = NULL; uint32_t Bytes = 0; char SWINFOPath[100]; + char FullPath[50]; FRESULT Fresult = FR_OK; int File_i; @@ -41,12 +40,13 @@ uint32_t ActivateVersionRequestFunc(MessageContainer* requestContainer) ActivateVersionResponse response = ACTIVATE_VERSION_RESPONSE__INIT; VersionPackageDescriptor* VersionPackage;// = VERSION_PACKAGE_DESCRIPTOR__INIT; + FPGA_ID FileDestinationToFPGAId[VERSION_FILE_DESTINATION__FPGA3+1] = {MAX_FPGA,FPGA1,FPGA2,FPGA3}; + strcpy (SWINFOPath,request->path); - strcat(SWINFOPath,"//SWINFO.DAT"); + strcat(SWINFOPath,"/file1.pck"); Fresult = FileRead(SWINFOPath, &Bytes, &buffer); - if (Fresult == FR_OK) { VersionPackage = version_package_descriptor__unpack(NULL,Bytes,buffer); @@ -61,17 +61,19 @@ uint32_t ActivateVersionRequestFunc(MessageContainer* requestContainer) case VERSION_FILE_DESTINATION__FPGA3: //validate //update - Fresult = FPGA_Programming_Up( VersionPackage->filedescriptors[File_i]->destination, VersionPackage->filedescriptors[File_i]->filename, false); + usnprintf(FullPath, 50, "%s%s%s", request->path,"/", VersionPackage->filedescriptors[File_i]->filename); + + Fresult = FPGA_Programming_Request( FileDestinationToFPGAId[VersionPackage->filedescriptors[File_i]->destination], FullPath, false); break; default: - LOG_ERROR (VersionPackage->filedescriptors[File_i]->destination,"wrong fule update Destination"); + LOG_ERROR (VersionPackage->filedescriptors[File_i]->destination,"wrong file update Destination"); Fresult = FR_INVALID_NAME; break; } } } responseContainer = createContainer(MESSAGE_TYPE__ActivateVersionResponse, requestContainer->token, false, &response, &activate_version_response__pack, &activate_version_response__get_packed_size); - if (status!= OK) + if (Fresult!= OK) { responseContainer.error = FileError_to_ErrorCode[Fresult]; responseContainer.errormessage = "Activate Version Request error"; diff --git a/Software/Embedded_SW/Embedded/Drivers/FPGA/Full_Vme/FPGA_Programming_Up.c b/Software/Embedded_SW/Embedded/Drivers/FPGA/Full_Vme/FPGA_Programming_Up.c index ab0775af3..248c9e66d 100644 --- a/Software/Embedded_SW/Embedded/Drivers/FPGA/Full_Vme/FPGA_Programming_Up.c +++ b/Software/Embedded_SW/Embedded/Drivers/FPGA/Full_Vme/FPGA_Programming_Up.c @@ -14,8 +14,8 @@ #include "FPGA_Programming_Up.h" #include - - +#include "Modules/Control/Control.h" +#include "Modules/Control/MillisecTask.h" extern short int main_vme(); @@ -69,8 +69,8 @@ FRESULT FPGA_Programming_Up(FPGA_ID FPGA_Id, char * FullPath, bool IncludeReboot FPGA_JTAG.GPI_TDO.Pin = GPIO_PIN_7; break; default: - //return error - break; + return FR_INVALID_OBJECT; + //break; } FileHandlevme = malloc(sizeof(FIL)); @@ -79,7 +79,7 @@ FRESULT FPGA_Programming_Up(FPGA_ID FPGA_Id, char * FullPath, bool IncludeReboot { return(fresult); } - main_vme(); + fresult = main_vme(); @@ -91,14 +91,62 @@ FRESULT FPGA_Programming_Up(FPGA_ID FPGA_Id, char * FullPath, bool IncludeReboot return fresult; } +/****************************************************************************** + * ======== messageTsk ======== + * Task for this function is created statically. See the project's .cfg file. + * this message task is created statically in system initialization, + ******************************************************************************/ +Mailbox_Handle FPGALoadMsgQ = NULL; +typedef enum +{ + OneFPGALoad, +}FPGALoadMessages; -void Test_Programing_Up() +typedef struct FPGALoadMessage{ + uint16_t messageId; + FPGA_ID FPGA_Id; + char * FullPath; + bool IncludeReboot; +}FPGALoadMessageStruc; + +FRESULT FPGA_Programming_Request(FPGA_ID FPGA_Id, char * FullPath, bool IncludeReboot) { - char FullPath1[] = "0://FPGAJTAG//F1TangoF.vme"; - char FullPath2[] = "0://FPGAJTAG//F2TangoF.vme"; - char FullPath3[] = "0://FPGAJTAG//F3_Tango.vme"; - FPGA_Programming_Up(FPGA1, FullPath1, FALSE); - FPGA_Programming_Up(FPGA2, FullPath2, FALSE); - FPGA_Programming_Up(FPGA3, FullPath3, FALSE); + FPGALoadMessageStruc FPGALoadMessage; + + FPGALoadMessage.messageId = OneFPGALoad; + FPGALoadMessage.FPGA_Id = FPGA_Id; + FPGALoadMessage.FullPath = FullPath; + FPGALoadMessage.IncludeReboot = IncludeReboot; + if (FPGALoadMsgQ != NULL) + Mailbox_post(FPGALoadMsgQ , &FPGALoadMessage, BIOS_NO_WAIT); + return FR_OK; +} + + +void FPGALoadTask(UArg arg0, UArg arg1) +{ + FPGALoadMessageStruc FPGALoadMessage; + Error_Block eb; + Error_init(&eb); + + FPGALoadMsgQ = Mailbox_create(sizeof(FPGALoadMessageStruc), 4, NULL,&eb); + + while(1) + { + Mailbox_pend(FPGALoadMsgQ , &FPGALoadMessage, BIOS_WAIT_FOREVER); + switch (FPGALoadMessage.messageId) + { + case OneFPGALoad: + ControlStop(); + MillisecStop(); + FPGA_Programming_Up(FPGALoadMessage.FPGA_Id,FPGALoadMessage.FullPath,FPGALoadMessage.IncludeReboot); + ControlStart(); + MillisecStart(); + //printf( "Finished Load FPGA %d File %s\n", FPGALoadMessage.FPGA_Id,FPGALoadMessage.FullPath ); + break; + default: + break; + } + } } diff --git a/Software/Embedded_SW/Embedded/Drivers/FPGA/Full_Vme/FPGA_Programming_Up.h b/Software/Embedded_SW/Embedded/Drivers/FPGA/Full_Vme/FPGA_Programming_Up.h index 91ad2a61a..b752f24b3 100644 --- a/Software/Embedded_SW/Embedded/Drivers/FPGA/Full_Vme/FPGA_Programming_Up.h +++ b/Software/Embedded_SW/Embedded/Drivers/FPGA/Full_Vme/FPGA_Programming_Up.h @@ -32,8 +32,10 @@ typedef struct GPIO GPI_TDO; //GPI FPGA->MCU }FPGA_JTAG_GPIO; +//Independent task non blocking call +FRESULT FPGA_Programming_Request(FPGA_ID FPGA_Id, char * FullPath, bool IncludeReboot); +//direct blocking call FRESULT FPGA_Programming_Up(FPGA_ID FPGA_Id, char * FullPath, bool IncludeReboot); - #endif /* DRIVERS_FPGA_FULL_VME_FPGA_PROGRAMMING_UP_H_ */ 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 37789abb1..940cd136c 100644 --- a/Software/Embedded_SW/Embedded/Drivers/I2C_Communication/DAC/Blower.c +++ b/Software/Embedded_SW/Embedded/Drivers/I2C_Communication/DAC/Blower.c @@ -217,7 +217,7 @@ uint32_t Gradual_Increase_Blower(uint32_t Initial_mV,uint32_t Target_mV) uint32_t Cancel_Gradual_Increase_Blower(uint32_t Initial_mV) { Control_Voltage_To_Blower(Initial_mV); - Report("Finished Increasing blower",__FILE__,__LINE__,(int)Initial_mV,RpWarning,(int)millisecondCounter,0); + Report("Cancelled Increasing blower",__FILE__,__LINE__,(int)Initial_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); diff --git a/Software/Embedded_SW/Embedded/Drivers/USB_Communication/USBCDCD.c b/Software/Embedded_SW/Embedded/Drivers/USB_Communication/USBCDCD.c index 4c6b18030..b3ab21f0a 100644 --- a/Software/Embedded_SW/Embedded/Drivers/USB_Communication/USBCDCD.c +++ b/Software/Embedded_SW/Embedded/Drivers/USB_Communication/USBCDCD.c @@ -810,6 +810,13 @@ void USBCDCD_init(void) /* State specific variables */ state = USBCDCD_STATE_UNCONFIGURED; + /*added lines for drivers version 4.178*/ + uint32_t g_ui32SysClock = MAP_SysCtlClockFreqSet((SYSCTL_XTAL_25MHZ |SYSCTL_OSC_MAIN |SYSCTL_USE_PLL |SYSCTL_CFG_VCO_480), 120000000); + USBDCDFeatureSet(0, USBLIB_FEATURE_CPUCLK, &g_ui32SysClock); + //uint32_t ui32PLLRate; + //SysCtlVCOGet(SYSCTL_XTAL_25MHZ, &ui32PLLRate); + //USBDCDFeatureSet(0, USBLIB_FEATURE_USBPLL, &ui32PLLRate); + /* Set the USB stack mode to Device mode with VBUS monitoring */ USBStackModeSet(0, eUSBModeForceDevice, 0); diff --git a/Software/Embedded_SW/Embedded/Embedded.cfg b/Software/Embedded_SW/Embedded/Embedded.cfg index 97c95a452..45ed20a54 100644 --- a/Software/Embedded_SW/Embedded/Embedded.cfg +++ b/Software/Embedded_SW/Embedded/Embedded.cfg @@ -116,6 +116,12 @@ MillisecTaskParams.stackSize = 2048; MillisecTaskParams.priority = 12; Program.global.millisec = Task.create("&MillisecTask", MillisecTaskParams); +var FPGALoad = new Task.Params(); +FPGALoad.instance.name = "FPGALoad"; +FPGALoad.stackSize = 4096; +FPGALoad.priority = 5; +Program.global.FPGALoad = Task.create("&FPGALoadTask", FPGALoad); + var ControlTaskParams = new Task.Params(); ControlTaskParams.instance.name = "control"; ControlTaskParams.stackSize = 2048; diff --git a/Software/Embedded_SW/Embedded/Main.c b/Software/Embedded_SW/Embedded/Main.c index 5e96abaf6..b13bab1d5 100644 --- a/Software/Embedded_SW/Embedded/Main.c +++ b/Software/Embedded_SW/Embedded/Main.c @@ -30,8 +30,6 @@ #include #include "Sys_PinOut_Config/MCU_MAIN_pinout.h" -#include "drivers/FPGA/Full_Vme/FPGA_Programming_Up.h" - /* #include "Drivers/SPI_SDCARD/SDSPI.h" #include "Drivers/SPI_SDCARD/SDCardSPI.h" @@ -203,9 +201,7 @@ int main(void) } //Control_File_System();// test file system //IDS_ModuleInit(); -/* - Test_Programing_Up() -*/ + //GetFiles(); - to start jtag //GetVmeByte(); diff --git a/Software/Embedded_SW/Embedded/tm4c129xnczad.cmd b/Software/Embedded_SW/Embedded/tm4c129xnczad.cmd index d63d890cd..25916dae2 100644 --- a/Software/Embedded_SW/Embedded/tm4c129xnczad.cmd +++ b/Software/Embedded_SW/Embedded/tm4c129xnczad.cmd @@ -42,7 +42,7 @@ MEMORY { /* Application stored in and executes from internal flash */ - FLASH (RX) : origin = APP_BASE, length = 0x000B0000 + FLASH (RX) : origin = APP_BASE, length = 0x000D0000 /* Application stored in and executes from internal flash */ FLASH_RAM (RWX) : origin = FLASH_RAM_BASE, length = 0x00030000 /* Application uses internal RAM for data */ -- cgit v1.3.1