Is Luos for me? 🤔

Messages

As a developer, you will have to create and use Luos messages to exchange information between servicesSoftware element run by Luos that can communicate with other services. It can be a driver or an app.. In order to do that, you have to understand how messages work.

Message structure

Luos messages are managed by the msg_t structure:

typedef struct{
    header_t header;
    uint8_t data[MAX_DATA_MSG_SIZE];
}msg_t;

All messages have a header. A header is a 7-byte field containing all information allowing services to understand the messages' context. All services in the network catch and decode the header of each sent and received message.

data is a table containing data.

Info: MAX_DATA_MSG_SIZE represents the maximum size of messages (default value is 128 bytes);

To send data to any services you want, you will have to first fill out some information on the header.

here is the header_t structure:

typedef struct{
    uint16_t protocol : 4;    /*!< Protocol version. */
    uint16_t target : 12;     /*!< Target address, it can be (ID, Multicast/Broadcast, Type). */
    uint16_t target_mode : 4; /*!< Select targeting mode (ID, ID+ACK, Multicast/Broadcast, Type). */
    uint16_t source : 12;     /*!< Source address, it can be (ID, Multicast/Broadcast, Type). */
    uint8_t cmd;              /*!< msg definition. */
    uint16_t size;            /*!< Size of the data field. */
}header_t;
  • Protocol (4 bits): This field provides the protocol revision. This field is automatically filled; you don't have to deal with it.
  • Target (12 bits): This field contains the target address. To understand the real destination of this field, you have to know the addressing mode contained on the Target_mode field.
  • Target_mode (4 bits): This field indicates the addressing mode and how to understand the Target field. It can take different values:
    • ID: This mode allows to communicate with a unique service using its ID without acknowledgment return.
    • IDACK: This mode allows to communicate with a unique service using its ID with acknowledgment return.
    • Type: This mode sends a message to all services with a given type, e.g. all "Sharp digital distance sensor".
    • Multicast/Broadcast: This mode allows multiple services to catch a message. In this case, the message contains a type of data used by multiple services.
    • NODEID: This mode allows to send a message to all the services of a specific node without acknowledgment return.
    • NODEIDACK: This mode allows to send a message to all the services of a specific node with acknowledgment return.
  • Source (12 bits): The unique ID of the transmitter service.
  • CMD (8 bits): The command defines the transmitted data's type.
  • Size (16 bits): Size of the incoming data.
  • ACK (8 bits): Acknowledgment signal demanded in target modes IDACK and NODEIDACK, after the good reception of the message.