Lorien:IncludingComponents

From Lorien Documentation
Jump to: navigation, search

If you followed the component tutorial you should be quite familiar with how to include other components in your system; here we expand on this with a little more detail.

Lorien systems tend to run minimal collections of components; we only include the exact set of components that we currently need in support of our currently required functionality. This allows us to constantly make the best use over time of limited resources. If we don't currently need an SHT11 sensor driver onboard for example we can just unload it, and reload it later if we need it again.

The decision as to whether or not to include components in an initial image for flashing to a sensor node is left entirely to the programmer. Lorien will not automatically include any components. Because Lorien components are at a large, comprehensible granularity (an entire radio driver for example is one component) this is not usually a problem and rather empowers the programmer to tune their system.

The steps for finding and including the components you want to use are generally as follows:

First, find the component source file in the components/ directory. This directory is organised as "apps", "library" and "os". The components in both apps and library are platform-independent, while those in "os" are platform-specific, generally comprising hardware drivers and schedulers. Let's assume we want to use the SHT11 sensor driver, which is in components/os/platform_specific/tmote/peripherals

Once you've found the component you want, open its source file and look for the component provides declaration to see which interfaces this component supports. You can then locate the corresponding interface definitions in the interfaces/ directory to find out how to use this component's functionality, and declare required interfaces of the appropriate type in your own component's component requires declaration. In the SHT11 driver we can see that it supports two interfaces of type ISense, one varianted as Temperature and the other as Humidity. In our component we can simply declare a required interface of type ISense and leave the variant selection to the architecture level.

Next, we need to know the abstract role name that the component you want uses. To find this open the corresponding configuration fragment (.cfg file) of the component you want to use (this will be in the same directory as the component's source code and will often have the same name). Underneath the [Role] section of the fragment you'll find the role name and the object file from which the component type is expected to be loaded. Also specified may be [Dependencies] which we'll come back to shortly. Our SHT11 driver component has a configuration fragment called SHT11.cfg, which specifies the role name THSense and the object file sht11.so.

Now that we've located the component we want to use, found the interfaces with which we would like to interact with it, and found the role name of the component, we need to update our own component's configuration fragment to specify the connection of our required interface(s) to that component's compatible provided interface(s). Again see the component tutorial for more detail on this, but for our SHT11 example we specify in our configurtion fragment:

ISense->THSense:Temperature

Here we're connecting our required interface ISense to a provided interface of the same type in the role THSense, and we're further selecting the Temperature variant from THSense.

Finally we need to update our make rule to include the component we wanted to use. We do this by adding three things: the compile statement for the component source; the compile statement for the component's configuration fragment; and the inclusion of the compiled configuration fragment in our system configuration.

The first two statements use LCC to compile the component source and CFBUILD to compile the configuration fragment. For our SHT11 example this means adding to our make rule:

	$(LCC) $(PLATFORM_DIR)/peripherals/sensor_sht11.c -o $(OBJDIR)/sht11.so
	$(CFBUILD) $(PLATFORM_DIR)/peripherals/SHT11.cfg -o $(OBJDIR)/SHT11

And finally we update the line containing CONFIG= to include the compiled configuration fragment:

CONFIG="$(CORE_CONFIG) ... $(OBJDIR)/SHT11"

And that's it - the procedure to include components in Lorien systems. You can browse a list of the interfaces available in Lorien's standard distribution [here], where each interface lists known implementing components, their configuration fragments, role names and expected object file names.

If a configuration fragment of a component you'd like to include contains a [Dependencies] section, you'll also need to ensure that all of the role names specified are included in the system with their implementing components and compatible provided interfaces.

Personal tools
Namespaces
Variants
Actions
Navigation
Toolbox