aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Embedded_SW/Embedded/Common
diff options
context:
space:
mode:
authorRoy Ben-Shabat <Roy@Twine-s.com>2018-06-20 20:10:45 +0300
committerRoy Ben-Shabat <Roy@Twine-s.com>2018-06-20 20:10:45 +0300
commite146b0bebe4905bda100b357d3e904b1430c8039 (patch)
treee9c2146cc382557ff66f1df46a1d31ff4ccd6cae /Software/Embedded_SW/Embedded/Common
parente6c909c6d72d827175f75f77b2b7ed0f3a6feb71 (diff)
parent0087c3567ff7322869fa6871e16372a49c382f38 (diff)
downloadTango-e146b0bebe4905bda100b357d3e904b1430c8039.tar.gz
Tango-e146b0bebe4905bda100b357d3e904b1430c8039.zip
Merge branch 'master' of https://twinetfs.visualstudio.com/_git/Tango
Diffstat (limited to 'Software/Embedded_SW/Embedded/Common')
-rw-r--r--Software/Embedded_SW/Embedded/Common/report/distributor.c70
-rw-r--r--Software/Embedded_SW/Embedded/Common/report/reportInit.c3
2 files changed, 40 insertions, 33 deletions
diff --git a/Software/Embedded_SW/Embedded/Common/report/distributor.c b/Software/Embedded_SW/Embedded/Common/report/distributor.c
index 06f67680e..ee55c3bc9 100644
--- a/Software/Embedded_SW/Embedded/Common/report/distributor.c
+++ b/Software/Embedded_SW/Embedded/Common/report/distributor.c
@@ -63,7 +63,8 @@ typedef struct
}INPUT_MESSAGE;
#define INPUT_MESSAGE_LEN sizeof(INPUT_MESSAGE)
-
+ReportFunction ReportFunc1 = NULL;
+ReportFunction ReportFunc2 = NULL;
typedef struct
{
int fd;
@@ -72,7 +73,7 @@ typedef struct
#define DESTINATION_SIZE sizeof(DESTINATION)
-#define NUM_OF_DESTINATIONS 4
+#define NUM_OF_DESTINATIONS 2
typedef struct
{
char name[11];
@@ -591,16 +592,6 @@ STATUS ReportFunc(ReportFunction func, uint32_t SwitchAddRemove, DistributorHand
{
int index = 0, i;
- if (SwitchAddRemove == REPORT_ADD)
- {
- index = FindFreeDestinationElement(Distributor);
- /* check for the table overflow */
- if (index == -1)
- {
- errno = REPORT_ERROR_NOT_ENOUGH_MEMORY;
- return ERROR;
- }
- }
/* consistency check: don't add illegal pointer */
if( func == NULL )
{
@@ -608,28 +599,37 @@ STATUS ReportFunc(ReportFunction func, uint32_t SwitchAddRemove, DistributorHand
return ERROR;
}
- /* search for func - if already exists */
- for( i = 0; i < NUM_OF_DESTINATIONS; i++ )
- if (Dist_Table[Distributor].dest[i].function == func)
- break;
-
- if (i == NUM_OF_DESTINATIONS)
+ if (SwitchAddRemove == REPORT_REMOVE)
{
- if (SwitchAddRemove == REPORT_REMOVE) /* nothing to remove */
+ if (ReportFunc1 == func)
{
- errno = REPORT_ERROR_CODE_NOT_FOUND;
- return ERROR;
+ ReportFunc1 = NULL;
+ return OK;
}
- /* Add routine */
- /* add new destination to the end of the table */
- Dist_Table[Distributor].dest[index].function = func;
- /* set the fd to illegal value to ensure that destination is nothing but function */
- Dist_Table[Distributor].dest[index].fd = -1;
+ if (ReportFunc2 == func)
+ {
+ ReportFunc2 = NULL;
+ return OK;
+ }
+ errno = REPORT_ERROR_CODE_NOT_FOUND;
+ return ERROR;
}
- else if (SwitchAddRemove == REPORT_ADD)
- return OK; /* this routine is already exists in the table */
- else /* Remove routine */
- Dist_Table[Distributor].dest[i].function = NULL;
+ if (SwitchAddRemove == REPORT_ADD)
+ {
+ if (ReportFunc1 == NULL)
+ {
+ ReportFunc1 = func;
+ return OK;
+ }
+ if (ReportFunc2 == NULL)
+ {
+ ReportFunc2 = func;
+ return OK;
+ }
+ errno = REPORT_ERROR_CODE_NOT_FOUND;
+ return ERROR;
+ }
+
return OK;
}
@@ -714,11 +714,17 @@ static void messageDistribute(char *msg,
it should not be -1 and function must be NULL.
If the destination is function, it's address must not be NULL
and fd should be -1 */
- for (index = 0; index < NUM_OF_DESTINATIONS; index++ )
+/* for (index = 0; index < NUM_OF_DESTINATIONS; index++ )
{
if (Dist_Table[DistTableEntry].dest[index].function != NULL)
Dist_Table[DistTableEntry].dest[index].function(msg,FileName,LineNumber,errorCode,parameter1,parameter2);
- }
+ }*/
+
+ if (ReportFunc1 != NULL)
+ ReportFunc1(msg, FileName,LineNumber,errorCode,parameter1, parameter2);
+ if (ReportFunc2 != NULL)
+ ReportFunc2(msg, FileName,LineNumber,errorCode,parameter1, parameter2);
+
}
diff --git a/Software/Embedded_SW/Embedded/Common/report/reportInit.c b/Software/Embedded_SW/Embedded/Common/report/reportInit.c
index 56800b755..b9f676d3a 100644
--- a/Software/Embedded_SW/Embedded/Common/report/reportInit.c
+++ b/Software/Embedded_SW/Embedded/Common/report/reportInit.c
@@ -83,7 +83,7 @@ int ReportResponseFunc(char *message, /* The formatted message
response.has_category = true;
response.category = (DebugLogCategory)parameter1;
response.filter = parameter2;
- strcpy (response.message,message);
+ response.message = message;
responseContainer = createContainer(MESSAGE_TYPE__StartDebugLogResponse, protobufToken, false, &response, &start_debug_log_response__pack, &start_debug_log_response__get_packed_size);
responseContainer.continuous = true;
uint8_t* container_buffer = malloc(message_container__get_packed_size(&responseContainer));
@@ -116,6 +116,7 @@ uint32_t ReportInitMessage(MessageContainer* requestContainer)
if (ReportHandle == NULL) status |= 0x8;
status |= ReportFunc(ReportResponseFunc , REPORT_ADD, ReportHandle);
start_debug_log_request__free_unpacked(request,NULL);
+ LOG_ERROR(127,"test");
return status;
}
uint32_t StopReportInitMessage(MessageContainer* requestContainer)