SatNOGS-COMMS
4.1.0
A COMMS subsystem for CubeSats
Toggle main menu visibility
Loading...
Searching...
No Matches
msgq.hpp
Go to the documentation of this file.
1
/*
2
* SatNOGS-COMMS control library
3
*
4
* Copyright (C) 2024, Libre Space Foundation <http://libre.space>
5
*
6
* This program is free software: you can redistribute it and/or modify
7
* it under the terms of the GNU General Public License as published by
8
* the Free Software Foundation, either version 3 of the License, or
9
* (at your option) any later version.
10
*
11
* This program is distributed in the hope that it will be useful,
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
* GNU General Public License for more details.
15
*
16
* You should have received a copy of the GNU General Public License
17
* along with this program. If not, see <http://www.gnu.org/licenses/>.
18
*
19
* SPDX-License-Identifier: GNU General Public License v3.0 or later
20
*/
21
22
#pragma once
23
24
#include <cstdint>
25
#include <cstdlib>
26
27
namespace
satnogs::comms::lib::bsp
28
{
41
template
<
typename
T>
class
imsgq
42
{
43
public
:
49
imsgq
(
size_t
len) :
m_len
(len) {}
50
51
imsgq
(
const
imsgq
&) =
delete
;
52
58
size_t
59
max_size
()
const
60
{
61
return
m_len
;
62
}
63
72
virtual
size_t
73
size
() = 0;
74
84
virtual
int
85
put
(
const
T &msg,
size_t
timeout_ms) = 0;
86
95
virtual
int
96
put_isr
(
const
T &msg) = 0;
97
106
virtual
int
107
peek
(T *msg) = 0;
108
118
virtual
int
119
get
(T *msg,
size_t
timeout_ms) = 0;
120
129
virtual
int
130
get_isr
(T *msg) = 0;
131
132
protected
:
133
const
size_t
m_len
;
134
};
135
151
template
<
typename
T, const
size_t
LEN>
class
msgq
:
public
imsgq
<T>
152
{
153
public
:
154
msgq
() :
imsgq
<T>(LEN) {}
155
};
156
}
// namespace satnogs::comms::lib::bsp
satnogs::comms::lib::bsp::imsgq::size
virtual size_t size()=0
A virtual method that returns the current number of messages in the queue.
satnogs::comms::lib::bsp::imsgq::max_size
size_t max_size() const
A method that returns the maximum size of the message queue.
Definition
msgq.hpp:59
satnogs::comms::lib::bsp::imsgq::imsgq
imsgq(size_t len)
Constructs an imsgq object with a specified maximum size.
Definition
msgq.hpp:49
satnogs::comms::lib::bsp::imsgq::peek
virtual int peek(T *msg)=0
A virtual method that peeks at the next message in the queue without removing it.
satnogs::comms::lib::bsp::imsgq::put_isr
virtual int put_isr(const T &msg)=0
A virtual method that enqueues a message into the queue from an interrupt context.
satnogs::comms::lib::bsp::imsgq::get_isr
virtual int get_isr(T *msg)=0
A virtual method that retrieves a message from the queue from an interrupt context.
satnogs::comms::lib::bsp::imsgq::imsgq
imsgq(const imsgq &)=delete
satnogs::comms::lib::bsp::imsgq::get
virtual int get(T *msg, size_t timeout_ms)=0
A virtual method that retrieves a message from the queue.
satnogs::comms::lib::bsp::imsgq::put
virtual int put(const T &msg, size_t timeout_ms)=0
A virtual method that enqueues a message into the queue.
satnogs::comms::lib::bsp::imsgq::m_len
const size_t m_len
Definition
msgq.hpp:133
satnogs::comms::lib::bsp::msgq::msgq
msgq()
Definition
msgq.hpp:154
satnogs::comms::lib::bsp
Definition
adc.hpp:26
libsatnogs-comms
include
satnogs-comms-lib
bsp
msgq.hpp
Generated by
1.17.0