Technology Careers Contact
Documentation Community Download Support

Routing Table

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

The routing table is a feature of Luos allowing every modulesSoftware element run by Luos that can communicate with other modules. Can be driver or app. to own a "map" (or topology) of the entire network of your device. This map allows modules to know their physical position and to search and interact with other modules easily.
This feature is particularly used by apps modules to find other modules they need to interact with.


Routing tables are automatically generated and shared to all modules by network detections. A detection can be initiated by any module, but driver modules should not be able to run it and this kind of features should be only used on app modules.

To run a detection, type:


where app is the module_t pointer running the detection.

A non-detected module (not in the routing table) has a specific ID of 0. At the beginning of the detection, Luos erases each module's ID in the network, so all of them will have the ID 0 during this operation. You can use it on your modules code to act consequently to this detection if you need it (for example, a module can monitor its ID to detect if a detection has been made and if it has to reconfigure its auto-update).

Then the module running the detection will have the ID 1 and the other modules will have an ID between 2 and 4096, depending on their position from the module detector. The IDs are attributed to the modules according to their position from the detector module and to the branch they are in. The ID attribution begins first to the PTPA port, then PTPB, etc. When each module in the network has an attributed ID, the detection algorithm proceeds to the creation of the routing table and shares it with every modules (saved only one time per node).

Sometimes, multiple modules in the network can have the same alias, which is not allowed to prevent module confusion. In this case, detection algorithm will add a number after each instance of this alias on the routing table.

Warning: Be careful that during a detection, a module can change ID depending on the module running this detection. Do not consider your module's ID fixed. Also, be aware that every modules remove their auto-update configuration during the detection to prevent any ID movement.


As explained in this page, nodesHardware element (MCU) hosting and running Luos and hosting one or several modules. can host multiple modules. To get the topology of your device, the routing table references physical connexions between your nodes and lists all the modules in each one of them.

The routing table is a table of a routing_table_t structure containing nodes or modules information. The maximum number of modules and nodes are managed by the precompilation constant MAX_MODULES_NUMBER (set to 40 by default).

route_table_t route_table[MAX_MODULES_NUMBER];

The routing table structure has two modes: module entry mode and node entry mode.

typedef struct __attribute__((__packed__)){
    entry_mode_t mode;
    union {
        struct __attribute__((__packed__)){ // MODULE entry mode
            unsigned short id; // Module ID
            unsigned char type; /*!< Module type. */
            char alias[MAX_ALIAS_SIZE]; /*!< Module alias. */
        struct __attribute__((__packed__)){ // NODE entry mode
            luos_uuid_t uuid; // Node UUID
            unsigned short port_table[4]; // Node link table

Module entry mode

This mode allows route_table to contain:

  • id: module's unique id
  • type: module's type
  • alias: module's alias

For more information, please refer to the Modules page of this documentation.

Node entry mode

This mode gives physical information of your devices.

The uuid is the serial number of the microcontroler hosting Luos. This number is unique, you can use it to identify each one of your nodes.

The port_table allows to share topological information of your network. Each element of this table corresponds to a physical Luos port of the node and indicates which node is connected to it by sharing a module's id.

Here is an example:

As shown on this image, elements of the port_table indicate the first or last module id of the connected node through a given port.

Specific values taken by port_table:

  • 0: this port is waiting to discover who is connected with. You should never see this value.
  • 0x0FFF: this port is not connected to any other Node.

Note: Routing tables can be easily displayed using Pyluos through a USB gate. Please refer to the Pyluos routing table section for more information.

Search tools

The routing table library provides the following search tools to find modules and nodes' information into a Luos network:

Find a module's id from its aliasid_from_alias(char* alias);int
Find a module's id from its type (return the first of the list)id_from_type(module_type_t type);int
Find a module's string from its type (return the first of the list)string_from_type(module_type_t type);char*
Find a module's alias from its id (return the first of the list)alias_from_id(uint16_t id);char*
Find a module's type from its idtype_from_id(uint16_t id);module_type_t
Find a module's type from its aliastype_from_alias(char* alias);module_type_t
Test if a module's type is a sensoris_sensor(module_type_t type);uint8_t
Get a node's idget_node_id(unsigned short index);int
Get the number of nodes in a Luos networkget_node_nb(void);int
Get the list of all the nodes in a Luos networkget_node_list(unsigned short* list);void

Management tools

Here are the management tools provided by the routing table library:

Compute the rooting tablecompute_route_table_entry_nb(void);void
Detect the modules in a Luos networkdetect_modules(module_t* module);void
Convert a node to a routing table entryconvert_board_to_route_table(route_table_t* entry, luos_uuid_t uuid, unsigned short* port_table, int branch_nb);void
Convert a module to a routing table entryconvert_module_to_route_table(route_table_t* entry, module_t* module);void
Insert an entry into the routing tableinsert_on_route_table(route_table_t* entry);void
Remove an entry in the routing table (by id)remove_on_route_table(int id);void
Erase routing tableflush_route_table(void);void
Get the routing tableget_route_table(void);route_table_t*
Get the last module in a Luos networkget_last_module(void);int
Get the last entry in a Luos networkget_last_entry(void);int

Follow Watch Star