Technology Careers Contact
Documentation Community Download

Create Luos modules

As a developer you will always develop your functionalities into modules and never into the main() program.

Warning: Make sure to read and understand how to Create Luos projects before reading this page.

How to create and initialize a module

To create a module, you have to call this function:

module_t* luos_module_create(void* callback, module_type_t type, char* default_alias);

The returned module_t* is a module structure pointer that will be useful to make your module act in the network after this initialization.

callback is a pointer to a callback function called by Luos when your module receive messages from other modules (see Real-time configuration page for more details). This function needs to have a specific format:

void module_cb(module_t *module, msg_t *msg)
  • module is the module pointer of the module receiving the data (basically, it's your module).
  • msg is the message your module received.

type is the type of the your new module represented by a number. Some basic types (e.g. DISTANCE_MOD, VOLTAGE_MOD, etc.) are already available in the module_type_t enum structure of Luos. You can also create your own on top of the luos one.

default alias is the alias by default for your new module. e.g. MyModule02. This alias is the one your module will take if no other alias is set by the user of your functionality hosted in your module. Aliases have a maximum size of 16 characters.

Following the project rules, here is a code example for a button module:

module_t* module_btn;

void rx_btn_cb(module_t *module, msg_t *msg){
    // Manage received messages
}

void button_init(void) {
    module_t* module_btn = luos_module_create(rx_btn_cb, STATE_MOD, "button_mod");
}

void button_loop(void) {
}

Note: According to the real-time configuration you chose, an additional line of code may be necessary. See Real-time configuration page for more details.

Modules categories

To make your development as clean as possible, you have to understand in which category (Driver or App) each module of the project is.

By following the categories guidelines, you will be able to make clean and reusable functionalities.

Drivers guidelines

A driver is a type of module that drives hardware. Motors, distance sensors, LEDs are all drivers.

By designing a driver, you have to keep the following rules in mind:

  • A driver module always uses a standard Luos type to be usable by any other modules.
  • A driver module always uses standard object dictionarySet of objects based on SI metric system that can be transmitted through Luos messages. Any object can easily be converted in other units. structures to be usable by any other modules.
  • A driver module never depends or uses any other modules (driver or app).
  • A driver module is "dumb", as it can't do anything else than manage its hardware feature (but it does it very well).

You can have multiple driver modules on the same nodeHardware element (MCU) hosting and running Luos and hosting one or several modules. managing different hardware functionalities of your board, it's your call to sort them depending on your design.

Apps guidelines

An applications or app is a type of module that only manages software items such as functions or algorithms. Apps use other modules to make your device act, operate, and behave. Apps can be placed in any nodesHardware element (MCU) hosting and running Luos and hosting one or several modules. on a Luos network without any hardware or code modifications. However, the choice of the hosting node can impact global performances of the system.

By designing an app, you have to keep the following rules in mind:

  • An app can't have hardware dependencies.
  • An app can use custom module types.
  • An app must use standard object dictionarySet of objects based on SI metric system that can be transmitted through Luos messages. Any object can easily be converted in other units. structures. If the structures used are not standard, Gate modules could be completely unable to manage them.

Apps are the embedded smartness of your device, and at least one of them should run a network detection in order to map every modules in every nodes in your device and make it work properly. Go to Routing table page for more informations.


Follow Watch Star

Luos is constantly evolving! Keep in touch to follow the last updates: