aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Embedded_SW/Embedded
diff options
context:
space:
mode:
authorShlomo Hecht <shlomo@twine-s.com>2018-11-12 15:04:02 +0200
committerShlomo Hecht <shlomo@twine-s.com>2018-11-12 15:04:02 +0200
commiteee8a19447eaeb87fd38d11354a4adc29148963a (patch)
treee92f4ddee94428107c1a2d78bcd6c3fa0af519d8 /Software/Embedded_SW/Embedded
parent6bf9ac4eca2a4b9616a1a62ba89707651c410562 (diff)
downloadTango-eee8a19447eaeb87fd38d11354a4adc29148963a.tar.gz
Tango-eee8a19447eaeb87fd38d11354a4adc29148963a.zip
some memory management hooks. fix motors homing
Diffstat (limited to 'Software/Embedded_SW/Embedded')
-rw-r--r--Software/Embedded_SW/Embedded/Common/Utilities/Utils.c38
-rw-r--r--Software/Embedded_SW/Embedded/Common/report/distributor.c2
-rw-r--r--Software/Embedded_SW/Embedded/Communication/CommunicationTask.c8
-rw-r--r--Software/Embedded_SW/Embedded/Communication/Container.c17
-rw-r--r--Software/Embedded_SW/Embedded/Modules/AlarmHandling/AlarmHandling.c4
-rw-r--r--Software/Embedded_SW/Embedded/Modules/Diagnostics/Diagnostics.c25
-rw-r--r--Software/Embedded_SW/Embedded/Modules/Diagnostics/DiagnosticsHoming.c4
-rw-r--r--Software/Embedded_SW/Embedded/Modules/Diagnostics/DiagnosticsJogging.c4
-rw-r--r--Software/Embedded_SW/Embedded/StateMachines/Printing/JobSTM.c2
9 files changed, 72 insertions, 32 deletions
diff --git a/Software/Embedded_SW/Embedded/Common/Utilities/Utils.c b/Software/Embedded_SW/Embedded/Common/Utilities/Utils.c
index b1da049b2..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)
{
@@ -69,13 +74,20 @@ void my_free(void *_ptr)
}
if (i==MAX_MEM_LOG)
{
- LOG_ERROR(i,"free error");
+ //LOG_ERROR(i,"free error");
return;
}
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 ac0f13a2a..13d059020 100644
--- a/Software/Embedded_SW/Embedded/Communication/CommunicationTask.c
+++ b/Software/Embedded_SW/Embedded/Communication/CommunicationTask.c
@@ -12,7 +12,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;
@@ -163,7 +163,7 @@ void communicationTask(UArg arg0, UArg arg1)
}
}
-int UnSentMessages=0;
+int UnSentMessages=0, deliveryfailure = 0;
bool CommunicationTaskSendMessage(char* buffer,size_t length)
{
CommTxMessageStruc Message;
@@ -179,11 +179,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;
@@ -195,6 +198,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/AlarmHandling/AlarmHandling.c b/Software/Embedded_SW/Embedded/Modules/AlarmHandling/AlarmHandling.c
index 49d13d07f..9a4871878 100644
--- a/Software/Embedded_SW/Embedded/Modules/AlarmHandling/AlarmHandling.c
+++ b/Software/Embedded_SW/Embedded/Modules/AlarmHandling/AlarmHandling.c
@@ -391,7 +391,7 @@ uint32_t AlarmHandlingLoop(uint32_t tick)
{
if (ivalue/100 >= AlarmItem[Alarm_i].AlarmValue)
{
- LOG_ERROR (ivalue/100,"Temperature spike");
+ //LOG_ERROR (ivalue/100,"Temperature spike");
Status = true;
}
}
@@ -399,7 +399,7 @@ uint32_t AlarmHandlingLoop(uint32_t tick)
{
if (ivalue/100 <= AlarmItem[Alarm_i].AlarmValue)
{
- LOG_ERROR (ivalue/100,"Temperature spike");
+ //LOG_ERROR (ivalue/100,"iTemperature spike");
Status = true;
}
}
diff --git a/Software/Embedded_SW/Embedded/Modules/Diagnostics/Diagnostics.c b/Software/Embedded_SW/Embedded/Modules/Diagnostics/Diagnostics.c
index 6ff1ef4fa..c34702e5c 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 ********************************************/
//**********************************************************************
@@ -580,7 +585,17 @@ void SendDiagnostics(void)
if (SendChars(diagnosticscontainer_buffer, container_size) == false) //comm tx mailbox full
{
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
{
@@ -606,8 +621,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;