summaryrefslogtreecommitdiffstats
path: root/ucs2-interface/ucs-xml/UcsXml.c
diff options
context:
space:
mode:
Diffstat (limited to 'ucs2-interface/ucs-xml/UcsXml.c')
-rw-r--r--ucs2-interface/ucs-xml/UcsXml.c49
1 files changed, 38 insertions, 11 deletions
diff --git a/ucs2-interface/ucs-xml/UcsXml.c b/ucs2-interface/ucs-xml/UcsXml.c
index 2360c7a..7715cd4 100644
--- a/ucs2-interface/ucs-xml/UcsXml.c
+++ b/ucs2-interface/ucs-xml/UcsXml.c
@@ -42,6 +42,7 @@
#define RETURN_ASSERT(result) { UcsXml_CB_OnError("Assertion in file=%s, line=%d", 2, __FILE__, __LINE__); return result; }
#define MISC_HB(value) ((uint8_t)((uint16_t)(value) >> 8))
#define MISC_LB(value) ((uint8_t)((uint16_t)(value) & (uint16_t)0xFF))
+#define ROUTE_AUTO_ID_START (0x8000)
struct UcsXmlRoute
{
@@ -260,6 +261,7 @@ static ParseResult_t ParseScriptPortWrite(xmlNode *act, Ucs_Ns_Script_t *scr, Pr
static ParseResult_t ParseScriptPortRead(xmlNode *act, Ucs_Ns_Script_t *scr, PrivateData_t *priv);
static ParseResult_t ParseScriptPause(xmlNode *act, Ucs_Ns_Script_t *scr, PrivateData_t *priv);
static ParseResult_t ParseRoutes(UcsXmlVal_t *ucs, PrivateData_t *priv);
+static bool IsAutoRouteId(uint16_t id, PrivateData_t *priv);
/************************************************************************/
/* Public Functions */
@@ -708,7 +710,7 @@ static ParseResult_t ParseAll(xmlNode *tree, UcsXmlVal_t *ucs, PrivateData_t *pr
uint32_t nodeCount;
xmlNode *sub;
ParseResult_t result;
- priv->autoRouteId = 0x8000;
+ priv->autoRouteId = ROUTE_AUTO_ID_START;
if (!GetCount(tree, NODE, &nodeCount, true))
RETURN_ASSERT(Parse_XmlError);
@@ -1535,9 +1537,19 @@ static ParseResult_t ParseRoutes(UcsXmlVal_t *ucs, PrivateData_t *priv)
sourceRoute = priv->pRtLst;
while (NULL != sourceRoute)
{
- if (!sourceRoute->isSource) /*There can be more sinks than sources, so count them*/
+ if (sourceRoute->isSource)
{
- ++routeAmount;
+ struct UcsXmlRoute *sinkRoute = priv->pRtLst;
+ while (NULL != sinkRoute)
+ {
+ if (sourceRoute != sinkRoute
+ && !sinkRoute->isSource
+ && (0 == strncmp(sourceRoute->routeName, sinkRoute->routeName, sizeof(sourceRoute->routeName))))
+ {
+ routeAmount++;
+ }
+ sinkRoute = sinkRoute->next;
+ }
}
sourceRoute = sourceRoute->next;
}
@@ -1559,22 +1571,30 @@ static ParseResult_t ParseRoutes(UcsXmlVal_t *ucs, PrivateData_t *priv)
&& !sinkRoute->isSource
&& (0 == strncmp(sourceRoute->routeName, sinkRoute->routeName, sizeof(sourceRoute->routeName))))
{
- Ucs_Rm_Route_t *route = &ucs->pRoutes[ucs->routesSize++];
+ Ucs_Rm_Route_t *route;
+ if(ucs->routesSize >= routeAmount)
+ {
+ RETURN_ASSERT(Parse_MemoryError);
+ }
+ route = &ucs->pRoutes[ucs->routesSize++];
route->source_endpoint_ptr = sourceRoute->ep;
route->sink_endpoint_ptr = sinkRoute->ep;
- route->active = sinkRoute->isActive;
- route->route_id = sinkRoute->routeId;
+ if (!IsAutoRouteId(sourceRoute->routeId, priv))
+ {
+ route->active = sourceRoute->isActive;
+ route->route_id = sourceRoute->routeId;
+ }
+ else
+ {
+ route->active = sinkRoute->isActive;
+ route->route_id = sinkRoute->routeId;
+ }
}
sinkRoute = sinkRoute->next;
}
}
sourceRoute = sourceRoute->next;
}
- if (routeAmount != ucs->routesSize)
- {
- UcsXml_CB_OnError("At least one sink (num=%d) is not connected, because of wrong Route name!", 2, (routeAmount - ucs->routesSize));
- RETURN_ASSERT(Parse_XmlError);
- }
#ifdef DEBUG
/* Third perform checks when running in debug mode*/
@@ -1610,3 +1630,10 @@ static ParseResult_t ParseRoutes(UcsXmlVal_t *ucs, PrivateData_t *priv)
#endif
return Parse_Success;
}
+
+static bool IsAutoRouteId(uint16_t id, PrivateData_t *priv)
+{
+ assert(NULL != priv);
+ return (id >= ROUTE_AUTO_ID_START && id <= priv->autoRouteId);
+}
+