Skip to content
This repository has been archived by the owner on Jan 7, 2019. It is now read-only.

Commit

Permalink
[XPCC] Require Identifier for containers.
Browse files Browse the repository at this point in the history
In the progress of adding raw Ethernet frames as a backend for XPCC
communication, each container requires a unique id.

When using CAN as a backend filtering is done by component id.
Normally, each CAN controller has enough filters to accommodate up to
ten components per container. E.g. STM32F4 has 14 CAN filters.

When moving to Ethernet, the Ethernet MAC controller only has two or
six filters which may be not enough. The filters are more difficult to
configure.

The fifth byte of the MAC address will be used for the container Id and
the sixth byte for the component Id.
MAC filtering then can be easily implemented by filtering for the first
five bytes of the MAC address.

There is no overhead for CAN communication as container Id is omitted.
  • Loading branch information
strongly-typed committed Dec 10, 2016
1 parent e41d8b1 commit 5f5934a
Show file tree
Hide file tree
Showing 7 changed files with 29 additions and 8 deletions.
1 change: 1 addition & 0 deletions examples/communication/xml/communication.dtd
Original file line number Diff line number Diff line change
Expand Up @@ -79,4 +79,5 @@
<!ELEMENT container (description|component)*>
<!ATTLIST container
name CDATA #REQUIRED
id CDATA #REQUIRED
>
10 changes: 5 additions & 5 deletions examples/communication/xml/communication.xml
Original file line number Diff line number Diff line change
Expand Up @@ -71,24 +71,24 @@
</component>

<!-- Containers -->
<container name="sender">
<container name="sender" id="0x10">
<component name="sender" />
</container>

<container name="receiver">
<container name="receiver" id="0x20">
<component name="receiver" />
</container>

<container name="odometry">
<container name="odometry" id="0x30">
<component name="odometry" />
</container>

<container name="senderreceiver">
<container name="sender receiver" id="0x40">
<component name="sender" />
<component name="receiver" />
</container>

<container name="gui">
<container name="gui" id="0x50">
<component name="gui" />
</container>

Expand Down
2 changes: 1 addition & 1 deletion examples/linux/communication/basic/project.cfg
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[communication]
container = senderreceiver
container = sender receiver
source = ../../../communication/xml/communication.xml

[environment]
Expand Down
2 changes: 2 additions & 0 deletions tools/system_design/builder/cpp_identifier.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ def generate(self):

cppFilter = {
'enumElement': filter.enumElement,
'enumElementStrong': filter.typeName,
'enumValue': filter.toHexValue,
}

Expand All @@ -66,6 +67,7 @@ def generate(self):

substitutions = {
'domains' : self.tree.domains,
'containers' : self.tree.containers,
'components': components,
'actions': self.tree.components.actions,
'events': self.tree.events,
Expand Down
10 changes: 10 additions & 0 deletions tools/system_design/builder/templates/robot_identifier.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,16 @@ namespace {{ namespace }}
}
}
}

namespace container
{
enum class Identifier : uint8_t
{
{%- for item in containers %}
{{ item.name | enumElementStrong }} = {{ item.id | enumValue }},
{%- endfor %}
};
}

namespace component
{
Expand Down
1 change: 1 addition & 0 deletions tools/system_design/xml/dtd/rca_container.dtd
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
<!ELEMENT container (description|bootloader|component)*>
<!ATTLIST container
name CDATA #REQUIRED
id CDATA #REQUIRED
>

<!ELEMENT domain (#PCDATA)>
Expand Down
11 changes: 9 additions & 2 deletions tools/system_design/xmlparser/container.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,11 @@

class Container:
""" Representation of a container which bundles components.
For microcontrollers, each container runs on a separate controller.
Attributes:
name -- Name of the container
id -- Globally unique identifier of the container (0..255).
bootloader -- Information about a bootloader used to program this
container.
description -- Description string
Expand Down Expand Up @@ -43,6 +45,7 @@ def __init__(self, node):
self.bootloader = bootloader

self.description = xml_utils.get_description(node)
self.id = xml_utils.get_identifier(self.node)

self.components = None
self.events = EventContainer()
Expand Down Expand Up @@ -95,7 +98,7 @@ def updateIndex(self):
self.indexReady = True

def __cmp__(self, other):
return cmp(self.name.lower(), other.name.lower())
return cmp(self.name.lower(), other.name.lower()) or cmp(self.id, other.id)

def dump(self):
str = "%s : container\n" % self.__str__()
Expand All @@ -104,4 +107,8 @@ def dump(self):
return str[:-1]

def __str__(self):
return self.name
if self.id is None:
name = "[--] %s" % self.name
else:
name = "[%02x] %s" % (self.id, self.name)
return name

0 comments on commit 5f5934a

Please sign in to comment.