From a435fa908aa5ef7e167c96866316c2c018f05877 Mon Sep 17 00:00:00 2001 From: Shlomo Hecht Date: Sun, 11 Nov 2018 17:30:48 +0200 Subject: remove usb reconnection (only flush buffers). improve thread tracking --- Software/Embedded_SW/Embedded/Modules/Thread/Thread_print.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'Software/Embedded_SW/Embedded/Modules/Thread') diff --git a/Software/Embedded_SW/Embedded/Modules/Thread/Thread_print.c b/Software/Embedded_SW/Embedded/Modules/Thread/Thread_print.c index 22f54eb50..24ce14676 100644 --- a/Software/Embedded_SW/Embedded/Modules/Thread/Thread_print.c +++ b/Software/Embedded_SW/Embedded/Modules/Thread/Thread_print.c @@ -5,6 +5,7 @@ * operating the dispensers according to predefined dispensing rate from the UI **************************************************************************************************************************/ #include "include.h" +#include #include "thread.h" #include "thread_ex.h" #include "../control/control.h" @@ -317,6 +318,8 @@ uint32_t ThreadControlSpeedReadFunction(uint32_t IfIndex, uint32_t ReadValue) //int TranslatedreadValue[100]; #define MAX_THREAD_CONTROL_LOG 500 double calculatedError[MAX_THREAD_CONTROL_LOG]; +double NormError[MAX_THREAD_CONTROL_LOG]; +double mIntegral[MAX_THREAD_CONTROL_LOG]; int MotorId[MAX_THREAD_CONTROL_LOG]; int readValue[MAX_THREAD_CONTROL_LOG]; int AveragereadValue[MAX_THREAD_CONTROL_LOG]; @@ -475,7 +478,10 @@ uint32_t ThreadControlCBFunction(uint32_t IfIndex, uint32_t ReadValue) readValue[controlIndex] = ReadValue; AveragereadValue[controlIndex] = avreageSampleValue; calculatedspeed[controlIndex] = calculated_speed; - timestamp[controlIndex] = HibernateRTCSSGet(); + NormError[controlIndex] + = MotorControlConfig[index].m_mesuredParam; + mIntegral[controlIndex] = MotorControlConfig[index].m_integral; + timestamp[controlIndex] = msec_millisecondCounter; if (controlIndex++>=MAX_THREAD_CONTROL_LOG) controlIndex = 0; } -- cgit v1.3.1 From 9699b74d7cf87fef466cb6606fe9e110e3b15120 Mon Sep 17 00:00:00 2001 From: Shlomo Hecht Date: Sun, 11 Nov 2018 17:37:27 +0200 Subject: reset control with eNoControl value --- Software/Embedded_SW/Embedded/Modules/Control/control.c | 3 +++ .../Embedded_SW/Embedded/Modules/Thread/Thread_print.c | 14 +++++++------- 2 files changed, 10 insertions(+), 7 deletions(-) (limited to 'Software/Embedded_SW/Embedded/Modules/Thread') diff --git a/Software/Embedded_SW/Embedded/Modules/Control/control.c b/Software/Embedded_SW/Embedded/Modules/Control/control.c index bb7bbaa92..78cdd5324 100644 --- a/Software/Embedded_SW/Embedded/Modules/Control/control.c +++ b/Software/Embedded_SW/Embedded/Modules/Control/control.c @@ -363,6 +363,9 @@ uint32_t ControlLoop(uint32_t tick) LOG_ERROR (Device_i, "Invalid callback ptr"); } break; + case eNoControl: + memset (&ControlArray[Device_i],0,sizeof(ControlDeviceStruc) ); + break; default: LOG_ERROR (ControlArray[Device_i].ControlTiming, "Invalid control timing value"); break; diff --git a/Software/Embedded_SW/Embedded/Modules/Thread/Thread_print.c b/Software/Embedded_SW/Embedded/Modules/Thread/Thread_print.c index 22f54eb50..d8dbbaaa0 100644 --- a/Software/Embedded_SW/Embedded/Modules/Thread/Thread_print.c +++ b/Software/Embedded_SW/Embedded/Modules/Thread/Thread_print.c @@ -316,12 +316,12 @@ uint32_t ThreadControlSpeedReadFunction(uint32_t IfIndex, uint32_t ReadValue) //double eNormalizedError[100]; //int TranslatedreadValue[100]; #define MAX_THREAD_CONTROL_LOG 500 -double calculatedError[MAX_THREAD_CONTROL_LOG]; -int MotorId[MAX_THREAD_CONTROL_LOG]; -int readValue[MAX_THREAD_CONTROL_LOG]; -int AveragereadValue[MAX_THREAD_CONTROL_LOG]; -int calculatedspeed[MAX_THREAD_CONTROL_LOG]; -int timestamp[MAX_THREAD_CONTROL_LOG]; +double calculatedError[MAX_THREAD_CONTROL_LOG+1]; +int MotorId[MAX_THREAD_CONTROL_LOG+1]; +int readValue[MAX_THREAD_CONTROL_LOG+1]; +int AveragereadValue[MAX_THREAD_CONTROL_LOG+1]; +int calculatedspeed[MAX_THREAD_CONTROL_LOG+1]; +int timestamp[MAX_THREAD_CONTROL_LOG+1]; int controlIndex = 0; bool keepdata = true; /*int32_t KeepReadValue = 0; @@ -475,7 +475,7 @@ uint32_t ThreadControlCBFunction(uint32_t IfIndex, uint32_t ReadValue) readValue[controlIndex] = ReadValue; AveragereadValue[controlIndex] = avreageSampleValue; calculatedspeed[controlIndex] = calculated_speed; - timestamp[controlIndex] = HibernateRTCSSGet(); + timestamp[controlIndex] = msec_millisecondCounter; if (controlIndex++>=MAX_THREAD_CONTROL_LOG) controlIndex = 0; } -- cgit v1.3.1 From 6bf9ac4eca2a4b9616a1a62ba89707651c410562 Mon Sep 17 00:00:00 2001 From: Shlomo Hecht Date: Sun, 11 Nov 2018 17:57:42 +0200 Subject: improved tracking in thread. save tim in malloc --- Software/Embedded_SW/Embedded/Common/Utilities/Utils.c | 14 +++++++++++--- Software/Embedded_SW/Embedded/Communication/Connection.c | 12 ++++++------ .../Embedded_SW/Embedded/Modules/Thread/Thread_print.c | 8 ++++++-- .../Embedded_SW/Embedded/StateMachines/Printing/JobSTM.c | 4 ++-- 4 files changed, 25 insertions(+), 13 deletions(-) (limited to 'Software/Embedded_SW/Embedded/Modules/Thread') diff --git a/Software/Embedded_SW/Embedded/Common/Utilities/Utils.c b/Software/Embedded_SW/Embedded/Common/Utilities/Utils.c index 20ab5e2a6..b1da049b2 100644 --- a/Software/Embedded_SW/Embedded/Common/Utilities/Utils.c +++ b/Software/Embedded_SW/Embedded/Common/Utilities/Utils.c @@ -26,6 +26,7 @@ void * malloc_addr[MAX_MEM_LOG]; void *my_malloc(size_t _size) { void * addr = malloc (_size); + if (_size == 0) return addr; int i; for (i=0; i< MAX_MEM_LOG;i++) { @@ -53,20 +54,27 @@ int allocated_size = 0; void my_free(void *_ptr) { int i; + free(_ptr); if (_ptr) { for (i=0; i< MAX_MEM_LOG;i++) { if ( malloc_addr[i] == _ptr) { + malloc_addr[i] = 0; malloc_time[i] = 0; malloc_size[i] = 0; + break; } } + if (i==MAX_MEM_LOG) + { + LOG_ERROR(i,"free error"); + return; + } allocated_size = 0; - for (i=0; i< MAX_MEM_LOG;i++) - allocated_size+=malloc_size[i]; - free(_ptr); +// for (i=0; i< MAX_MEM_LOG;i++) +// allocated_size+=malloc_size[i]; } } diff --git a/Software/Embedded_SW/Embedded/Communication/Connection.c b/Software/Embedded_SW/Embedded/Communication/Connection.c index 56ca9ab2d..0039fd488 100644 --- a/Software/Embedded_SW/Embedded/Communication/Connection.c +++ b/Software/Embedded_SW/Embedded/Communication/Connection.c @@ -92,7 +92,7 @@ void DisconnectionRequest(MessageContainer* requestContainer) { MessageContainer responseContainer; - //DisconnectRequest* request = disconnect_request__unpack(NULL, requestContainer->data.len, requestContainer->data.data); + DisconnectRequest* request = disconnect_request__unpack(NULL, requestContainer->data.len, requestContainer->data.data); DisconnectResponse response = DISCONNECT_RESPONSE__INIT; responseContainer = createContainer(MESSAGE_TYPE__DisconnectResponse, requestContainer->token, true, &response, &disconnect_response__pack, &disconnect_response__get_packed_size); @@ -106,9 +106,9 @@ void DisconnectionRequest(MessageContainer* requestContainer) size_t container_size = message_container__pack(&responseContainer, container_buffer); my_free(responseContainer.data.data); SendChars((char*)container_buffer, container_size); - //disconnect_request__free_unpacked(request,NULL); - CommunicationMailboxFlush(); - USBCDCD_Reinit(); + disconnect_request__free_unpacked(request,NULL); + //CommunicationMailboxFlush(); + //USBCDCD_Reinit(); } int KeepAliveOneSecondCounter = 0; @@ -118,7 +118,7 @@ void KeepAliveRequestFunc(MessageContainer* requestContainer) { MessageContainer responseContainer; - //KeepAliveRequest* request = keep_alive_request__unpack(NULL, requestContainer->data.len, requestContainer->data.data); + KeepAliveRequest* request = keep_alive_request__unpack(NULL, requestContainer->data.len, requestContainer->data.data); KeepAliveResponse response = KEEP_ALIVE_RESPONSE__INIT; KeepAliveOneSecondCounter = 0; @@ -129,7 +129,7 @@ void KeepAliveRequestFunc(MessageContainer* requestContainer) size_t container_size = message_container__pack(&responseContainer, container_buffer); my_free(responseContainer.data.data); SendChars((char*)container_buffer, container_size); - //keep_alive_request__free_unpacked(request,NULL); + keep_alive_request__free_unpacked(request,NULL); } void KeepAliveOneSecondCall(void) { diff --git a/Software/Embedded_SW/Embedded/Modules/Thread/Thread_print.c b/Software/Embedded_SW/Embedded/Modules/Thread/Thread_print.c index ac6dd1969..3b17cd5dd 100644 --- a/Software/Embedded_SW/Embedded/Modules/Thread/Thread_print.c +++ b/Software/Embedded_SW/Embedded/Modules/Thread/Thread_print.c @@ -316,8 +316,10 @@ uint32_t ThreadControlSpeedReadFunction(uint32_t IfIndex, uint32_t ReadValue) } //double eNormalizedError[100]; //int TranslatedreadValue[100]; -#define MAX_THREAD_CONTROL_LOG 500 +#define MAX_THREAD_CONTROL_LOG 300 double calculatedError[MAX_THREAD_CONTROL_LOG+1]; +double NormError[MAX_THREAD_CONTROL_LOG+1]; +double Integral[MAX_THREAD_CONTROL_LOG+1]; int MotorId[MAX_THREAD_CONTROL_LOG+1]; int readValue[MAX_THREAD_CONTROL_LOG+1]; int AveragereadValue[MAX_THREAD_CONTROL_LOG+1]; @@ -476,7 +478,9 @@ uint32_t ThreadControlCBFunction(uint32_t IfIndex, uint32_t ReadValue) readValue[controlIndex] = ReadValue; AveragereadValue[controlIndex] = avreageSampleValue; calculatedspeed[controlIndex] = calculated_speed; - timestamp[controlIndex] = HibernateRTCSSGet(); + timestamp[controlIndex] = msec_millisecondCounter; + NormError[controlIndex]= NormalizedError; + Integral[controlIndex] = MotorControlConfig[index].m_integral; if (controlIndex++>=MAX_THREAD_CONTROL_LOG) controlIndex = 0; } diff --git a/Software/Embedded_SW/Embedded/StateMachines/Printing/JobSTM.c b/Software/Embedded_SW/Embedded/StateMachines/Printing/JobSTM.c index 8929f9e23..12c456e89 100644 --- a/Software/Embedded_SW/Embedded/StateMachines/Printing/JobSTM.c +++ b/Software/Embedded_SW/Embedded/StateMachines/Printing/JobSTM.c @@ -544,10 +544,10 @@ void SendJobProgress(double ProcessedLength, int SegmentId, bool done, char *Mes int len; //static msdid = 0; int length = (int)(ProcessedLength*100); - len = usnprintf(logmsg, 254, "MSG: Job Progress Length %d, Seg %d Done %d ",length, SegmentId, done); + //len = usnprintf(logmsg, 254, "MSG: Job Progress Length %d, Seg %d Done %d ",length, SegmentId, done); //REPORT_MSG(msdid++,logmsg); - Report(logmsg,__FILE__,__LINE__,SegmentId,RpWarning,SegmentId, done); + //Report(logmsg,__FILE__,__LINE__,SegmentId,RpWarning,SegmentId, done); if (Message) { strcpy (infomsg,Message); -- cgit v1.3.1