SatNOGS-COMMS  4.1.0
A COMMS subsystem for CubeSats
Loading...
Searching...
No Matches
satnogs::comms::msg_arbiter Class Reference

Incoming/Outgoing Message Arbiter. More...

#include <msg_arbiter.hpp>

Classes

class  msg

Public Types

enum class  subsys : uint8_t {
  CAN1 = 0 , CAN2 = 1 , RADIO_UHF = 2 , RADIO_SBAND = 3 ,
  SPI = 4 , UART_PC104 = 5
}
 Peripheral identifier. More...

Public Member Functions

 msg_arbiter (msg_arbiter const &)=delete
void operator= (msg_arbiter const &)=delete
int push (const msg_arbiter::msg &m, k_timeout_t wait=K_MSEC(CONFIG_MSG_ARBITER_TIMEOUT_MS))
 Push a received message for processing.
int pull (msg_arbiter::msg &m, subsys s, k_timeout_t wait=K_MSEC(CONFIG_MSG_ARBITER_TIMEOUT_MS))
 Pulls a message for a specific IO interface.
int fwd (const msg_arbiter::msg &m, subsys s, k_timeout_t wait=K_MSEC(CONFIG_MSG_ARBITER_TIMEOUT_MS))
 Forward a received message for processing.
int fwd (uint8_t mapid, uint8_t vcid, const msg_arbiter::msg &m, subsys s, k_timeout_t wait=K_MSEC(CONFIG_MSG_ARBITER_TIMEOUT_MS))
uint32_t backpressure (subsys s)
 Returns the number of messages that are waiting in the message queue of a specific subsystem.
void start ()
 Starts the processing task for incoming messages handling.

Static Public Member Functions

static msg_arbiterget_instance ()
 Singleton access to a unique and global msg_arbiter instance.

Static Public Attributes

static constexpr size_t mtu = CONFIG_MAX_MTU
static constexpr size_t rx_msgq_size = CONFIG_RX_MSGQ_SIZE
static constexpr size_t can1_tx_msgq_size = CONFIG_CAN1_TX_MSGQ_SIZE
static constexpr size_t can2_tx_msgq_size = CONFIG_CAN2_TX_MSGQ_SIZE
static constexpr size_t uhf_tx_msgq_size = CONFIG_UHF_TX_MSGQ_SIZE
static constexpr size_t sband_tx_msgq_size = CONFIG_SBAND_TX_MSGQ_SIZE

Detailed Description

Incoming/Outgoing Message Arbiter.

The msg_arbiter class is responsible for:

  • Receiving messages: It handles incoming messages from various configured input interfaces.
  • Message queuing: It maintains a thread-safe message queue for received frames and individual queues for each output interface.
  • Message processing: It processes valid telecommands:
    • Local processing: Handles telecommands specific to the SatNOGS-COMMS subsystem.
    • Forwarding: Forwards telecommands to the appropriate output interface for delivery to target subsystems within the satellite.

Usage:

To use the msg_arbiter class:

  1. Instantiate: Create an instance of the class. The class provides singleton access, via the get_instance() method.
  2. Start: Begin the message processing loop by calling the start() method.
  3. Push messages: Use the push() method to enqueue received messages from any of the available IO interfaces.
  4. Pull messages: Messages for specific interfaces can be pulled using the pull() method.
Note
Each output interface has a dedicated message queue. A pull() call that may block for a specific interface, does not block the other available.
Warning
The start() method should be called once as early as possible in the firmware. Multiple calls of start() may result to undefined behavior.

flowchart TD subgraph arbiter["msg_arbiter Task"] msgq["Read RX message queue"] route["Perfrom routing"] n1["Is for SatNOGS-COMMS?"] parse["Parse telecommand"] tc["Handle telecommand"] tlm["Produce telemetry"] radiomsgq["Radio TX mssq"] uartAmsgq["UART A TX mssq"] uartBmsgq["UART B TX mssq"] canAmsgq["CAN A TX mssq"] canBmsgq["CAN B TX mssq"] end msgq --> parse parse --> n1 n1 -- No --> route n1 -- Yes --> tc tc --> tlm tlm --> route radio["Radio RX Task"] -- msg_arbiter::push() --> msgq uartA["UART A RX Task"] -- msg_arbiter::push() --> msgq uartB["UART B RX Task"] -- msg_arbiter::push() --> msgq canA["CAN A RX Task"] -- msg_arbiter::push() --> msgq canB["CAN B RX Task"] -- msg_arbiter::push() --> msgq radiotx["Radio TX Task"] uartAtx["UART A TX Task"] uartBtx["UART B TX Task"] canAtx["CAN A TX Task"] canBtx["CAN B TX Task"] route --> radiomsgq -- msg_arbiter::pull(radio) --> radiotx route --> uartAmsgq -- msg_arbiter::pull(UART A) --> uartAtx route --> uartBmsgq -- msg_arbiter::pull(UART B) --> uartBtx route --> canAmsgq -- msg_arbiter::pull(CAN A) --> canAtx route --> canBmsgq -- msg_arbiter::pull(CAN B) --> canBtx n1@{ shape: diam}

Definition at line 71 of file msg_arbiter.hpp.

Member Enumeration Documentation

◆ subsys

enum class satnogs::comms::msg_arbiter::subsys : uint8_t
strong

Peripheral identifier.

SatNOGS-COMMS has several peripherals that can be configured as input/output interfaces. Each msg contains the IO interface that was received.

Enumerator
CAN1 
CAN2 
RADIO_UHF 
RADIO_SBAND 
SPI 
UART_PC104 

Definition at line 103 of file msg_arbiter.hpp.

Constructor & Destructor Documentation

◆ msg_arbiter()

satnogs::comms::msg_arbiter::msg_arbiter ( msg_arbiter const & )
delete

Member Function Documentation

◆ backpressure()

uint32_t satnogs::comms::msg_arbiter::backpressure ( subsys s)

Returns the number of messages that are waiting in the message queue of a specific subsystem.

Parameters
sthe target IO interface
Returns
uint32_t the number of messages inside the message queue

Definition at line 200 of file msg_arbiter.cpp.

◆ fwd() [1/2]

int satnogs::comms::msg_arbiter::fwd ( const msg_arbiter::msg & m,
subsys s,
k_timeout_t wait = K_MSEC(CONFIG_MSG_ARBITER_TIMEOUT_MS) )

Forward a received message for processing.

Parameters
mReference to a message object that will be filled with the pulled data. The caller must ensure the object is allocated before calling.
sthe target IO interface
waitWaiting period to add the message, or one of the special values K_NO_WAIT and K_FOREVER
Returns
int 0 on success, negative error code on timeout of failure
Exceptions
scl::inval_arg_exceptionif the provided subsystem is invalid
scl::can_enable_exceptionif one of the CAN interfaces are not enabled

Definition at line 145 of file msg_arbiter.cpp.

◆ fwd() [2/2]

int satnogs::comms::msg_arbiter::fwd ( uint8_t mapid,
uint8_t vcid,
const msg_arbiter::msg & m,
subsys s,
k_timeout_t wait = K_MSEC(CONFIG_MSG_ARBITER_TIMEOUT_MS) )

Definition at line 172 of file msg_arbiter.cpp.

◆ get_instance()

msg_arbiter & satnogs::comms::msg_arbiter::get_instance ( )
inlinestatic

Singleton access to a unique and global msg_arbiter instance.

Note
The start() method should be called once for the full functionality of this subsystem
Returns
msg_arbiter& a unique and global msg_arbiter instance

Definition at line 90 of file msg_arbiter.hpp.

◆ operator=()

void satnogs::comms::msg_arbiter::operator= ( msg_arbiter const & )
delete

◆ pull()

int satnogs::comms::msg_arbiter::pull ( msg_arbiter::msg & m,
subsys s,
k_timeout_t wait = K_MSEC(CONFIG_MSG_ARBITER_TIMEOUT_MS) )

Pulls a message for a specific IO interface.

Parameters
mReference to a message object that will be filled with the pulled data. The caller must ensure the object is allocated before calling.
sthe target IO interface
waitWaiting period to receive the message, or one of the special values K_NO_WAIT and K_FOREVER
Returns
int 0 on success, negative error code on timeout of failure
Exceptions
scl::inval_arg_exceptionif the provided subsystem is invalid

Definition at line 115 of file msg_arbiter.cpp.

◆ push()

int satnogs::comms::msg_arbiter::push ( const msg_arbiter::msg & m,
k_timeout_t wait = K_MSEC(CONFIG_MSG_ARBITER_TIMEOUT_MS) )

Push a received message for processing.

Parameters
mthe received message
waitWaiting period to add the message, or one of the special values K_NO_WAIT and K_FOREVER
Todo
Append radio drop frames stats in case of failure to push to the message queue
Returns
int 0 on success, negative error code on timeout of failure

Definition at line 98 of file msg_arbiter.cpp.

◆ start()

void satnogs::comms::msg_arbiter::start ( )

Starts the processing task for incoming messages handling.

Warning
This method should be called only once

Definition at line 222 of file msg_arbiter.cpp.

Member Data Documentation

◆ can1_tx_msgq_size

size_t satnogs::comms::msg_arbiter::can1_tx_msgq_size = CONFIG_CAN1_TX_MSGQ_SIZE
staticconstexpr

Definition at line 76 of file msg_arbiter.hpp.

◆ can2_tx_msgq_size

size_t satnogs::comms::msg_arbiter::can2_tx_msgq_size = CONFIG_CAN2_TX_MSGQ_SIZE
staticconstexpr

Definition at line 77 of file msg_arbiter.hpp.

◆ mtu

size_t satnogs::comms::msg_arbiter::mtu = CONFIG_MAX_MTU
staticconstexpr

Definition at line 74 of file msg_arbiter.hpp.

◆ rx_msgq_size

size_t satnogs::comms::msg_arbiter::rx_msgq_size = CONFIG_RX_MSGQ_SIZE
staticconstexpr

Definition at line 75 of file msg_arbiter.hpp.

◆ sband_tx_msgq_size

size_t satnogs::comms::msg_arbiter::sband_tx_msgq_size = CONFIG_SBAND_TX_MSGQ_SIZE
staticconstexpr

Definition at line 79 of file msg_arbiter.hpp.

◆ uhf_tx_msgq_size

size_t satnogs::comms::msg_arbiter::uhf_tx_msgq_size = CONFIG_UHF_TX_MSGQ_SIZE
staticconstexpr

Definition at line 78 of file msg_arbiter.hpp.


The documentation for this class was generated from the following files: