diff options
| author | Roy Ben Shabat <Roy.mail.net@gmail.com> | 2020-12-24 18:58:17 +0200 |
|---|---|---|
| committer | Roy Ben Shabat <Roy.mail.net@gmail.com> | 2020-12-24 18:58:17 +0200 |
| commit | ad969db71a39b4854d744412eb6482c0391a4dd9 (patch) | |
| tree | 7ece9b0fe114e6a1afd171c3feec054d1ed90617 /Software/Embedded_SW | |
| parent | 941679fac898ab6c488674f611e157d5094a8c83 (diff) | |
| parent | 71f7f59a5345c2df5d2fa8c641a88bf1d12bf063 (diff) | |
| download | Tango-ad969db71a39b4854d744412eb6482c0391a4dd9.tar.gz Tango-ad969db71a39b4854d744412eb6482c0391a4dd9.zip | |
Merge branch 'master' of https://twinetfs.visualstudio.com/Tango/_git/Tango
Diffstat (limited to 'Software/Embedded_SW')
31 files changed, 795 insertions, 228 deletions
diff --git a/Software/Embedded_SW/Embedded/Common/SWUpdate/FileSystem.c b/Software/Embedded_SW/Embedded/Common/SWUpdate/FileSystem.c index 17c1f164b..7b7d4c3c2 100644 --- a/Software/Embedded_SW/Embedded/Common/SWUpdate/FileSystem.c +++ b/Software/Embedded_SW/Embedded/Common/SWUpdate/FileSystem.c @@ -646,11 +646,11 @@ uint32_t GetFilesRequestFunc(MessageContainer* requestContainer) GetFilesResponse response = GET_FILES_RESPONSE__INIT; //struct tm RTC_time; - #define MAX_NUM_OF_FILES 20 + #define MAX_NUM_OF_FILES 40 DIR dir; FILINFO* fno[MAX_NUM_OF_FILES]; char FullPath[MAX_NUM_OF_FILES][60]; - int i,NumOfFiles = 0; + int i,NumOfFiles = 0, ListedFiles = 0; FRESULT Fresult = FR_OK; FileInfo **FilesInfo = (FileInfo**)my_malloc(sizeof(FileInfo *)*(MAX_NUM_OF_FILES)); FileInfo Data[MAX_NUM_OF_FILES]; @@ -699,26 +699,33 @@ uint32_t GetFilesRequestFunc(MessageContainer* requestContainer) { for (i = 0;i < NumOfFiles;i++) { - file_info__init(&Data[i]); - FilesInfo[i] = &Data[i]; - Data[i].has_attribute = true; - Data[i].attribute = fno[i]->fattrib; - Data[i].name = fno[i]->fname; - Data[i].has_length = true; - Data[i].length = fno[i]->fsize; - Data[i].has_lastmodifieddate = true; - Data[i].lastmodifieddate = fno[i]->fdate; - Data[i].has_lastmodifiedtime = true; - Data[i].lastmodifiedtime = fno[i]->ftime; - - if (i==0) - usnprintf(&FullPath[i], 50, "%s", request->path); + if (i==0) + usnprintf(&FullPath[ListedFiles], 50, "%s", request->path); + else + if (strlen(request->path)==1) //info under the root + usnprintf(&FullPath[ListedFiles], 50, "%s%s", request->path, fno[i]->fname); + else + usnprintf(&FullPath[ListedFiles], 50, "%s%s%s", request->path,"/", fno[i]->fname); + if (fno[i]->fattrib != 0xFF) //garbage + { + file_info__init(&Data[ListedFiles]); + FilesInfo[ListedFiles] = &Data[ListedFiles]; + Data[ListedFiles].has_attribute = true; + Data[ListedFiles].attribute = fno[i]->fattrib; + Data[ListedFiles].name = fno[i]->fname; + Data[ListedFiles].has_length = true; + Data[ListedFiles].length = fno[i]->fsize; + Data[ListedFiles].has_lastmodifieddate = true; + Data[ListedFiles].lastmodifieddate = fno[i]->fdate; + Data[ListedFiles].has_lastmodifiedtime = true; + Data[ListedFiles].lastmodifiedtime = fno[i]->ftime; + Data[ListedFiles].fullpath = &FullPath[i][0]; + ListedFiles++; + } else - 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][0]; + { + f_unlink(Data[ListedFiles].fullpath); + } /*RTC_time.tm_year=(fno[i]->fdate>>9)+1980;//populate the time struct (FAT start==1980, RTC.year==0) RTC_time.tm_mon=(fno[i]->fdate>>5)&0x000F; RTC_time.tm_mday=fno[i]->fdate&0x001F; @@ -728,7 +735,7 @@ uint32_t GetFilesRequestFunc(MessageContainer* requestContainer) } - response.n_items = NumOfFiles; + response.n_items = ListedFiles; response.items = FilesInfo; } else diff --git a/Software/Embedded_SW/Embedded/Common/Utilities/Utils.c b/Software/Embedded_SW/Embedded/Common/Utilities/Utils.c index d1143ada2..822294092 100644 --- a/Software/Embedded_SW/Embedded/Common/Utilities/Utils.c +++ b/Software/Embedded_SW/Embedded/Common/Utilities/Utils.c @@ -13,6 +13,7 @@ #include "driverlib/hibernate.h" #include <driverlib/Watchdog.h> #include <ti/sysbios/hal/Seconds.h> +#include "drivers/Flash_ram/MCU_E2Prom.h" //***************************************************************************** @@ -137,16 +138,21 @@ void utilsInit(uint32_t ui32SysClock) // // HibernateCounterMode(HIBERNATE_COUNTER_24HR); // Configure the hibernate module counter to RTC counter mode. - HibernateCounterMode(HIBERNATE_COUNTER_RTC); + HibernateCounterMode(HIBERNATE_COUNTER_24HR); -#define STARTTIME 1564403262 - Seconds_set(STARTTIME); +//#define STARTTIME 1564403262 +// Seconds_set(STARTTIME); } void utilsUpdateDateTime(uint32_t StartTime) { Seconds_set(StartTime); } +void utilsStoreLocalTime() +{ + time_t time_store = umktime(&LocalTime); + MCU_E2PromProgram(EEPROM_LOCAL_TIME,time_store); +} uint32_t UsersysTickGet (void) { uint32_t tick = 0; diff --git a/Software/Embedded_SW/Embedded/Common/Utilities/Utils.h b/Software/Embedded_SW/Embedded/Common/Utilities/Utils.h index b54453e2c..779534182 100644 --- a/Software/Embedded_SW/Embedded/Common/Utilities/Utils.h +++ b/Software/Embedded_SW/Embedded/Common/Utilities/Utils.h @@ -23,6 +23,7 @@ typedef enum void utilsInit(uint32_t ui32SysClock); void utilsUpdateDateTime(uint32_t StartTime); +void utilsStoreLocalTime(void); uint32_t UsersysTickGet (void); bool DanserCheckPosition(uint16_t position , Danser_t danser, bool test); void InitWatchdog(uint32_t clock); diff --git a/Software/Embedded_SW/Embedded/Common/report/filter.c b/Software/Embedded_SW/Embedded/Common/report/filter.c index 753123ee7..78e0ef7eb 100644 --- a/Software/Embedded_SW/Embedded/Common/report/filter.c +++ b/Software/Embedded_SW/Embedded/Common/report/filter.c @@ -333,7 +333,13 @@ void ReportSeveritySet(ErrorSeverity level) SeverityLevel = level; } +uint32_t safeReport(char *message, char *FileName, int LineNumber,int errorCode,int Severity,int parameter1,int parameter2) +{ + if (isReportActive() == false) + return OK; + return (Report(message, FileName, LineNumber, errorCode, Severity, parameter1, parameter2)); +} /*************************************************************************** * * Name : Report diff --git a/Software/Embedded_SW/Embedded/Common/report/report.h b/Software/Embedded_SW/Embedded/Common/report/report.h index 84063fb0f..94017ff20 100644 --- a/Software/Embedded_SW/Embedded/Common/report/report.h +++ b/Software/Embedded_SW/Embedded/Common/report/report.h @@ -131,6 +131,8 @@ uint32_t OpenLogFile(void); uint32_t CloseLogFile(void); bool isReportActive(void); uint32_t LogToFile(char *message, char *FileName, int LineNumber,int errorCode,int Severity,int parameter); +uint32_t safeReport(char *message, char *FileName, int LineNumber,int errorCode,int Severity,int parameter1,int parameter2); + /*************************************************************************** diff --git a/Software/Embedded_SW/Embedded/Common/report/reportInit.c b/Software/Embedded_SW/Embedded/Common/report/reportInit.c index 8292cdeda..4b056b0d8 100644 --- a/Software/Embedded_SW/Embedded/Common/report/reportInit.c +++ b/Software/Embedded_SW/Embedded/Common/report/reportInit.c @@ -101,7 +101,7 @@ uint32_t OpenLogFile(void) f_lseek(LogFileHandle, 0); f_truncate (LogFileHandle); } - len = usnprintf(RepMessage, 80, "\r\n*******\r\nLog File start %s %s",__DATE__, __TIME__); + len = usnprintf(RepMessage, 80, "\r\n*******\r\nLog File start %d/%d/%d %d:%d:%d",LocalTime.tm_mday,LocalTime.tm_mon+1,LocalTime.tm_year,LocalTime.tm_hour,LocalTime.tm_min,LocalTime.tm_sec); LogFresult = f_write(LogFileHandle,RepMessage,len,&Bytes ); ReportResetReason(); } @@ -110,8 +110,9 @@ uint32_t OpenLogFile(void) LogFresult = FR_INT_ERR; return LogFresult; -#endif +#else return OK; +#endif } uint32_t CloseLogFile(void) { @@ -119,13 +120,14 @@ uint32_t CloseLogFile(void) #ifdef STORE_DEBUG_LOGS int len; uint32_t Bytes = 0; - len = usnprintf(RepMessage, 80, "Closing Log File %s %s",__DATE__, __TIME__); + len = usnprintf(RepMessage, 80, "\r\n*******\r\nClosing Log File %d/%d/%d %d:%d:%d",LocalTime.tm_mday,LocalTime.tm_mon+1,LocalTime.tm_year,LocalTime.tm_hour,LocalTime.tm_min,LocalTime.tm_sec); LogFresult = f_write(LogFileHandle,RepMessage,len,&Bytes ); LogFresult = f_close(LogFileHandle); LogFileHandle = NULL; return LogFresult; -#endif +#else return OK; +#endif } uint32_t LogToFile(char *message, /* The formatted message */ @@ -143,13 +145,13 @@ uint32_t LogToFile(char *message, /* The formatted message if (LogFileHandle == NULL) return OK; - len = usnprintf(RepMessage, 300, "\r\nfile %s\t line %d\t code %d\t sev %d,\tparam %d,\t %s",FileName, LineNumber,errorCode, Severity, parameter,message); + len = usnprintf(RepMessage, 300, "\r\n %d:%d:%d %s ,file %s\t line %d\t code %d\t sev %d,\tparam %d",LocalTime.tm_hour,LocalTime.tm_min,LocalTime.tm_sec,message,FileName, LineNumber,errorCode, Severity, parameter); LogFresult = f_write(LogFileHandle,RepMessage,len,&Bytes ); return LogFresult; -#endif +#else return OK; - +#endif } int ReportResponseFunc(char *message, /* The formatted message */ char *FileName, diff --git a/Software/Embedded_SW/Embedded/Communication/Connection.c b/Software/Embedded_SW/Embedded/Communication/Connection.c index 5396938fd..ec15c1596 100644 --- a/Software/Embedded_SW/Embedded/Communication/Connection.c +++ b/Software/Embedded_SW/Embedded/Communication/Connection.c @@ -24,6 +24,7 @@ #include <utils/ustdlib.h> #include "drivers/FPGA/FPGA.h" #include "Drivers/FPGA/FPGA_GPIO/FPGA_GPIO.h" +#include "driverlib/hibernate.h" #include "StateMachines/Printing/PrintingSTM.h" #include "StateMachines/Initialization/InitSequence.h" @@ -100,8 +101,8 @@ void ConnectionRequest(MessageContainer* requestContainer) if (request->has_unixtime) utilsUpdateDateTime(request->unixtime);//(request->seconds); ulocaltime(request->unixtime, &LocalTime); - LocalTime.tm_mon +=1;//since we get from ulocaltime Months since January - [0,11] - + HibernateCalendarSet(&LocalTime); + ReportWithPackageFilter(ThreadFilter,"Set Time: ",__FILE__,LocalTime.tm_hour,LocalTime.tm_min,RpWarning,(int) LocalTime.tm_sec,0); LocalTimeToAScii(); StopRecurringReports(); /* diff --git a/Software/Embedded_SW/Embedded/DataDef.h b/Software/Embedded_SW/Embedded/DataDef.h index 001303c88..3115f6828 100644 --- a/Software/Embedded_SW/Embedded/DataDef.h +++ b/Software/Embedded_SW/Embedded/DataDef.h @@ -169,6 +169,7 @@ typedef enum #define LOW 0x0 #define HIGH 0x1 #define LOW_AND_HIGH 0x2 +#define HIGHEST 0x3 #define WR 0 #define RD 1 @@ -330,6 +331,8 @@ typedef enum #define BIT30 0x40000000 //0x01 << 30 #define BIT31 0x80000000 //0x01 << 31 +extern struct tm LocalTime;//Months since January - [0,11] + //LocalTimeInAScii typedef union { 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 c37bbc437..d9315f9af 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 @@ -18,6 +18,7 @@ #include "Drivers/I2C_Communication/Head_Card/IO_Ports/Head_IO.h" #include <Drivers/I2C_Communication/I2C_Task.h> +#include <Utilities/utils.h> #include <Utilities/delay.h> FPGA_GPI FPGA_Gpi; @@ -122,7 +123,7 @@ LS_DISPENSER_7_8 LS_Dispenser_7_8; LS_DRYER_DH Ls_Dryer_Dh; F3_LS_01 LS_Spare; -void FPGA_Read_LS_Safty_Ind_Reg() +void FPGA_Read_LS_Safty_Ind_Reg()//MillisecLoop { // uint8_t temp[8] = {0,0,0,0,0,0,0,0},i; #ifndef EVALUATION_BOARD @@ -487,9 +488,9 @@ uint32_t DeActivateCleanerPump() return OK; } //---------------------------------- - void Power_Off()//Power Down { + utilsStoreLocalTime(); #ifdef WATCHDOG ROM_WatchdogResetDisable(WATCHDOG0_BASE); #endif @@ -499,6 +500,7 @@ void Power_Off()//Power Down void Power_Reset()// Resets the MCU { + utilsStoreLocalTime(); F3_SW_RESET_reg &= ~BIT0; SysCtlDelay(1000); F3_SW_RESET_reg |= BIT0; diff --git a/Software/Embedded_SW/Embedded/Drivers/Flash_Memory/FATFS/ff.c b/Software/Embedded_SW/Embedded/Drivers/Flash_Memory/FATFS/ff.c index 632dfb0d5..5140b8202 100644 --- a/Software/Embedded_SW/Embedded/Drivers/Flash_Memory/FATFS/ff.c +++ b/Software/Embedded_SW/Embedded/Drivers/Flash_Memory/FATFS/ff.c @@ -898,7 +898,7 @@ FRESULT put_fat ( if (clst < 2 || clst >= fs->n_fatent) { /* Check range */ { res = FR_INT_ERR; - Report("put_fat FR_INT_ERR",__FILE__,__LINE__,(int)clst,RpWarning,(int)fs->n_fatent,0); + safeReport("put_fat FR_INT_ERR",__FILE__,__LINE__,(int)clst,RpWarning,(int)fs->n_fatent,0); } } else { @@ -934,7 +934,7 @@ FRESULT put_fat ( default : res = FR_INT_ERR; - Report("put_fat FR_INT_ERR",__FILE__,__LINE__,(int)clst,RpWarning,(int)fs->fs_type,0); + safeReport("put_fat FR_INT_ERR",__FILE__,__LINE__,(int)clst,RpWarning,(int)fs->fs_type,0); } fs->wflag = 1; @@ -965,7 +965,7 @@ FRESULT remove_chain ( if (clst < 2 || clst >= fs->n_fatent) { /* Check range */ res = FR_INT_ERR; - Report("remove_chain FR_INT_ERR",__FILE__,__LINE__,(int)clst,RpWarning,(int)fs->n_fatent,0); + safeReport("remove_chain FR_INT_ERR",__FILE__,__LINE__,(int)clst,RpWarning,(int)fs->n_fatent,0); } else { res = FR_OK; while (clst < fs->n_fatent) { /* Not a last link? */ @@ -973,7 +973,7 @@ FRESULT remove_chain ( if (nxt == 0) break; /* Empty cluster? */ if (nxt == 1) { res = FR_INT_ERR; - Report("remove_chain FR_INT_ERR",__FILE__,__LINE__,(int)res,RpWarning,(int)fs->n_fatent,0); + safeReport("remove_chain FR_INT_ERR",__FILE__,__LINE__,(int)res,RpWarning,(int)fs->n_fatent,0); break; } /* Internal error? */ if (nxt == 0xFFFFFFFF) { res = FR_DISK_ERR; break; } /* Disk error? */ res = put_fat(fs, clst, 0); /* Mark the cluster "empty" */ @@ -1108,7 +1108,7 @@ FRESULT dir_sdi ( clst = dj->sclust; if (clst == 1 || clst >= dj->fs->n_fatent) /* Check start cluster range */ { - Report("dir_sdi FR_INT_ERR",__FILE__,__LINE__,(int)clst,RpWarning,(int)dj->fs->n_fatent,0); + safeReport("dir_sdi FR_INT_ERR",__FILE__,__LINE__,(int)clst,RpWarning,(int)dj->fs->n_fatent,0); return FR_INT_ERR; } if (!clst && dj->fs->fs_type == FS_FAT32) /* Replace cluster# 0 with root cluster# if in FAT32 */ @@ -1118,7 +1118,7 @@ FRESULT dir_sdi ( dj->clust = clst; if (idx >= dj->fs->n_rootdir) /* Index is out of range */ { - Report("dir_sdi FR_INT_ERR",__FILE__,__LINE__,(int)idx,RpWarning,(int)dj->fs->n_rootdir,0); + safeReport("dir_sdi FR_INT_ERR",__FILE__,__LINE__,(int)idx,RpWarning,(int)dj->fs->n_rootdir,0); return FR_INT_ERR; } dj->sect = dj->fs->dirbase + idx / (SS(dj->fs) / SZ_DIR); /* Sector# */ @@ -1130,7 +1130,7 @@ FRESULT dir_sdi ( if (clst == 0xFFFFFFFF) return FR_DISK_ERR; /* Disk error */ if (clst < 2 || clst >= dj->fs->n_fatent) /* Reached to end of table or int error */ { - Report("dir_sdi FR_INT_ERR",__FILE__,__LINE__,(int)clst,RpWarning,(int)dj->fs->n_fatent,0); + safeReport("dir_sdi FR_INT_ERR",__FILE__,__LINE__,(int)clst,RpWarning,(int)dj->fs->n_fatent,0); return FR_INT_ERR; } idx -= ic; @@ -2578,7 +2578,7 @@ FRESULT f_write ( if (res != FR_OK) LEAVE_FF(fp->fs, res); if (fp->flag & FA__ERROR) /* Aborted file? */ { - Report("f_write FR_INT_ERR",__FILE__,__LINE__,(int)fp->flag,RpWarning,(int)btw,0); + safeReport("f_write FR_INT_ERR",__FILE__,__LINE__,(int)fp->flag,RpWarning,(int)btw,0); LEAVE_FF(fp->fs, FR_INT_ERR); } if (!(fp->flag & FA_WRITE)) /* Check access mode */ @@ -2620,7 +2620,7 @@ FRESULT f_write ( sect = clust2sect(fp->fs, fp->clust); /* Get current sector */ if (!sect) { - Report("f_write FR_INT_ERR",__FILE__,__LINE__,(int)sect,RpWarning,(int)btw,0); + safeReport("f_write FR_INT_ERR",__FILE__,__LINE__,(int)sect,RpWarning,(int)btw,0); ABORT(fp->fs, FR_INT_ERR); } sect += csect; @@ -2913,7 +2913,7 @@ FRESULT f_lseek ( if (res != FR_OK) LEAVE_FF(fp->fs, res); if (fp->flag & FA__ERROR) /* Check abort flag */ { - Report("f_lseek FR_INT_ERR",__FILE__,__LINE__,(int)fp->flag,RpWarning,(int)FA__ERROR,0); + safeReport("f_lseek FR_INT_ERR",__FILE__,__LINE__,(int)fp->flag,RpWarning,(int)FA__ERROR,0); LEAVE_FF(fp->fs, FR_INT_ERR); } @@ -3000,7 +3000,7 @@ FRESULT f_lseek ( clst = create_chain(fp->fs, 0); if (clst == 1) { - Report("f_lseek FR_INT_ERR",__FILE__,__LINE__,(int)clst,RpWarning,(int)FA__ERROR,0); + safeReport("f_lseek FR_INT_ERR",__FILE__,__LINE__,(int)clst,RpWarning,(int)FA__ERROR,0); ABORT(fp->fs, FR_INT_ERR); } if (clst == 0xFFFFFFFF) ABORT(fp->fs, FR_DISK_ERR); @@ -3023,7 +3023,7 @@ FRESULT f_lseek ( if (clst == 0xFFFFFFFF) ABORT(fp->fs, FR_DISK_ERR); if (clst <= 1 || clst >= fp->fs->n_fatent) { - Report("f_lseek FR_INT_ERR",__FILE__,__LINE__,(int)clst,RpWarning,(int)fp->fs->n_fatent,0); + safeReport("f_lseek FR_INT_ERR",__FILE__,__LINE__,(int)clst,RpWarning,(int)fp->fs->n_fatent,0); ABORT(fp->fs, FR_INT_ERR); } fp->clust = clst; @@ -3035,7 +3035,7 @@ FRESULT f_lseek ( nsect = clust2sect(fp->fs, clst); /* Current sector */ if (!nsect) { - Report("f_lseek FR_INT_ERR",__FILE__,__LINE__,(int)nsect,RpWarning,(int)0,0); + safeReport("f_lseek FR_INT_ERR",__FILE__,__LINE__,(int)nsect,RpWarning,(int)0,0); ABORT(fp->fs, FR_INT_ERR); } nsect += ofs / SS(fp->fs); @@ -3227,7 +3227,7 @@ FRESULT f_getfree ( if (stat == 0xFFFFFFFF) { res = FR_DISK_ERR; break; } if (stat == 1) { - Report("f_getfree FR_INT_ERR",__FILE__,__LINE__,(int)stat,RpWarning,(int)0,0); + safeReport("f_getfree FR_INT_ERR",__FILE__,__LINE__,(int)stat,RpWarning,(int)0,0); res = FR_INT_ERR; break; } if (stat == 0) n++; } while (++clst < fs->n_fatent); @@ -3277,7 +3277,7 @@ FRESULT f_truncate ( res = validate(fp); /* Check validity of the object */ if (res == FR_OK) { if (fp->flag & FA__ERROR) { /* Check abort flag */ - Report("f_truncate FR_INT_ERR",__FILE__,__LINE__,(int)fp->flag,RpWarning,(int)0,0); + safeReport("f_truncate FR_INT_ERR",__FILE__,__LINE__,(int)fp->flag,RpWarning,(int)0,0); res = FR_INT_ERR; } else { if (!(fp->flag & FA_WRITE)) /* Check access mode */ @@ -3297,7 +3297,7 @@ FRESULT f_truncate ( if (ncl == 0xFFFFFFFF) res = FR_DISK_ERR; if (ncl == 1) { - Report("f_truncate FR_INT_ERR",__FILE__,__LINE__,(int)ncl,RpWarning,(int)0,0); + safeReport("f_truncate FR_INT_ERR",__FILE__,__LINE__,(int)ncl,RpWarning,(int)0,0); res = FR_INT_ERR; } if (res == FR_OK && ncl < fp->fs->n_fatent) { @@ -3350,7 +3350,7 @@ FRESULT f_unlink ( dclst = ld_clust(dj.fs, dir); if (res == FR_OK && (dir[DIR_Attr] & AM_DIR)) { /* Is it a sub-dir? */ if (dclst < 2) { - Report("f_unlink FR_INT_ERR",__FILE__,__LINE__,(int)dclst,RpWarning,(int)0,0); + safeReport("f_unlink FR_INT_ERR",__FILE__,__LINE__,(int)dclst,RpWarning,(int)0,0); res = FR_INT_ERR; } else { mem_cpy(&sdj, &dj, sizeof (DIR)); /* Check if the sub-dir is empty or not */ diff --git a/Software/Embedded_SW/Embedded/Drivers/I2C_Communication/RFID_NFC/NFC.c b/Software/Embedded_SW/Embedded/Drivers/I2C_Communication/RFID_NFC/NFC.c index 33f154492..1e989d4d1 100644 --- a/Software/Embedded_SW/Embedded/Drivers/I2C_Communication/RFID_NFC/NFC.c +++ b/Software/Embedded_SW/Embedded/Drivers/I2C_Communication/RFID_NFC/NFC.c @@ -118,15 +118,14 @@ RFID_RETURN_CODE RFID_Status = 0; uint8_t Connect_to_RFID_Reder(uint8_t readerID)//2 { RFID_RETURN_CODE RFIDRetValue; - bool isTagValid; uint8_t Status = OK; - - +/* + bool isTagValid; uint32_t newPwd; uint32_t newPACK; uint32_t counter; - int PwdRetVal; +*/ static uint32_t nop = 0; RFID_StartDiscovery(readerID); @@ -187,7 +186,7 @@ NFC_Tag NFC_Tag_U[Max_Readers];//read with updates RFID_RETURN_CODE TagWriteData(RFID_READER_ID readerID) { - uint8_t index = 0; + //uint8_t index = 0; uint32_t dummy = 0; uint32_t Tuint32 = 0; //uint16_t Tuint16 = 0; @@ -375,7 +374,7 @@ RFID_RETURN_CODE TagWriteData(RFID_READER_ID readerID) RFIDRetValue = WriteValue( readerID, &tagInfo, tagMemory, 31, Tuint32 ); - return SUCCESS; + return RFIDRetValue; } diff --git a/Software/Embedded_SW/Embedded/Drivers/I2C_Communication/RFID_NFC/logi-tag/LT_RFID.c b/Software/Embedded_SW/Embedded/Drivers/I2C_Communication/RFID_NFC/logi-tag/LT_RFID.c index 7035d172e..6d6425172 100644 --- a/Software/Embedded_SW/Embedded/Drivers/I2C_Communication/RFID_NFC/logi-tag/LT_RFID.c +++ b/Software/Embedded_SW/Embedded/Drivers/I2C_Communication/RFID_NFC/logi-tag/LT_RFID.c @@ -1209,13 +1209,13 @@ uint32_t crc_ccitt_update(unsigned char * buf, int len) } -void RFID_Test() +RFID_RETURN_CODE RFID_Test() { uint8_t i, readerID = 1; NxpNci_RfIntf_t tagInfo; -uint8_t addressBlock = 0xE3; // NTAG216 - User memory blocks: 0x04-0xE1 = 222 blocks = 888 bytes -uint8_t tagId[]= {0}; +//uint8_t addressBlock = 0xE3; // NTAG216 - User memory blocks: 0x04-0xE1 = 222 blocks = 888 bytes +//uint8_t tagId[]= {0}; uint8_t Serial[] = {'1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F', 'G'}; uint8_t factoryID[] = { '1', '2', '3'}; uint16_t fillingSystem = 55; @@ -1250,12 +1250,12 @@ uint8_t uid[7] = {0}; uint8_t hashValue[16] = {0}; uint8_t newPACK[] = {0x11, 0x22}; uint8_t newPwd[] = {0xFF, 0xFF, 0xFF, 0xFF}; -uint8_t startingBlock = 0x04; +/*uint8_t startingBlock = 0x04; uint8_t pwdAddr = 0xE5; -uint8_t tagMemory[1024]; uint16_t succeededWriteSize = 0; uint16_t succeededReadSize = 0; -bool firstTime = true; +bool firstTime = true;*/ +uint8_t tagMemory[1024]; uint32_t dummy = 0; RFID_RETURN_CODE RFIDRetValue; @@ -1421,6 +1421,6 @@ while(1) } //---------------------------------------------------------------------------- - + return RFIDRetValue; } diff --git a/Software/Embedded_SW/Embedded/Drivers/Uart_Comm/BTSR/BTSR.c b/Software/Embedded_SW/Embedded/Drivers/Uart_Comm/BTSR/BTSR.c index 92337080d..54296e0dc 100644 --- a/Software/Embedded_SW/Embedded/Drivers/Uart_Comm/BTSR/BTSR.c +++ b/Software/Embedded_SW/Embedded/Drivers/Uart_Comm/BTSR/BTSR.c @@ -41,6 +41,8 @@ uint8_t BTSR_RX_Buff[Max_BTSR_RX_Bytes]; uint16_t TX_Timeout = 0xFFFF;//6250 uint16_t RX_Timeout = 0xFFFF;//1 +BTSR_t BTSR[MaxUFeeders]; + typedef enum { BTSR_UART_CONFIG_PAR_1 = (UART_CONFIG_WLEN_8 |UART_CONFIG_STOP_ONE | UART_CONFIG_PAR_ONE), @@ -77,7 +79,6 @@ void U4RX() void uart4_intHandler() { - //static uint8_t nop = 0; //Get interrupt flags unsigned long status = UARTIntStatus(UART4_BASE, 1); @@ -366,6 +367,7 @@ uint8_t Check_Received_CheckSum(uint8_t CODE_STRING, uint8_t Function_Code, uint (Buf[size_include_Checksum - 1] != (Sum >> 8)) ) { Status = ERROR; + ReportWithPackageFilter(ThreadFilter,"BTSR Get Wrong Checksum",__FILE__,__LINE__,(int)CODE_STRING,RpError,(int)Function_Code,0); } } return Status; @@ -405,56 +407,6 @@ uint8_t BTSR_Send_Buf(uint8_t *Buf, uint8_t size) return TxResult; } - -/* -uint8_t BTSR_Send_Buf(uint8_t *Buf, uint8_t size) -{ - int TxResult = 0; - uint8_t i = 1;//change to ADD0 and send the rest of bytes (1..Size) - const uint8_t Save_Size = size; - - BTSR_Change_Comm_Mode(TX_FIRST_BYTE); - Task_sleep (eOneMillisecond); - TxResult |=ROM_UARTCharPutNonBlocking(UART4_BASE,Buf[0]); - - BTSR_Change_Comm_Mode(TX_NOT_FIRST_BYTE); - Task_sleep (eOneMillisecond); - - while(size) - { - if(size <= 16) //FIFO is working for data up to 16 bytes - { - for(; i < Save_Size; i++) - { - TxResult |=ROM_UARTCharPutNonBlocking(UART4_BASE,Buf[i]); - } - size = 0;// all sent - } - else - { - for(; i < 16; i++) - { - TxResult |=ROM_UARTCharPutNonBlocking(UART4_BASE,Buf[i]); - } - size -= 16; - } - - while(HWREG(UART4_BASE + UART_O_FR) & UART_FR_BUSY)//UARTFR - { - if(TX_Timeout) - { - TX_Timeout--; - } - else - return ERROR; - } - } - - UART4_RS485_Direction(RX); - - return TxResult; -} -*/ uint8_t BTSR_Send_Buf_3xADD1(uint8_t *Buf, uint8_t size)//Only for commands with 3 bytes with Address 1 (0x06/0xFD) { int TxResult = 0; @@ -630,90 +582,287 @@ uint8_t BTSR_Read_Status(uint8_t BTSR_Id, uint8_t Application, uint8_t Yarn_Type //---------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------- -//BTSR_ALARM_AND_ENABLING_STATUS_READ -typedef struct + + + + + + + + +//BTSR_ALARM_AND_ENABLING_STATUS_READ BTSR_Status; +//BTSR_DEVICE_INFORMATION_READ BTSR_Info; + +typedef union { - bool D0 : 1;//0 - bool D1 : 1;//1 - bool D2 : 1;//2 - bool D3 : 1;//3 - bool D4 : 1;//4 - bool D5 : 1;//5 - bool D6 : 1;//6 - bool D7 : 1;//7 -}BITS; + struct + { + uint8_t CODE_STRING ; + uint8_t FUNCTION_STRING; + + //DATA_STRING + uint16_t WORK_TENSION ;//1° - 2° + uint16_t OUTPUT_TENSION;//3° - 4° + uint16_t RELAX_YARN ;//5° - 6° + uint8_t INC_DEC_TENSION;//7° + uint8_t INC_DEC_STRETCH;//8° + uint16_t TENSION_ERROR ;//9° - 10° + uint16_t TIME_ALARM ;//11° - 12° + uint8_t RELAX_SPEED ;//13° + uint8_t APPLICATION ;//14° + uint8_t YARN_TYPE ;//15° + uint8_t SPARE[4] ;//16° + uint8_t ALARM_ENABLING ;//20° + uint8_t ABILITAZIONE ;//21° + uint16_t CHECKSUM ; + }Byte; +uint8_t Buf[25]; +}BTSR_ADVANCED_STYLE_LOAD; + +BTSR_ADVANCED_STYLE_LOAD BTSR_AdvStyle_Load; typedef union { - BITS Bit[4]; - uint8_t Byte[4]; -}BTSR_ALARM_AND_ENABLING_STATUS_READ; + struct + { + uint8_t CODE_STRING ; + uint8_t FUNCTION_STRING ; + + //DATA_STRING + uint16_t OUTPUT_TENSION ; + uint16_t WORK_TENSION ; + uint16_t RELAX_YARN ; + uint8_t INC_DEC_TENSION ; + uint8_t INC_DEC_STRETCH ; + uint32_t METER_START ; + uint32_t INC_DEC_METER ; + uint32_t TARGET ; + uint16_t TENSION_ERROR ; + uint16_t ALARM_TIME ; + uint8_t SPARE1[2] ; + uint8_t ALARM_ENABLING ; + uint8_t TARGET_ENABLING ; + uint8_t RELAX_YARN_SPEED; + uint8_t SPARE2[6] ; + + uint16_t CHECKSUM ; + }Byte; +uint8_t Buf[39]; +}BTSR_ADVANCED_TENSION_PROGRAMMING; -BTSR_ALARM_AND_ENABLING_STATUS_READ BTSR_Status; +BTSR_ADVANCED_TENSION_PROGRAMMING BTSR_Adv_Tension_Prog; -void BTSR_Configuration_Set(uint8_t UFeeder_ID) +void BTSR_Configuration_Set(UFeeder_Index UFeeder_i)//15 { memset(BTSR_TX_Buff, 0, Max_BTSR_TX_Bytes); - BTSR_TX_Buff[0] = UFeeder_ID; + BTSR_TX_Buff[0] = BTSR[UFeeder_i].ID; BTSR_TX_Buff[1] = 0x36; - BTSR_TX_Buff[2] = 0x80;//CCW + BTSR_TX_Buff[2] = BTSR[UFeeder_i].DirectionCCW << 7; BTSR_TX_Buff[3] = 0x01;//YYT OFF, UNICO OFF - BTSR_TX_Buff[4] = 0x40;//FLIP DISPLAY + BTSR_TX_Buff[4] = BTSR[UFeeder_i].Flip_Display << 6; BTSR_Calculate_CheckSum(BTSR_TX_Buff,18); - BTSR_Send_Buf(Typology_Set.Buf, 20); + BTSR_Send_Buf(BTSR_TX_Buff, 20); + +} + +void BTSR_Advanced_Style_Load(UFeeder_Index UFeeder_i) +{ + //memset(BTSR_AdvStyle_Load.Buf, 0, Size); + /* + uint8_t Size = sizeof(BTSR_AdvStyle_Load.Buf); + + memset(BTSR_AdvStyle_Load.Buf, 0, Size); +/ + BTSR_AdvStyle_Load.Byte.CODE_STRING = UFeeder_ID; + BTSR_AdvStyle_Load.Byte.FUNCTION_STRING = 0x4B; + + BTSR_AdvStyle_Load.Byte.WORK_TENSION = Tension; + BTSR_AdvStyle_Load.Byte.TENSION_ERROR = Tension_Error; + BTSR_AdvStyle_Load.Byte.TIME_ALARM = Time_Alarm; + BTSR_AdvStyle_Load.Byte.APPLICATION = Application; + BTSR_AdvStyle_Load.Byte.YARN_TYPE = YarnType; + BTSR_AdvStyle_Load.Byte.ALARM_ENABLING = 0x03; // OUTPUT TENSION ENABLED + TENSION ERROR ENABLED +*/ + //BTSR_Calculate_CheckSum(BTSR_AdvStyle_Load.Buf,Size - 2); + + memset(BTSR_TX_Buff, 0, Max_BTSR_TX_Bytes); + + BTSR_TX_Buff[0] = BTSR[UFeeder_i].ID; + BTSR_TX_Buff[1] = 0x4B; + + BTSR_TX_Buff[2] = BTSR[UFeeder_i].Tension & 0XFF;//1 + BTSR_TX_Buff[3] = BTSR[UFeeder_i].Tension >> 8;//2 + + BTSR_TX_Buff[10] = BTSR[UFeeder_i].Tension_Err & 0XFF;//9 + BTSR_TX_Buff[11] = BTSR[UFeeder_i].Tension_Err >> 8;//10 + BTSR_TX_Buff[12] = BTSR[UFeeder_i].Alarm_Time & 0XFF;//11 + BTSR_TX_Buff[13] = BTSR[UFeeder_i].Alarm_Time >> 8;//12 + + + BTSR_TX_Buff[15] = BTSR[UFeeder_i].Application;//14 + BTSR_TX_Buff[16] = BTSR[UFeeder_i].Yarn_Type;//15 + + BTSR_Calculate_CheckSum(BTSR_TX_Buff,23); + + BTSR_Send_Buf(BTSR_TX_Buff,25); + +} + +void BTSR_Advanced_Tension_Prog(UFeeder_Index UFeeder_i ) +{ + + memset(BTSR_TX_Buff, 0, Max_BTSR_TX_Bytes); + + BTSR_TX_Buff[0] = BTSR[UFeeder_i].ID; + BTSR_TX_Buff[1] = 0x39; + + BTSR_TX_Buff[4] = BTSR[UFeeder_i].Tension & 0XFF;//3 + BTSR_TX_Buff[5] = BTSR[UFeeder_i].Tension >> 8;//4 + + BTSR_TX_Buff[22] = BTSR[UFeeder_i].Tension_Err & 0XFF;//21 + BTSR_TX_Buff[23] = BTSR[UFeeder_i].Tension_Err >> 8;//22 + + BTSR_TX_Buff[24] = BTSR[UFeeder_i].Alarm_Time & 0XFF;//23 + BTSR_TX_Buff[25] = BTSR[UFeeder_i].Alarm_Time >> 8;//24 + + BTSR_TX_Buff[28] = 0x01;//27 ‘1’ TENSION ERROR ENABLED + + BTSR_Calculate_CheckSum(BTSR_TX_Buff,37); + + BTSR_Send_Buf(BTSR_TX_Buff,39); +} + +void BTSR_Application_Yarn_Type_Set(UFeeder_Index UFeeder_i) +{ + //APPLICATION_AND_YARN_TYPOLOGY_SET_27 + memset(BTSR_TX_Buff, 0, Max_BTSR_TX_Bytes); + + BTSR_TX_Buff[0] = BTSR[UFeeder_i].ID; + BTSR_TX_Buff[1] = 0x3F; + BTSR_TX_Buff[2] = BTSR[UFeeder_i].Application; + BTSR_TX_Buff[3] = BTSR[UFeeder_i].Yarn_Type; + + BTSR_Calculate_CheckSum(BTSR_TX_Buff,4); + + BTSR_Send_Buf(BTSR_TX_Buff, 6); +} + + +void BTSR_Status_Reset(UFeeder_Index UFeeder_i)//35 +{ + memset(BTSR_TX_Buff, 0, Max_BTSR_TX_Bytes); + + BTSR_TX_Buff[0] = BTSR[UFeeder_i].ID; + BTSR_TX_Buff[1] = 0x27; + + BTSR_TX_Buff[2] = 0x07;//RESET_0 + BTSR_TX_Buff[3] = 0x00;//RESET_1 + BTSR_TX_Buff[4] = 0x00;//SPARE + BTSR_TX_Buff[5] = 0x00;//SPARE + + BTSR_Calculate_CheckSum(BTSR_TX_Buff,6); + + BTSR_Send_Buf(BTSR_TX_Buff, 8); + +} + +void BTSR_Errors_Counter_Reset(UFeeder_Index UFeeder_i)//36 +{ + memset(BTSR_TX_Buff, 0, Max_BTSR_TX_Bytes); + + BTSR_TX_Buff[0] = BTSR[UFeeder_i].ID; + BTSR_TX_Buff[1] = 0x29; + BTSR_TX_Buff[2] = 0x00;//00 - RESETS ALL THE COUNTERS + + BTSR_Calculate_CheckSum(BTSR_TX_Buff,3); + + BTSR_Send_Buf(BTSR_TX_Buff, 5); + +} + +void BTSR_Meters_Total_Counter_Reset(UFeeder_Index UFeeder_i , uint8_t Resolution)//37/39/41 +{ + memset(BTSR_TX_Buff, 0, Max_BTSR_TX_Bytes); + + BTSR_TX_Buff[0] = BTSR[UFeeder_i].ID; + + if(Resolution == LOW) + BTSR_TX_Buff[1] = 0x06; + else + if(Resolution == HIGH) + BTSR_TX_Buff[1] = 0x1E; + else + if(Resolution == HIGHEST) + BTSR_TX_Buff[1] = 0x48; + + BTSR_Calculate_CheckSum(BTSR_TX_Buff,2); + + BTSR_Send_Buf(BTSR_TX_Buff, 4); +} + +void BTSR_Info_Read(UFeeder_Index UFeeder_i) +{ + memset(BTSR_TX_Buff, 0, Max_BTSR_TX_Bytes); + + BTSR_TX_Buff[0] = BTSR[UFeeder_i].ID; + BTSR_TX_Buff[1] = 0x3E; + + BTSR_Calculate_CheckSum(BTSR_TX_Buff,2); + + BTSR_Send_Buf(BTSR_TX_Buff, 4); + +} + +void BTSR_Meters_Total_Counter_Read(UFeeder_Index UFeeder_i , uint8_t Resolution)//37/39/41 +{ + memset(BTSR_TX_Buff, 0, Max_BTSR_TX_Bytes); + + BTSR_TX_Buff[0] = BTSR[UFeeder_i].ID; + + if(Resolution == LOW) + BTSR_TX_Buff[1] = 0x16; + else + if(Resolution == HIGH) + BTSR_TX_Buff[1] = 0x1D; + else + if(Resolution == HIGHEST) + BTSR_TX_Buff[1] = 0x47; + BTSR_Calculate_CheckSum(BTSR_TX_Buff,2); + + BTSR_Send_Buf(BTSR_TX_Buff, 4); } -void BTSR_Alarm_and_Enabling_Status_Read(uint8_t UFeeder_ID) +void BTSR_Alarm_and_Enabling_Status_Read(UFeeder_Index UFeeder_i)//30 { memset(BTSR_TX_Buff, 0, Max_BTSR_TX_Bytes); - BTSR_TX_Buff[0] = UFeeder_ID; + BTSR_TX_Buff[0] = BTSR[UFeeder_i].ID; BTSR_TX_Buff[1] = 0x1C; BTSR_Calculate_CheckSum(BTSR_TX_Buff,2); - BTSR_Send_Buf(Typology_Set.Buf, 4); + BTSR_Send_Buf(BTSR_TX_Buff, 4); } -typedef enum + + +typedef union { - //BTSR_READ - DEVICE_INFORMATION_READ_10 , - ADVANCED_PROGRAMMING_READ_18 , - ADVANCED_TENSION_READ_23 , - APPLICATION_AND_YARN_TYPOLOGY_READ_28 , - ALARM_AND_ENABLING_STATUS_READ_30 , - PC_LINK_READ_32 , - METERS_TOTAL_COUNTER_READ_LOW_37 , - METERS_TOTAL_COUNTER_READ_HIGH_39 , - METER_TOTAL_COUNTER_READ_HIGHEST_41 , - MAX_BTSR_READ , + struct + { + uint32_t Uint32; + uint16_t CheckSum; + }Data; + uint8_t Buf[6]; +}BTSR_METERS; + +BTSR_METERS BTSR_Meters; - //BTSR_SET - //return 0xFA/0xFB/0xF9 - DEVICE_CALIBRATION_11 , - BAUDRATE_SET_13 , - DISPLAY_LANGUAGE_SET_14 , - CONFIGURATION_SET_15 , - ADVANCED_CONFIGURATION_SET_17 , - INPUT_CURRENT_CONTROL_SET_20 , - ADVANCED_TENSION_PROGRAMMING_21 , - ADVANCED_STYLE_LOAD_25 , - APPLICATION_AND_YARN_TYPOLOGY_SET_27 , - WORK_TENSION_AND_OPERATION_STATUS_SET_29 , - ALARM_STATUS_RESET_35 , - RESETS_ALL_THE_COUNTERS_36 , - //return device + Function code - METERS_TOTAL_COUNTER_RESET_LOW_38 , - METERS_TOTAL_COUNTER_RESET_HIGH_40 , - METERS_TOTAL_COUNTER_RESET_HIGHEST_42 , - MAX_BTSR_SET -}BTSR_CMD; #define Get_Set_resp 5 #define Set_Command 6 @@ -721,21 +870,22 @@ typedef enum #define Get_Read_resp 7 #define Read_Command 8 -BTSR_CMD BTSR_command_Stage[MAX_BTSR_SET]; - -uint8_t BTSR_State_Machine(uint8_t UFeeder_ID) +uint8_t BTSR_State_Machine(UFeeder_Index UFeeder_i) { uint8_t status = OK; - uint8_t i; + uint8_t i,j; + float temp = 0.0; + + //BTSR_Init(); for(i = DEVICE_CALIBRATION_11; i < MAX_BTSR_SET; i++) { - if(BTSR_command_Stage[i] == Get_Set_resp) + if(BTSR[UFeeder_i].Command[i] == Get_Set_resp) { - if((i >= DEVICE_CALIBRATION_11) && (i <= RESETS_ALL_THE_COUNTERS_36) /*&& (BTSR_RX_Buff[0] != BTSR_RISP_OK)*/) + if((i >= DEVICE_CALIBRATION_11) && (i <= RESETS_ALL_THE_COUNTERS_36) && (BTSR_RX_Buff[0] != BTSR_RISP_OK)) { status = ERROR; - BTSR_command_Stage[i] = BTSR_RX_Buff[0]; + BTSR[UFeeder_i].Command[i] = BTSR_RX_Buff[0]; //print response + command ID } else if(((i == METERS_TOTAL_COUNTER_RESET_LOW_38) && (BTSR_RX_Buff[1] != 0x06)) || @@ -743,21 +893,43 @@ uint8_t BTSR_State_Machine(uint8_t UFeeder_ID) ((i == METERS_TOTAL_COUNTER_RESET_HIGHEST_42) && (BTSR_RX_Buff[1] != 0x48)) ) { status = ERROR; - BTSR_command_Stage[i] = BTSR_RX_Buff[1]; + BTSR[UFeeder_i].Command[i] = BTSR_RX_Buff[1]; //print response + command ID } - //print response + command ID - BTSR_command_Stage[i] = OK; + else//print response + command ID + BTSR[UFeeder_i].Command[i] = BTSR_RX_Buff[0];//OK; } - if(BTSR_command_Stage[i] == Set_Command) + if(BTSR[UFeeder_i].Command[i] == Set_Command) { - if(i == CONFIGURATION_SET_15) + switch(i) { - BTSR_Configuration_Set(UFeeder_ID); + case CONFIGURATION_SET_15: + BTSR_Configuration_Set(UFeeder_i); + break; + case ADVANCED_TENSION_PROGRAMMING_21: + BTSR_Advanced_Tension_Prog(UFeeder_i); + break; + case APPLICATION_AND_YARN_TYPOLOGY_SET_27: + BTSR_Application_Yarn_Type_Set(UFeeder_i); + break; + case ALARM_STATUS_RESET_35: + BTSR_Status_Reset(UFeeder_i); + break; + case RESETS_ALL_THE_COUNTERS_36: + BTSR_Errors_Counter_Reset(UFeeder_i); + break; + case METERS_TOTAL_COUNTER_RESET_LOW_38: + BTSR_Meters_Total_Counter_Reset(UFeeder_i, LOW); + break; + case METERS_TOTAL_COUNTER_RESET_HIGH_40: + BTSR_Meters_Total_Counter_Reset(UFeeder_i, HIGH); + break; + case METERS_TOTAL_COUNTER_RESET_HIGHEST_42: + BTSR_Meters_Total_Counter_Reset(UFeeder_i, HIGHEST); + break; } - - BTSR_command_Stage[i] = Get_Set_resp; + BTSR[UFeeder_i].Command[i] = Get_Set_resp; return status;//Only one command in cycle } } @@ -765,25 +937,66 @@ uint8_t BTSR_State_Machine(uint8_t UFeeder_ID) for(i = DEVICE_INFORMATION_READ_10; i < MAX_BTSR_READ; i++) { - if(BTSR_command_Stage[i] == Get_Read_resp) + if(BTSR[UFeeder_i].Command[i] == Get_Read_resp) { // Add CRC check if(i == ALARM_AND_ENABLING_STATUS_READ_30) { - for(i = 0; i < 4; i++) - BTSR_Status.Byte[i] = BTSR_RX_Buff[i]; + for(j = 0; j < 6; j++) + BTSR[UFeeder_i].Status.Byte[j] = BTSR_RX_Buff[j]; + } + else + if(i == DEVICE_INFORMATION_READ_10) + { + for(j = 0; j < 12; j++) + BTSR[UFeeder_i].Info.Buf[j] = BTSR_RX_Buff[j]; + status |= Check_Received_CheckSum(BTSR[UFeeder_i].ID, 0x3E, BTSR[UFeeder_i].Info.Buf, 12); + ReportWithPackageFilter(ThreadFilter,"BTSR VERSION",__FILE__,UFeeder_i,(BTSR[UFeeder_i].Info.Byte.BOARD_HW_VERSION << 8) | BTSR[UFeeder_i].Info.Byte.BOOTLOADER_SW_VERSION,RpMessage,(BTSR[UFeeder_i].Info.Byte.SW_VERSION << 8) | BTSR[UFeeder_i].Info.Byte.SW_UNDER_VERSION,0); + } + else + if((i == METERS_TOTAL_COUNTER_READ_LOW_37) || (i == METERS_TOTAL_COUNTER_READ_HIGH_39) || (i == METER_TOTAL_COUNTER_READ_HIGHEST_41)) + { + for(j = 0; j < 6; j++) + BTSR_Meters.Buf[j] = BTSR_RX_Buff[j]; + status |= Check_Received_CheckSum(BTSR[UFeeder_i].ID, 0x16, BTSR_Meters.Buf, 6); + + temp = (float)(BTSR_Meters.Data.Uint32) * PI * BTSR[UFeeder_i].Radius_Meter; + if(i == METERS_TOTAL_COUNTER_READ_HIGH_39) + temp /=12.0; + else + if(i == METER_TOTAL_COUNTER_READ_HIGHEST_41) + temp /=750.0; + + BTSR[UFeeder_i].LengthInMeter = temp; } - BTSR_command_Stage[i] = 0; + + memset(BTSR_RX_Buff, 0, Max_BTSR_RX_Bytes); + BTSR[UFeeder_i].Command[i] = BTSR_RISP_OK; } + //else//? - if(BTSR_command_Stage[i] == Read_Command) + if(BTSR[UFeeder_i].Command[i] == Read_Command) { - - if(i == ALARM_AND_ENABLING_STATUS_READ_30) + switch(i) { - BTSR_Alarm_and_Enabling_Status_Read(UFeeder_ID); + case ALARM_AND_ENABLING_STATUS_READ_30: + BTSR_Alarm_and_Enabling_Status_Read(UFeeder_i); + break; + case DEVICE_INFORMATION_READ_10: + BTSR_Info_Read(UFeeder_i); + break; + case METERS_TOTAL_COUNTER_READ_LOW_37: + BTSR_Meters_Total_Counter_Read(UFeeder_i, LOW); + break; + case METERS_TOTAL_COUNTER_READ_HIGH_39: + BTSR_Meters_Total_Counter_Read(UFeeder_i, HIGH); + break; + case METER_TOTAL_COUNTER_READ_HIGHEST_41: + BTSR_Meters_Total_Counter_Read(UFeeder_i, HIGHEST); + break; } - BTSR_command_Stage[i] = Get_Read_resp; + + BTSR[UFeeder_i].Command[i] = Get_Read_resp; return status;//Only one command in cycle } } @@ -791,3 +1004,38 @@ uint8_t BTSR_State_Machine(uint8_t UFeeder_ID) return status; } + +void BTSR_Settings(UFeeder_Index UFeeder_i, uint8_t Application, uint8_t Yarn_Type, uint16_t Tension, uint16_t Tension_Err, uint16_t Alarm_Time, uint8_t Length_Resolution ) +{ + BTSR[UFeeder_i].Application = SHOES; + BTSR[UFeeder_i].Yarn_Type = ALL_YARNS3; + BTSR[UFeeder_i].Tension = Tension; + BTSR[UFeeder_i].Tension_Err = Tension_Err; + BTSR[UFeeder_i].Alarm_Time = Alarm_Time; + BTSR[UFeeder_i].Length_Resolution = Length_Resolution; + + BTSR[UFeeder_i].Command[ADVANCED_TENSION_PROGRAMMING_21] = Set_Command; + BTSR[UFeeder_i].Command[APPLICATION_AND_YARN_TYPOLOGY_SET_27] = Set_Command; + BTSR[UFeeder_i].Command[ALARM_AND_ENABLING_STATUS_READ_30] = Read_Command; + BTSR[UFeeder_i].Command[ALARM_STATUS_RESET_35] = Set_Command; + BTSR[UFeeder_i].Command[RESETS_ALL_THE_COUNTERS_36] = Set_Command; + BTSR[UFeeder_i].Command[METER_TOTAL_COUNTER_READ_HIGHEST_41] = Set_Command; + BTSR[UFeeder_i].Command[METERS_TOTAL_COUNTER_RESET_HIGHEST_42] = Set_Command; +} + + + +void BTSR_Init() +{ + //RUFeeder1 + BTSR[RUFeeder1].ID = 0x01; + BTSR[RUFeeder1].Flip_Display = true; + BTSR[RUFeeder1].DirectionCCW = true; + BTSR[RUFeeder1].Radius_Meter = 0.03;//need to update the correct value + + BTSR[RUFeeder1].Command[CONFIGURATION_SET_15] = Set_Command; + BTSR[RUFeeder1].Command[DEVICE_INFORMATION_READ_10] = Read_Command; + + BTSR_Settings(RUFeeder1, SHOES, ALL_YARNS3, 1000, 10, 5, HIGHEST);//Test!!! --- need to move to RML +} + diff --git a/Software/Embedded_SW/Embedded/Drivers/Uart_Comm/BTSR/BTSR.h b/Software/Embedded_SW/Embedded/Drivers/Uart_Comm/BTSR/BTSR.h index 14fda8f19..984313c22 100644 --- a/Software/Embedded_SW/Embedded/Drivers/Uart_Comm/BTSR/BTSR.h +++ b/Software/Embedded_SW/Embedded/Drivers/Uart_Comm/BTSR/BTSR.h @@ -48,12 +48,117 @@ typedef enum BTSR_RISP_OUT_OF_RANFE = 0xF9, }BTSR_RISP_BYTE; +typedef enum +{ + //BTSR_READ + DEVICE_INFORMATION_READ_10 ,//0 + ADVANCED_PROGRAMMING_READ_18 ,//1 + ADVANCED_TENSION_READ_23 ,//2 + APPLICATION_AND_YARN_TYPOLOGY_READ_28 ,//3 + ALARM_AND_ENABLING_STATUS_READ_30 ,//4 + PC_LINK_READ_32 ,//5 + METERS_TOTAL_COUNTER_READ_LOW_37 ,//6 + METERS_TOTAL_COUNTER_READ_HIGH_39 ,//7 + METER_TOTAL_COUNTER_READ_HIGHEST_41 ,//8 + MAX_BTSR_READ ,//9 + + //BTSR_SET + //return 0xFA/0xFB/0xF9 + DEVICE_CALIBRATION_11 ,//10 + BAUDRATE_SET_13 ,//11 + DISPLAY_LANGUAGE_SET_14 ,//12 + CONFIGURATION_SET_15 ,//13 + ADVANCED_CONFIGURATION_SET_17 ,//14 + INPUT_CURRENT_CONTROL_SET_20 ,//15 + ADVANCED_TENSION_PROGRAMMING_21 ,//16 + ADVANCED_STYLE_LOAD_25 ,//17 + APPLICATION_AND_YARN_TYPOLOGY_SET_27 ,//18 + WORK_TENSION_AND_OPERATION_STATUS_SET_29 ,//19 + ALARM_STATUS_RESET_35 ,//20 + RESETS_ALL_THE_COUNTERS_36 ,//21 + //return device + Function code + METERS_TOTAL_COUNTER_RESET_LOW_38 ,//22 + METERS_TOTAL_COUNTER_RESET_HIGH_40 ,//23 + METERS_TOTAL_COUNTER_RESET_HIGHEST_42 ,//24 + MAX_BTSR_SET //25 +}BTSR_CMD; + +typedef enum +{ + RUFeeder1 = 0, + //RUFeeder2 = 1, + //RUFeeder3 = 2, + //RUFeeder4 = 3, + + MaxUFeeders, +}UFeeder_Index; + +//BTSR_ALARM_AND_ENABLING_STATUS_READ +typedef struct +{ + bool D0 : 1;//0 + bool D1 : 1;//1 + bool D2 : 1;//2 + bool D3 : 1;//3 + bool D4 : 1;//4 + bool D5 : 1;//5 + bool D6 : 1;//6 + bool D7 : 1;//7 +}BITS; + + +typedef union +{ + BITS Bit[6]; + uint8_t Byte[6]; +}BTSR_ALARM_AND_ENABLING_STATUS_READ; + +typedef union +{ + struct + { + uint8_t SW_VERSION;//0XDE + uint8_t SW_UNDER_VERSION;//0X01 + uint8_t BYTE_U0X55;//0X55 + uint8_t BYTE_F0X46;//0X46 + uint8_t PRODUCT_CODE;//0X13 + uint8_t TENSION_SENSOR_END_SCALE;//0X65 + uint8_t BOARD_HW_VERSION;//0X02 + uint8_t BOOTLOADER_SW_VERSION;//0X0A + uint8_t BYTE_0X32;//0X32 + uint8_t SPARE;//0X00 + uint8_t CHECKSUM_LSB;//0X60 + uint8_t CHECKSUM_MSB;//0X01 + }Byte; +uint8_t Buf[12]; +}BTSR_DEVICE_INFORMATION_READ; + +typedef struct +{ + uint8_t ID; + bool DirectionCCW; + bool Flip_Display; + float Radius_Meter; + uint8_t Command[MAX_BTSR_SET]; + uint8_t Application; + uint8_t Yarn_Type; + uint16_t Tension; + uint16_t Tension_Err; + uint16_t Alarm_Time; + uint8_t Length_Resolution; + + float LengthInMeter; + BTSR_ALARM_AND_ENABLING_STATUS_READ Status; + BTSR_DEVICE_INFORMATION_READ Info; + +}BTSR_t; + extern uint8_t BTSR_RX_Buff[Max_BTSR_RX_Bytes]; unsigned long UARTStatus(); bool BTSR_Change_Comm_Mode(uint8_t Mode); -uint8_t BTSR_Auto_Identify(uint8_t BTSR_Id);//AUTOMATIC IDENTIFICATION PROCEDURE (IDENTIFY) -uint8_t BTSR_Set_Parmeters(uint8_t BTSR_Id, uint8_t Application, uint8_t Yarn_Type ); +uint8_t BTSR_Auto_Identify(uint8_t BTSR_ID);//AUTOMATIC IDENTIFICATION PROCEDURE (IDENTIFY) +uint8_t BTSR_Set_Parmeters(uint8_t BTSR_ID, uint8_t Application, uint8_t Yarn_Type ); uint8_t BTSR_Send_Buf(uint8_t *Buf, uint8_t size); uint8_t BTSR_RECEIVE_Buf(uint8_t *Buf, uint8_t size); @@ -62,4 +167,7 @@ uint8_t Check_Received_CheckSum(uint8_t CODE_STRING, uint8_t Function_Code, uint uint8_t BTSR_Send_Buf_3xADD1(uint8_t *Buf, uint8_t size);//Only for commands with 3 bytes with Address 1 (0x06/0xFD) void InitConsole_BTSR_UART4(int32_t ui32SysClock); +uint8_t BTSR_State_Machine(UFeeder_Index UFeeder_i); +void BTSR_Init(); + #endif /* DRIVERS_UART_COMM_BTSR_BTSR_H_ */ diff --git a/Software/Embedded_SW/Embedded/Drivers/flash_ram/MCU_E2Prom.h b/Software/Embedded_SW/Embedded/Drivers/flash_ram/MCU_E2Prom.h index 2102d1716..aee812973 100644 --- a/Software/Embedded_SW/Embedded/Drivers/flash_ram/MCU_E2Prom.h +++ b/Software/Embedded_SW/Embedded/Drivers/flash_ram/MCU_E2Prom.h @@ -38,7 +38,7 @@ typedef enum { EEPROM_ALARM_SUPPORT, EEPROM_ORIFICE1_ZERO_VALUE, EEPROM_ORIFICE3_ZERO_VALUE, - EEPROM_WASTE_TANK_ZERO_VALUE, + EEPROM_LOCAL_TIME, EEPROM_PULLER_TENSION_POSITION, EEPROM_WINDER_TENSION_POSITION, EEPROM_INIT_FAILURE_COUNTER, diff --git a/Software/Embedded_SW/Embedded/Main.c b/Software/Embedded_SW/Embedded/Main.c index 541fff0a7..899143c36 100644 --- a/Software/Embedded_SW/Embedded/Main.c +++ b/Software/Embedded_SW/Embedded/Main.c @@ -13,6 +13,7 @@ */ #include <driverlib/sysctl.h> #include "driverlib/eeprom.h" +#include "driverlib/hibernate.h" #include "Drivers/USB_Communication/USBCDCD.h" #include "Drivers/I2C_Communication/I2C.h" @@ -168,6 +169,8 @@ Void errHook(Error_Block *eb) { FirstErrorFlag = false; MCU_E2PromProgram(EEPROM_INIT_FAILURE_COUNTER,InitFailures+1); + utilsStoreLocalTime(); + len = usnprintf(message, 300, "\r\nerror task 0x%x %s context prev task 0x%x,%s", PrevTask,Task_Handle_name(PrevTask),NextTask,Task_Handle_name(NextTask)); f_write(LogFileHandle,message,len,&Bytes ); site = Error_getSite(eb); @@ -234,6 +237,7 @@ void Init_EVB() int main(void) { FRESULT Fresult = FR_OK; + time_t time_store = 0; // Enable interrupts to the processor. // ROM_IntMasterDisable(); @@ -301,6 +305,13 @@ int main(void) #endif } + utilsInit(ui32SysClock); + MCU_E2PromRead(EEPROM_LOCAL_TIME,&time_store); + if (time_store) + { + ulocaltime(time_store+5,&LocalTime); + HibernateCalendarSet(&LocalTime); + } OpenLogFile(); Data = MCU_E2PromEmbeddedVersionRead(); memcpy (&Version,&Data,4); @@ -344,6 +355,10 @@ int main(void) I2C_DispRFIDTask_Init();//I2C Task for dispensers & RFID +#ifdef USE_UART4_FOR_BTSR + BTSR_Init(); +#endif + #if defined(USE_RFID_LOGIC) || defined(USE_RFID_STUB) //Trigger_RFID_Init(); //Init_IFS();//must be done after FPGA_Init Init_IFS(); @@ -367,7 +382,6 @@ int main(void) #endif CommunicationTaskInit(); - utilsInit(ui32SysClock); #ifndef EVALUATION_BOARD //Turn_the_Blower_On();//Turn on with the Default_Voltage diff --git a/Software/Embedded_SW/Embedded/Modules/Control/MillisecTask.c b/Software/Embedded_SW/Embedded/Modules/Control/MillisecTask.c index 5c0ff852c..fd861a985 100644 --- a/Software/Embedded_SW/Embedded/Modules/Control/MillisecTask.c +++ b/Software/Embedded_SW/Embedded/Modules/Control/MillisecTask.c @@ -22,6 +22,10 @@ #include "MillisecTask.h" #include <driverlib/timer.h> +#include <time.h> +#include "Common/Utilities/Utils.h" +#include "driverlib/hibernate.h" + #include <Drivers/SSI_Comm/SSI_Comm.h> #include <Drivers/SSI_Comm/Speed_Sensor/Speed_Sensor.h> #include <Drivers/SSI_Comm/Dancer/Dancer.h> @@ -72,6 +76,7 @@ #include <Drivers/I2C_Communication/RFID_NFC/RFIDTagInfo.h> #include <Drivers/I2C_Communication/RFID_NFC/I2C_IFS_Mux.h> #include <Drivers/I2C_Communication/RFID_NFC/NFC.h> +#include "Drivers/Uart_Comm/BTSR/BTSR.h" Task_Handle Millisecond_Task_Handle; /******************** Definitions ********************************************/ @@ -730,11 +735,21 @@ uint32_t MillisecLowLoop(uint32_t tick) } } #endif + + #ifdef USE_UART4_FOR_BTSR + //call every 100mSec + BTSR_State_Machine(RUFeeder1); + #endif } if (Gradient_Tick) DispensersCollectionCall(); if (O200Millisecond_Tick) { + + ulocaltime(umktime(&LocalTime)+1,&LocalTime); + HibernateCalendarSet(&LocalTime); + //ReportWithPackageFilter(ThreadFilter,"Time: ",__FILE__,LocalTime.tm_min,LocalTime.tm_sec,RpWarning,(int) msec_millisecondCounter,0); + Trigger_WHS_MAX11614_Read_allADC(); FPGA_GetAllDispensersValveBusyOCD(); Read_Dryer_Fan_Tacho(); diff --git a/Software/Embedded_SW/Embedded/Modules/General/Safety.c b/Software/Embedded_SW/Embedded/Modules/General/Safety.c index a70866fd6..725316453 100644 --- a/Software/Embedded_SW/Embedded/Modules/General/Safety.c +++ b/Software/Embedded_SW/Embedded/Modules/General/Safety.c @@ -84,7 +84,7 @@ uint32_t Safety_Main_State(uint32_t IfIndex, uint32_t BusyFlag) } else { - if (Get_COVER_1_State(DryerDoor)) + if (Get_COVER_1_State(DryerDoor))//"1" - Door open { //report and handle dryer door open AlarmHandlingSetAlarm(EVENT_TYPE__DRYER_DOOR_OPEN, true); diff --git a/Software/Embedded_SW/Embedded/Modules/Heaters/Heaters_ex.h b/Software/Embedded_SW/Embedded/Modules/Heaters/Heaters_ex.h index 7c11b12bf..7e3f6252f 100644 --- a/Software/Embedded_SW/Embedded/Modules/Heaters/Heaters_ex.h +++ b/Software/Embedded_SW/Embedded/Modules/Heaters/Heaters_ex.h @@ -40,6 +40,8 @@ void Heaters_SetOverHeatTimeOutValues(uint32_t OverHeatTimeout, uint32_t UnderHe void Heaters_SetOperationLimits(int acheatersloweroperationlimit,int acheatersupperoperationlimit,int dcheatersloweroperationlimit,int dcheatersupperoperationlimit); uint32_t DrierHeaterVoltageSetup(void); +//this function returns preparation ratio for the most cool heater (current temperature/ target temerature) +double HeatersPrepareProgress(void); uint32_t HeatersEnd(void); void HeatersControlStart(void); diff --git a/Software/Embedded_SW/Embedded/Modules/Heaters/Heaters_print.c b/Software/Embedded_SW/Embedded/Modules/Heaters/Heaters_print.c index db7261090..d48139255 100644 --- a/Software/Embedded_SW/Embedded/Modules/Heaters/Heaters_print.c +++ b/Software/Embedded_SW/Embedded/Modules/Heaters/Heaters_print.c @@ -574,6 +574,27 @@ uint32_t HeatersSingleHeaterEnd(int HeaterId) return status; } +//this function returns preparation ratio for the most cool heater (current temperature/ target temerature) +double HeatersPrepareProgress(void) +{ + HardwarePidControlType i; + double MaxDifference = 1.00,temp = 0; + for (i=0;i<HEATER_TYPE_MAX_HEATERS;i++) + { + if(HeaterCmd[i].targettemperatue) + { + if (MillisecGetTemperatures(HeaterId2PT100Id[i])>=HeaterCmd[i].targettemperatue) + continue; + temp = MillisecGetTemperatures(HeaterId2PT100Id[i])/HeaterCmd[i].targettemperatue; + if (temp<MaxDifference) + MaxDifference = temp; + } + } + Report("HeatersPrepareProgress" ,__FILE__,__LINE__,(int)(MaxDifference*100),RpWarning,0,0); + + return MaxDifference; + +} uint32_t HeatersEnd(void) diff --git a/Software/Embedded_SW/Embedded/Modules/IDS/IDS_dispenser.c b/Software/Embedded_SW/Embedded/Modules/IDS/IDS_dispenser.c index 4ee94dae4..4d103395c 100644 --- a/Software/Embedded_SW/Embedded/Modules/IDS/IDS_dispenser.c +++ b/Software/Embedded_SW/Embedded/Modules/IDS/IDS_dispenser.c @@ -33,6 +33,29 @@ uint32_t OpenValveTimeout = 10; #define DISPENSER_BUILD_PRESSURE_TIMEOUT 120000 #define DISPENSER_BUILD_PRESSURE_LAG 50 #define DEFAULT_NANOLITER_PER_PULSE 2.34 + +FPGA_GPI_ENUM Dispenser_Id_to_LS_50_Id[MAX_SYSTEM_DISPENSERS] = { + GPI_LS_DISPENSER_50_1, //MOTO_DISPENSER_1 = 6, + GPI_LS_DISPENSER_50_2, //MOTO_DISPENSER_2 = 7, + GPI_LS_DISPENSER_50_3, //MOTO_DISPENSER_3 = 8, + GPI_LS_DISPENSER_50_4, //MOTO_DISPENSER_4 = 9, + GPI_LS_DISPENSER_50_5, //MOTO_DISPENSER_5 = 10, + GPI_LS_DISPENSER_50_6, //MOTO_DISPENSER_6 = 11, + GPI_LS_DISPENSER_50_7, //MOTO_DISPENSER_7 = 12, + GPI_LS_DISPENSER_50_8, //MOTO_DISPENSER_8 = 13, +}; +FPGA_GPI_ENUM Dispenser_Id_to_LS_25_Id[MAX_SYSTEM_DISPENSERS] = { + GPI_LS_DISPENSER_25_1, //MOTO_DISPENSER_1 = 6, + GPI_LS_DISPENSER_25_2, //MOTO_DISPENSER_2 = 7, + GPI_LS_DISPENSER_25_3, //MOTO_DISPENSER_3 = 8, + GPI_LS_DISPENSER_25_4, //MOTO_DISPENSER_4 = 9, + GPI_LS_DISPENSER_25_5, //MOTO_DISPENSER_5 = 10, + GPI_LS_DISPENSER_25_6, //MOTO_DISPENSER_6 = 11, + GPI_LS_DISPENSER_25_7, //MOTO_DISPENSER_7 = 12, + GPI_LS_DISPENSER_25_8, //MOTO_DISPENSER_8 = 13, +}; +bool DispenserDirectionFlag_50[MAX_SYSTEM_DISPENSERS] = {0,0,0,0,0,0,0,0}; +bool DispenserDirectionFlag_25[MAX_SYSTEM_DISPENSERS] = {0,0,0,0,0,0,0,0}; uint32_t DispenserPrepareSpeed = DISPENSER_BUILD_PRESSURE_SPEED; double DispenserPreparePressure = DISPENSER_BUILD_PRESSURE_LIMIT; uint32_t DispenserPrepareTimeout = DISPENSER_BUILD_PRESSURE_TIMEOUT; @@ -380,6 +403,16 @@ void IDS_Dispenser_Content_Calculation (char DispenserId) { ReportWithPackageFilter(IDSFilter,"IDS_Dispenser_Data ",__FILE__,DispenserId,(int)IDS_Dispenser_Data[DispenserId].consumedinnanolitter,RpWarning,(int)CurrentDispenserSpeed[DispenserId],0); } + if ((Dispenser_Id_to_LS_50_Id[DispenserId])&&(DispenserDirectionFlag_50[DispenserId]==false)) + { + DispenserDirectionFlag_50[DispenserId]= true; + ReportWithPackageFilter(IDSFilter,"Dispenser at 50% ",__FILE__,DispenserId,(int)IDS_Dispenser_Data[DispenserId].consumedinnanolitter,RpWarning,(int)65000000,0); + } + if ((Dispenser_Id_to_LS_25_Id[DispenserId])&&(DispenserDirectionFlag_25[DispenserId]==false)) + { + DispenserDirectionFlag_25[DispenserId]= true; + ReportWithPackageFilter(IDSFilter,"Dispenser at 25% ",__FILE__,DispenserId,(int)IDS_Dispenser_Data[DispenserId].consumedinnanolitter,RpWarning,(int)32500000,0); + } } if (DispenserId == 0) { @@ -410,6 +443,8 @@ void IDS_Dispenser_RefillStarted (char DispenserId,char MicroSteps) IDS_Dispenser_Data[DispenserId].nanolitterperpulse = assumedFlow; IDS_Dispenser_Data[DispenserId].microsteps = 1; IDS_Dispenser_Data[DispenserId].direction = 0;*/ + DispenserDirectionFlag_50[DispenserId] = false; + DispenserDirectionFlag_25[DispenserId] = false; ReportWithPackageFilter(IDSFilter,"IDS_Dispenser_RefillStarted",__FILE__,__LINE__,(int)DispenserId,RpWarning,(int)(CurrentDispenserSpeed[DispenserId]),0); } void IDS_Dispenser_RefillEnded (char DispenserId,char MicroSteps) @@ -419,6 +454,8 @@ void IDS_Dispenser_RefillEnded (char DispenserId,char MicroSteps) IDS_Dispenser_Data[DispenserId].numberofrefills++; //IDS_Dispenser_Data[DispenserId].direction = 1; IDS_Dispenser_Data[DispenserId].consumedinnanolitter = 0; + DispenserDirectionFlag_50[DispenserId] = false; + DispenserDirectionFlag_25[DispenserId] = false; ReportWithPackageFilter(IDSFilter,"IDS_Dispenser_RefillEnded",__FILE__,__LINE__,(int)DispenserId,RpWarning,(int)IDS_Dispenser_Data[DispenserId].numberofrefills,0); } void DispenserDataRequestFunc(MessageContainer* requestContainer) diff --git a/Software/Embedded_SW/Embedded/Modules/IDS/IDS_ex.h b/Software/Embedded_SW/Embedded/Modules/IDS/IDS_ex.h index 0a8060496..ceb504099 100644 --- a/Software/Embedded_SW/Embedded/Modules/IDS/IDS_ex.h +++ b/Software/Embedded_SW/Embedded/Modules/IDS/IDS_ex.h @@ -60,6 +60,9 @@ void IDS_Dispenser_Content_Init (void); uint32_t IDSPrepareState(void *JobDetails); void IDSPrepareStart(void); +//this function returns preparation ratio for the most cool heater (current temperature/ target temerature) +double IdsPrepareProgress(void); + uint32_t IDSPreSegmentState(void *SegmentDetails, int SegmentId); uint32_t IDSCheckSegmentData(void *SegmentDetails, int SegmentId); uint32_t IDSSegmentState(void *SegmentDetails, int SegmentId); diff --git a/Software/Embedded_SW/Embedded/Modules/IDS/IDS_maint.c b/Software/Embedded_SW/Embedded/Modules/IDS/IDS_maint.c index 1528a9a3b..9c422444f 100644 --- a/Software/Embedded_SW/Embedded/Modules/IDS/IDS_maint.c +++ b/Software/Embedded_SW/Embedded/Modules/IDS/IDS_maint.c @@ -195,6 +195,7 @@ uint32_t IDS_Honing_Timeout_Callback(uint32_t DispenserId, uint32_t ReadValue) ReportWithPackageFilter(IDSFilter,"IDS_Honing_Timeout_Callback",__FILE__,DispenserId,(int)(GetDispenserPressure(DispenserId)*100),RpWarning,2000,0); SafeRemoveControlCallback(DispenserHomingTimeoutControlId[DispenserId], IDS_Honing_Timeout_Callback ); AlarmHandlingSetAlarm (DispenserId+EVENT_TYPE__DISPENSER_1_REFILL_FAILURE,true); + return OK; } uint32_t IDS_HomeDispenserCallback(uint32_t motorId, uint32_t ReadValue) diff --git a/Software/Embedded_SW/Embedded/Modules/IDS/IDS_print.c b/Software/Embedded_SW/Embedded/Modules/IDS/IDS_print.c index fb7529b46..aaa371aac 100644 --- a/Software/Embedded_SW/Embedded/Modules/IDS/IDS_print.c +++ b/Software/Embedded_SW/Embedded/Modules/IDS/IDS_print.c @@ -459,11 +459,31 @@ c. Go to step 2.a x Segment.BrushStopsCount. uint32_t DispenserPrepareControlId = 0xFF; int NumOfActiveDispensers = 0; int DispenserBuildTimeCounter = 0; - double TargetNumberOfStepsPreRun,MaximalPressurePreRun; + double TargetNumberOfStepsPreRun = 120000,MaximalPressurePreRun = 4; int DispenserTotalPrepareSteps[MAX_SYSTEM_DISPENSERS]; bool DispenserLastMovementDown[MAX_SYSTEM_DISPENSERS]; #define PRESSURE_READ_TIME_GAP 100 + //this function returns preparation ratio for the most cool heater (current temperature/ target temerature) + double IdsPrepareProgress(void) + { + HardwarePidControlType i; + double MaxDifference = 1.00,temp = 0; + if (TargetNumberOfStepsPreRun == 0) + return 1.00; + for (i = 0; i < MAX_DYE_DISPENSERS; i++) + { + if (DispenserUsedInJob[i] == false) //we actually should check for all dispensers + continue; + if (DispenserTotalPrepareSteps[i]>TargetNumberOfStepsPreRun) + continue; + temp = DispenserTotalPrepareSteps[i]/TargetNumberOfStepsPreRun; + if (temp<MaxDifference) + MaxDifference = temp; + } + Report("IdsPrepareProgress" ,__FILE__,__LINE__,(int)(MaxDifference*100),RpWarning,0,0); + return MaxDifference; + } uint32_t InactiveDispenserHome(uint32_t DispenserId, uint32_t ReadValue) { @@ -1523,7 +1543,7 @@ uint32_t IDSPreSegmentState(void *SegmentDetails, int SegmentId) //******************************************************************************************************************** uint32_t SegmentNumOfBrushStops = 0; -double BrushStopTime = 0; +double BrushStopTime = 0,BrushStopOffset = 0,PrevBrushStopOffset = 0; uint32_t BrushStopCounter = 0; uint32_t BrushStopStartTime = 0,BrushStopLength = 0; @@ -1532,7 +1552,16 @@ void IDS_StartBrushStop(int n_dispensers, JobDispenser** Dispensers) int Dispenser_i,DispenserId; TimerMotors_t HW_Motor_Id; double segmentfirst_speed; + double tempBrushStopTime = 0; //ReportWithPackageFilter(IDSFilter,"IDS_StartBrushStop",__FILE__,__LINE__,(int)JobBrushStopId,RpWarning,(int)0,0); + PrevBrushStopOffset = BrushStopOffset; + BrushStopOffset = FileBrushStop->offsetmeters; + tempBrushStopTime = (BrushStopOffset-PrevBrushStopOffset); //length in meters + tempBrushStopTime = ((tempBrushStopTime*100)/dyeingspeed);//brushstop in seconds (length in cetimeters/ centimeters per second) + tempBrushStopTime *= 1000; // milliseconds + if (tempBrushStopTime > 100) + BrushStopTime = tempBrushStopTime; + ReportWithPackageFilter(IDSFilter,"IDS_StartBrushStop offset", __FILE__, tempBrushStopTime,(int)(BrushStopOffset*100), RpWarning,(int)(PrevBrushStopOffset*100), 0); if (n_dispensers) { @@ -1611,7 +1640,7 @@ void IDS_StartBrushStop(int n_dispensers, JobDispenser** Dispensers) //usnprintf(IdMessage, 80,"IDS_StartBrushStop %d/%d K %d,C %d,M %d,Y %d,TI %d",FileBrushStop->index,SegmentNumOfBrushStops,CurrentDispenserSpeed[0], // CurrentDispenserSpeed[1],CurrentDispenserSpeed[2],CurrentDispenserSpeed[3],CurrentDispenserSpeed[4]); if (BuildIdsJobPrintString(IdMessage,"IDS_StartBrushStop ",FileBrushStop->index)) - ReportWithPackageFilter(IDSFilter,IdMessage, __FILE__, SegmentNumOfBrushStops, FileBrushStop->index, RpWarning,(int)FileBrushStop->offsetmeters, 0); + ReportWithPackageFilter(IDSFilter,IdMessage, __FILE__, SegmentNumOfBrushStops, FileBrushStop->index, RpWarning,(int)(FileBrushStop->offsetmeters*100), 0); } uint32_t IDSBrushStopRestartCallback(uint32_t IfIndex, uint32_t readValue) @@ -1714,6 +1743,8 @@ uint32_t IDSSegmentState(void *SegmentDetails, int SegmentId) if (CurrentDispenserSpeed[CLEANER_DISPENSER]>0) IDS_Cleaning_Stop_Cleaning_Solution(NULL); #endif + BrushStopOffset = 0; + PrevBrushStopOffset = 0; SegmentNumOfBrushStops = Segment->n_brushstops; BrushStopTime = Segment->length*1000/(double)SegmentNumOfBrushStops; //brushstop in meters //brushstop in millisecond BrushStopTime = ((BrushStopTime*100)/dyeingspeed);//brushstop in seconds diff --git a/Software/Embedded_SW/Embedded/Modules/IFS/ifs.c b/Software/Embedded_SW/Embedded/Modules/IFS/ifs.c index 469e82aa8..2c67a623b 100644 --- a/Software/Embedded_SW/Embedded/Modules/IFS/ifs.c +++ b/Software/Embedded_SW/Embedded/Modules/IFS/ifs.c @@ -157,6 +157,7 @@ bool CartridgeInkFull() int GetCartridgeFillPercent() { double MidTank_Pressure = 0; + double percent; #ifdef IFS_DEBUG static int percent = 0; if (midTankState == MidTankStateFilling) { @@ -169,7 +170,8 @@ int GetCartridgeFillPercent() return percent; #else MidTank_Pressure = Read_MidTank_Pressure_Sensor(midTankCartColor); - return (((MidTank_Pressure - midTankCapacity)* 100) / CARTRIDGE_CAPATICY); + percent = (((MidTank_Pressure - midTankCapacity)* 100) / CARTRIDGE_CAPATICY); + return percent; #endif } diff --git a/Software/Embedded_SW/Embedded/Modules/IFS/ifs.h b/Software/Embedded_SW/Embedded/Modules/IFS/ifs.h index 0f95fb2e2..7d68621e9 100644 --- a/Software/Embedded_SW/Embedded/Modules/IFS/ifs.h +++ b/Software/Embedded_SW/Embedded/Modules/IFS/ifs.h @@ -13,7 +13,7 @@ #define CARTRIDGE_INK_TIMEOUT 420 #define MidTank_Pressure_EMPTY 0.3 -#define CARTRIDGE_CAPATICY 1500 +#define CARTRIDGE_CAPATICY 1.5 typedef enum{ MidTankStateIdle, diff --git a/Software/Embedded_SW/Embedded/Modules/Thread/Thread.h b/Software/Embedded_SW/Embedded/Modules/Thread/Thread.h index 13032f49d..aedb49a62 100644 --- a/Software/Embedded_SW/Embedded/Modules/Thread/Thread.h +++ b/Software/Embedded_SW/Embedded/Modules/Thread/Thread.h @@ -22,16 +22,6 @@ #define NORMAL_COEF_DIVIDER 100 typedef struct { - uint32_t startoffsetpulses; - uint32_t spoolbackingrate; - uint32_t segmentoffsetpulses;// the spool winding initial length in mm - uint32_t milimetersperrotation; - uint32_t SpoolBottomBackingRate;// the angle of the bottom of the spool - double NumberOfRotationPerPassage; // how many rotations per spool passage - double diameter; -}InternalWinderConfigStruc; -typedef struct -{ bool m_isEnabled; int32_t m_SetParam; float m_mesuredParam; diff --git a/Software/Embedded_SW/Embedded/Modules/Thread/Thread_ex.h b/Software/Embedded_SW/Embedded/Modules/Thread/Thread_ex.h index 4ce48a639..05cacd20e 100644 --- a/Software/Embedded_SW/Embedded/Modules/Thread/Thread_ex.h +++ b/Software/Embedded_SW/Embedded/Modules/Thread/Thread_ex.h @@ -14,7 +14,18 @@ #define WINDER_4_DANCER HARDWARE_DANCER_TYPE__RightDancer #define NUM_OF_DANCERS NUM_OF_ROTENC -//} DANCER_ENUM; + +typedef struct +{ + uint32_t startoffsetpulses; + uint32_t spoolbackingrate; + uint32_t segmentoffsetpulses;// the spool winding initial length in mm + uint32_t milimetersperrotation; + uint32_t SpoolBottomBackingRate;// the angle of the bottom of the spool + double NumberOfRotationPerPassage; // how many rotations per spool passage + double diameter; +}InternalWinderConfigStruc; + typedef enum threadMotorsEnum { FEEDER_MOTOR, @@ -55,6 +66,7 @@ uint32_t LoadDancerConfigMessage(void); //uint32_t MotorPidRequestMessage(HardwarePidControl* request); extern float NumberOfRotationPerPassage; //debug for rotation per passage trials +extern InternalWinderConfigStruc InternalWinderCfg; uint32_t Winder_Init(void); uint32_t Winder_Check_Cone(void); diff --git a/Software/Embedded_SW/Embedded/Modules/Thread/Thread_print.c b/Software/Embedded_SW/Embedded/Modules/Thread/Thread_print.c index 8b72c1a30..87ad612ba 100644 --- a/Software/Embedded_SW/Embedded/Modules/Thread/Thread_print.c +++ b/Software/Embedded_SW/Embedded/Modules/Thread/Thread_print.c @@ -581,7 +581,7 @@ uint32_t ThreadControlCBFunction(uint32_t IfIndex, uint32_t ReadValue) } index = IfIndex&0xFF; - if (index == POOLER_MOTOR) //move break sensor handling up to ensure handling even if tiing control is > 1 msec + if (index == WINDER_MOTOR) //move break sensor handling up to ensure handling even if tiing control is > 1 msec { if (checkBreakSensor(index) == ERROR) return OK; diff --git a/Software/Embedded_SW/Embedded/Software Release Notes.txt b/Software/Embedded_SW/Embedded/Software Release Notes.txt index 402a40e2e..55bb213d2 100644 --- a/Software/Embedded_SW/Embedded/Software Release Notes.txt +++ b/Software/Embedded_SW/Embedded/Software Release Notes.txt @@ -1,3 +1,14 @@ +Embedded SW Release note - Version 1.6.0(1) - Pack 4 - Gen #2 +============================================================= +Flash RAM handling: flash reduced to 0x4000 bytes only (16K) - used for semi-permanent data only - embedded parameters and alarm file. +hw configuration stored only in flash file system (uploaded from PPC/MS on every connection anyway) +dispensers data and process parameters stored in internal EEPROM - Addresses 0x200, 0x400. +homing tokens - dynamic allocation +Dispensers filling timeout alarm (after one hour) +IDS - gradient brushstop offset size from the file +store real time and use in error log +BTSR Support + Embedded SW Release note - Version 1.5.3(4) - Pack 3 ============================================================= remove ErrFile.txt handling (storing logs while report is disconnected) - from release version diff --git a/Software/Embedded_SW/Embedded/StateMachines/Printing/JobSTM.c b/Software/Embedded_SW/Embedded/StateMachines/Printing/JobSTM.c index dedf8ba98..aef2af830 100644 --- a/Software/Embedded_SW/Embedded/StateMachines/Printing/JobSTM.c +++ b/Software/Embedded_SW/Embedded/StateMachines/Printing/JobSTM.c @@ -115,6 +115,8 @@ ModuleStateEnum PrepareWaiting[MAX_SYSTEM_MODULES] = {ModuleIdle,ModuleIdle,Modu double job_length = 0.0; char infomsg[190]; +bool prepare_state = false; + /******************************************************************************************** * functions describes motor operation flow and movement state during profile execution * used to operate in runtime correct profileflow execution @@ -212,6 +214,8 @@ static ReturnCode PrepareState(void *JobDetails) usnprintf(ErrorMsg, 80,"Configured Thrd %d Wind %d IDS %d Heat %d WHS %d",Configured[Module_Thread],Configured[Module_Winder],Configured[Module_IDS],Configured[Module_Heaters],Configured[Module_Waste]); Report(ErrorMsg, __FILE__, __LINE__, 0, RpWarning, 0, 0); + prepare_state = true; + if (Configured[Module_IDS]) { PrepareWaiting[Module_IDS] = ModuleWaiting; @@ -305,6 +309,7 @@ uint32_t PrepareReady(int ModuleId, ModuleStateEnum result) Report(infomsg, __FILE__, __LINE__, ready, RpError, status, 0); SendJobProgress(0.0,0,false, infomsg); + prepare_state = false; SendJobProgress(0.0, 0, false, "Prepare Ready"); if (status == OK) Message.messageId = PreparationResultsOk; else Message.messageId = PreparationResultsFail; @@ -456,11 +461,26 @@ uint32_t ThreadJoggingFunc(int speed) TSegment->length = 200.0; TSegment->n_brushstops = 0; Ticket.segments[0] = TSegment; - Tspool->backingrate = 32; - Tspool->bottombackingrate = 32; - Tspool->segmentoffsetpulses = 1000; - Tspool->startoffsetpulses = 220; - Tspool->rotationsperpassage = 3.1415926*2; + if (InternalWinderCfg.spoolbackingrate) + Tspool->backingrate = InternalWinderCfg.spoolbackingrate; + else + Tspool->backingrate = 32; + if (InternalWinderCfg.SpoolBottomBackingRate) + Tspool->bottombackingrate = InternalWinderCfg.SpoolBottomBackingRate; + else + Tspool->bottombackingrate = 32; + if (InternalWinderCfg.segmentoffsetpulses) + Tspool->segmentoffsetpulses = InternalWinderCfg.segmentoffsetpulses; + else + Tspool->segmentoffsetpulses = 1000; + if (InternalWinderCfg.startoffsetpulses) + Tspool->startoffsetpulses = InternalWinderCfg.startoffsetpulses; + else + Tspool->startoffsetpulses = 220; + if (InternalWinderCfg.NumberOfRotationPerPassage) + Tspool->rotationsperpassage = InternalWinderCfg.NumberOfRotationPerPassage; + else + Tspool->rotationsperpassage = 3.1415926*3; Tspool->has_limitswitchstartpointoffset = false; Ticket.spool = Tspool; Ticket.threadparameters = &SavedThreadParameters; @@ -638,11 +658,27 @@ uint32_t ThreadCleaningJob(int speed) Tdispenser->index = 4; //TI dispenser Ticket.segments[0] = TSegment; Ticket.segments[1] = TSegment; - Tspool->backingrate = 32; - Tspool->bottombackingrate = 32; - Tspool->segmentoffsetpulses = 1000; - Tspool->startoffsetpulses = 220; - Tspool->rotationsperpassage = 3.1415926*2; + if (InternalWinderCfg.spoolbackingrate) + Tspool->backingrate = InternalWinderCfg.spoolbackingrate; + else + Tspool->backingrate = 32; + if (InternalWinderCfg.SpoolBottomBackingRate) + Tspool->bottombackingrate = InternalWinderCfg.SpoolBottomBackingRate; + else + Tspool->bottombackingrate = 32; + if (InternalWinderCfg.segmentoffsetpulses) + Tspool->segmentoffsetpulses = InternalWinderCfg.segmentoffsetpulses; + else + Tspool->segmentoffsetpulses = 1000; + if (InternalWinderCfg.startoffsetpulses) + Tspool->startoffsetpulses = InternalWinderCfg.startoffsetpulses; + else + Tspool->startoffsetpulses = 220; + if (InternalWinderCfg.NumberOfRotationPerPassage) + Tspool->rotationsperpassage = InternalWinderCfg.NumberOfRotationPerPassage; + else + Tspool->rotationsperpassage = 3.1415926*3; + Tspool->has_limitswitchstartpointoffset = false; Tspool->has_limitswitchstartpointoffset = false; Ticket.spool = Tspool; Ticket.threadparameters = &SavedThreadParameters; @@ -1136,6 +1172,12 @@ void SendJobProgress(double ProcessedLength, int SegmentId, bool done, char *Mes Report(infomsg,__FILE__,__LINE__,55,RpWarning,33, 44); }*/ //UInt Key = Task_disable(); + + if (prepare_state == true) + { + double prepare_progress = 0.9*HeatersPrepareProgress()+0.1*IdsPrepareProgress(); + Report("prepare_progress" ,__FILE__,__LINE__,(int)(prepare_progress*100),RpWarning,0,0); + } double totlength = 0; if (JobToken[0] != 0) @@ -1247,6 +1289,7 @@ void SendJobProgress(double ProcessedLength, int SegmentId, bool done, char *Mes CurrentRequest = NULL; } JobStopReporting(); + prepare_state = false; HandleJobEnd(JobEndReason); } // if (responseContainer.data.data) |
