diff options
| author | Shlomo Hecht <shlomo@twine-s.com> | 2018-11-13 10:46:15 +0200 |
|---|---|---|
| committer | Shlomo Hecht <shlomo@twine-s.com> | 2018-11-13 10:46:15 +0200 |
| commit | 00525cc261ec117e2eb78ac2a4525fa3da92d399 (patch) | |
| tree | 9f4c311d915b0305f31925bab4d87a97cf82d790 /Software/Embedded_SW | |
| parent | 8d4920307ed4bbb6760245728934b91e249fe6c4 (diff) | |
| parent | 996422d12e0a40aa408757989232f0225dc29a28 (diff) | |
| download | Tango-00525cc261ec117e2eb78ac2a4525fa3da92d399.tar.gz Tango-00525cc261ec117e2eb78ac2a4525fa3da92d399.zip | |
Merge branch 'master' of https://twinetfs.visualstudio.com/Tango/_git/Tango
Diffstat (limited to 'Software/Embedded_SW')
8 files changed, 69 insertions, 29 deletions
diff --git a/Software/Embedded_SW/Embedded/Common/Utilities/Utils.c b/Software/Embedded_SW/Embedded/Common/Utilities/Utils.c index c745436ad..d339ab66b 100644 --- a/Software/Embedded_SW/Embedded/Common/Utilities/Utils.c +++ b/Software/Embedded_SW/Embedded/Common/Utilities/Utils.c @@ -16,18 +16,23 @@ static const float speedCoef = 5.3051647697298445256294587790838f;//(200 micro s //***************************************************************************** -#define MAX_MEM_LOG 200 -int freeIndex=0,malloc_index=0; +#define MAX_MEM_LOG 300 +int free_index=0,malloc_index=0; +int zero_mallocs=0,null_free=0; uint32_t malloc_size[MAX_MEM_LOG]; uint32_t malloc_time[MAX_MEM_LOG]; void * malloc_addr[MAX_MEM_LOG]; -//void * free_addr[MAX_MEM_LOG]; +void * free_addr[MAX_MEM_LOG]; //uint32_t total_allocated = 0; void *my_malloc(size_t _size) { void * addr = malloc (_size); - if (_size == 0) return addr; - int i; + if (_size == 0) + { + zero_mallocs++; + return addr; + } + /*int i; for (i=0; i< MAX_MEM_LOG;i++) { if (malloc_time[i] == 0) @@ -42,12 +47,12 @@ void *my_malloc(size_t _size) malloc_addr[malloc_index] = addr; malloc_size[malloc_index] = _size; malloc_time[malloc_index] = msec_millisecondCounter; - } - //malloc_addr[malloc_index] = addr; - //malloc_size[malloc_index] = _size; - //malloc_time[malloc_index] = HibernateRTCSSGet(); - //if (malloc_index++>=MAX_MEM_LOG) - // malloc_index = 0; + }*/ + malloc_addr[malloc_index] = addr; + malloc_size[malloc_index] = _size; + malloc_time[malloc_index] = msec_millisecondCounter; + if (malloc_index++>=MAX_MEM_LOG) + malloc_index = 0; return addr; } int allocated_size = 0; @@ -57,7 +62,7 @@ void my_free(void *_ptr) free(_ptr); if (_ptr) { - for (i=0; i< MAX_MEM_LOG;i++) +/* for (i=0; i< MAX_MEM_LOG;i++) { if ( malloc_addr[i] == _ptr) { @@ -75,7 +80,14 @@ void my_free(void *_ptr) allocated_size = 0; // for (i=0; i< MAX_MEM_LOG;i++) // allocated_size+=malloc_size[i]; +*/ + free_addr[free_index] = _ptr; + if (free_index++>=MAX_MEM_LOG) + free_index = 0; + } + else + null_free++; } //***************************************************************************** diff --git a/Software/Embedded_SW/Embedded/Common/report/distributor.c b/Software/Embedded_SW/Embedded/Common/report/distributor.c index 46a3affd6..cbc754a7e 100644 --- a/Software/Embedded_SW/Embedded/Common/report/distributor.c +++ b/Software/Embedded_SW/Embedded/Common/report/distributor.c @@ -240,7 +240,7 @@ Void reportService(UArg arg0, UArg arg1) int DistTableEntry;//,msgLen, errCode, par1, par2; ReportInitParams InitParams; - InitParams.DistributorQueueMaxMsgs = 20; + InitParams.DistributorQueueMaxMsgs = 15; InitParams.DistributorTaskPriority = 6; InitParams.MaxNumOfFilterNames = 1; InitParams.MaxNumberOfPrivateDistributors = 2; diff --git a/Software/Embedded_SW/Embedded/Communication/CommunicationTask.c b/Software/Embedded_SW/Embedded/Communication/CommunicationTask.c index 2b551108d..b27ab687d 100644 --- a/Software/Embedded_SW/Embedded/Communication/CommunicationTask.c +++ b/Software/Embedded_SW/Embedded/Communication/CommunicationTask.c @@ -15,7 +15,7 @@ static void (*callback)(char* buffer, size_t length); Mailbox_Handle CommunicationRxMsgQ = NULL; Mailbox_Handle CommunicationTxMsgQ = NULL; -#define COMMUNICATION_NUM_MSGS 15 +#define COMMUNICATION_NUM_MSGS 20 typedef struct CommRxMessage{ //uint16_t messageId; uint16_t msgSize; @@ -157,7 +157,7 @@ void communicationTask(UArg arg0, UArg arg1) } } -int UnSentMessages=0; +int UnSentMessages=0, deliveryfailure = 0; bool CommunicationTaskSendMessage(char* buffer,size_t length) { CommTxMessageStruc Message; @@ -173,11 +173,14 @@ bool CommunicationTaskSendMessage(char* buffer,size_t length) if (retcode == false) { my_free(buffer); + deliveryfailure++; + CommunicationMailboxFlush(); } return retcode; } +int memoryrelease = 0; void CommunicationMailboxFlush(void) { int i; @@ -189,6 +192,7 @@ void CommunicationMailboxFlush(void) UnSentMessages--; LOG_ERROR(Message.msgSize,"Flushing Message"); my_free(Message.Buff); + memoryrelease+=Message.msgSize; } } } diff --git a/Software/Embedded_SW/Embedded/Communication/Container.c b/Software/Embedded_SW/Embedded/Communication/Container.c index 408e88a3d..337e7c368 100644 --- a/Software/Embedded_SW/Embedded/Communication/Container.c +++ b/Software/Embedded_SW/Embedded/Communication/Container.c @@ -44,12 +44,13 @@ #include "Common/report/report.h" #include "Connection.h" -/* -uint32_t TxmsgId[50] = {0}; -uint32_t TxLength[50] = {0}; -uint32_t TxAddr[50] = {0}; +#define MAX_CONT_LOG 300 + +uint32_t TxmsgId[MAX_CONT_LOG+1] = {0}; +uint32_t TxLength[MAX_CONT_LOG+1] = {0}; +uint32_t TxAddr[MAX_CONT_LOG+1] = {0}; byte Txindex = 0; -uint32_t msgId[50] = {0}; +/*uint32_t msgId[50] = {0}; uint32_t Length[50] = {0}; uint32_t DataLength[50] = {0}; byte index = 0; @@ -75,12 +76,12 @@ MessageContainer createContainer(MessageType type, char* token, protobuf_c_boole container.data.data = response_buffer; container.data.len = response_size; - /*TxmsgId[Txindex] = type; + TxmsgId[Txindex] = type; TxLength[Txindex] = response_size; TxAddr[Txindex] = response_buffer; - if (Txindex++>=50) + if (Txindex++>=MAX_CONT_LOG) Txindex = 0; -*/ + //free(response); return container; } diff --git a/Software/Embedded_SW/Embedded/Modules/Diagnostics/Diagnostics.c b/Software/Embedded_SW/Embedded/Modules/Diagnostics/Diagnostics.c index 3fcd988bd..1bd37d15c 100644 --- a/Software/Embedded_SW/Embedded/Modules/Diagnostics/Diagnostics.c +++ b/Software/Embedded_SW/Embedded/Modules/Diagnostics/Diagnostics.c @@ -129,6 +129,11 @@ typedef struct DiagnosticsMessage{ uint8_t messageData[20]; }DiagnosticsMessageStruc; +#define MAX_DIAG_LOG 100 +int diag_index=0; +uint32_t diag_size[MAX_DIAG_LOG]; +uint32_t diag_time[MAX_DIAG_LOG]; + /******************** CODE ********************************************/ //********************************************************************** @@ -587,7 +592,17 @@ void SendDiagnostics(void) { LOG_ERROR(Task_self(),"my_malloc failed"); DiagnosticsStop(); + CommunicationMailboxFlush(); + } + else + { + //Report("Diagnostic Messgage",__FILE__,__LINE__,container_size,RpWarning,msec_millisecondCounter, msec_millisecondCounter); } + diag_size[diag_index] = container_size; + diag_time[diag_index] = msec_millisecondCounter; + if (diag_index++>=MAX_DIAG_LOG) + diag_index = 0; + } else { @@ -612,8 +627,14 @@ uint32_t DiagnosticsStart(void) if (DiagnosticRequestAccepted == true) { DiagnosticsActive = true; - DiagnosticsControlId = AddControlCallback(Diagnostics_ControlTrigger,DiagnosticLimit,DiagnosticsEmptyCBFunction,0,0,0); - Diagnostics10MSControlId = AddControlCallback(Diagnostics_TenMiliControlTrigger,DiagnosticFastLimit,DiagnosticsEmptyCBFunction,0,0,0); + if (DiagnosticsControlId == 0xFF) + DiagnosticsControlId = AddControlCallback(Diagnostics_ControlTrigger,DiagnosticLimit,DiagnosticsEmptyCBFunction,0,0,0); + else + LOG_ERROR(DiagnosticsControlId,"Diagnostics restarted"); + if (Diagnostics10MSControlId == 0xFF) + Diagnostics10MSControlId = AddControlCallback(Diagnostics_TenMiliControlTrigger,DiagnosticFastLimit,DiagnosticsEmptyCBFunction,0,0,0); + else + LOG_ERROR(DiagnosticsControlId,"Diagnostics restarted"); } } return OK; diff --git a/Software/Embedded_SW/Embedded/Modules/Diagnostics/DiagnosticsHoming.c b/Software/Embedded_SW/Embedded/Modules/Diagnostics/DiagnosticsHoming.c index b3ed6fde0..58d05f383 100644 --- a/Software/Embedded_SW/Embedded/Modules/Diagnostics/DiagnosticsHoming.c +++ b/Software/Embedded_SW/Embedded/Modules/Diagnostics/DiagnosticsHoming.c @@ -163,7 +163,7 @@ uint32_t MotorHomingRequestFunc(MessageContainer* requestContainer) { if ( Motor_Id_to_LS_IdUp[MotorId] != MAX_GPI) { - MotorMovetoLimitSwitch (MotorId,MotorsCfg[MotorId].directionthreadwize, speed, Motor_Id_to_LS_IdUp[MotorId], MotorHomingRequestCallback); + MotorMovetoLimitSwitch (MotorId,MotorsCfg[MotorId].directionthreadwize, speed, Motor_Id_to_LS_IdDown[MotorId], MotorHomingRequestCallback); ustrncpy (HomingToken[MotorId], requestContainer->token,36); return OK; } @@ -172,7 +172,7 @@ uint32_t MotorHomingRequestFunc(MessageContainer* requestContainer) { if ( Motor_Id_to_LS_IdDown[MotorId] != MAX_GPI) { - MotorMovetoLimitSwitch (MotorId,1-MotorsCfg[MotorId].directionthreadwize, speed, Motor_Id_to_LS_IdDown[MotorId], MotorHomingRequestCallback); + MotorMovetoLimitSwitch (MotorId,1-MotorsCfg[MotorId].directionthreadwize, speed, Motor_Id_to_LS_IdUp[MotorId], MotorHomingRequestCallback); ustrncpy (HomingToken[MotorId], requestContainer->token,36); return OK; } diff --git a/Software/Embedded_SW/Embedded/Modules/Diagnostics/DiagnosticsJogging.c b/Software/Embedded_SW/Embedded/Modules/Diagnostics/DiagnosticsJogging.c index 5a709e4a4..bc3630698 100644 --- a/Software/Embedded_SW/Embedded/Modules/Diagnostics/DiagnosticsJogging.c +++ b/Software/Embedded_SW/Embedded/Modules/Diagnostics/DiagnosticsJogging.c @@ -65,10 +65,10 @@ uint32_t MotorJoggingRequestFunc(MessageContainer* requestContainer) switch (request->direction) { case MOTOR_DIRECTION__Forward: - direction = MotorsCfg[MotorId].directionthreadwize; + direction = 1-MotorsCfg[MotorId].directionthreadwize; break; case MOTOR_DIRECTION__Backward: - direction = 1-MotorsCfg[MotorId].directionthreadwize; + direction = MotorsCfg[MotorId].directionthreadwize; break; } MotorSetDirection(MotorId,direction); diff --git a/Software/Embedded_SW/Embedded/StateMachines/Printing/JobSTM.c b/Software/Embedded_SW/Embedded/StateMachines/Printing/JobSTM.c index 12c456e89..67cb7c666 100644 --- a/Software/Embedded_SW/Embedded/StateMachines/Printing/JobSTM.c +++ b/Software/Embedded_SW/Embedded/StateMachines/Printing/JobSTM.c @@ -461,6 +461,8 @@ void JobRequestFunc(MessageContainer* requestContainer) { //memcpy(CurrentJob, Ticket,TicketSize); CurrentJob = Ticket; + if (CurrentRequest!= NULL) + job_request__free_unpacked(CurrentRequest,NULL); CurrentRequest = request; status = PASSED; |
