SatNOGS-COMMS
4.1.0
A COMMS subsystem for CubeSats
Toggle main menu visibility
Loading...
Searching...
No Matches
telecommand.hpp
Go to the documentation of this file.
1
/*
2
* SatNOGS-COMMS MCU software
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 "
msg_arbiter.hpp
"
25
#include "
ota.hpp
"
26
#include <cstddef>
27
#include <cstdint>
28
#include <cstring>
29
#include <etl/bit_stream.h>
30
31
namespace
satnogs::comms
32
{
33
class
telecommand
34
{
35
public
:
36
static
telecommand
&
37
get_instance
()
38
{
39
static
telecommand
instance;
40
return
instance;
41
}
42
43
enum class
packet_id
: uint16_t
44
{
45
PING
= 1,
46
TELEMETRY_REQ
= 2,
47
OTA_REQUEST
= 3,
48
OTA_FINISH
= 4,
49
OTA_DATA
= 5,
50
TEST_TX_SIMPLE
= 6,
51
TESTS_STOP
= 7,
52
FPGA_ENABLE
= 8,
53
STORAGE_ENABLE
= 9,
54
STORAGE_DIRECTION
= 10,
55
STOP_WDT_UPDATE
= 11,
56
FREQ_SET
= 12,
57
TX_INHIBIT
= 13,
58
TX_GAIN
= 14,
59
IO_WDT_PERIOD
= 15,
60
SET_RX_GAIN_MODE
= 16,
61
EMMC_TEST
= 17,
62
RESET_RADIO_STATS
= 18,
63
SET_RFFE_PARAMS
= 19,
64
SET_RTC
= 20,
65
REBOOT
= 21,
66
SET_PLL_CLK_SRC
= 22,
67
RESET_SETTINGS
= 23,
68
SET_FILTER
= 24,
69
STORAGE_LS
= 25,
70
STORAGE_READ
= 26,
71
STORAGE_MKDIR
= 27,
72
STORAGE_RMDIR
= 28,
73
STORAGE_RM
= 29,
74
STORAGE_WRITE
= 30,
75
STORAGE_WRITE_OFFSET
= 31,
76
STORAGE_FSTATS
= 32,
77
RING_BUFFER_LOGS
= 33,
78
SAVE_SETTINGS
= 34,
79
SET_AGC0_CONF
= 35,
80
SET_AGC1_CONF
= 36,
81
SET_GAIN0_CONF
= 37,
82
SET_GAIN1_CONF
= 38,
83
SET_MODULATION
= 39,
84
SET_TX_FSK_CONF
= 40,
85
SET_RX_FSK_CONF
= 41,
86
DISK_RAW_WRITE
= 42,
87
DISK_RAW_READ
= 43,
88
DISK_SECTORS_ERASE
= 44,
89
SET_RADIO_ENABLE
= 45,
90
SET_THERMAL_MONITOR_PARAMS
= 46,
91
SET_TX_GS_TURNAROUND_TIME
= 47,
92
FPGA_SET_BOOT_MODE
= 48,
93
SET_FLASH_MONITOR_DELAY_SEC
= 49,
94
RESET_ALL_OTA_SESSIONS
= 50,
95
RESET_OTA_SESSION
= 51,
96
CONFIRM_IMAGE
= 52,
97
SET_RADIO_DUTY_CYCLE
= 53,
98
SET_TX_WAIT_MS
= 54
99
};
100
101
/* Primary traits template for all the telecommand types defined by a specific
102
* tc_packet_id */
103
template
<packet_
id
A>
class
parser
;
104
105
enum class
storage_direction
:
bool
106
{
107
MCU
= 0,
108
FPGA
= 1
109
};
110
111
class
ccsds_tc_header
112
{
113
public
:
114
static
constexpr
size_t
size
= 8U;
115
uint8_t
version
;
116
uint8_t
type
;
117
uint8_t
sec_hdr
;
118
uint16_t
apid
;
119
uint8_t
group_flags
;
120
uint16_t
count
;
121
uint16_t
length
;
122
uint16_t
packet_id_type
;
123
124
ccsds_tc_header
()
125
:
version
(0),
126
type
(0),
127
sec_hdr
(0),
128
apid
(0),
129
group_flags
(0),
130
count
(0),
131
length
(0),
132
packet_id_type
(0)
133
{
134
}
135
136
void
137
deserialize
(etl::bit_stream_reader &reader)
138
{
139
version
= reader.read<uint8_t>(3).value();
140
type
= reader.read<uint8_t>(1).value();
141
sec_hdr
= reader.read<uint8_t>(1).value();
142
apid
= reader.read<uint16_t>(11).value();
143
group_flags
= reader.read<uint8_t>(2).value();
144
count
= reader.read<uint16_t>(14).value();
145
length
= reader.read<uint16_t>(16).value();
146
packet_id_type
= reader.read<uint16_t>(16).value();
147
}
148
};
149
150
class
prefixed_string
151
{
152
public
:
153
prefixed_string
() =
default
;
154
155
size_t
length
;
156
etl::string<CONFIG_STORAGE_MAX_PATH_LEN>
value
;
157
158
void
159
deserialize
(etl::bit_stream_reader &reader)
160
{
161
value
.clear();
162
length
= reader.read<uint32_t>(32).
value
();
163
for
(
size_t
i = 0; i <
length
; ++i) {
164
value
.push_back(reader.read<
char
>(8).value());
165
}
166
}
167
};
168
169
/* Singleton */
170
telecommand
(
telecommand
const
&) =
delete
;
171
172
void
173
operator=
(
telecommand
const
&) =
delete
;
174
175
bool
176
ccsds_frame_valid
(
const
uint8_t *b,
size_t
len);
177
178
int
179
get_frame_count
();
180
181
bool
182
decode_ccsds_xtce
(
msg_arbiter::msg
&m,
int
wdgid);
183
184
bool
185
decode_ccsds_xtce
(
msg_arbiter::msg
&resp,
const
msg_arbiter::msg
&req,
186
int
wdgid);
187
188
static
void
189
deserialize
(etl::bit_stream_reader &reader,
float
&x);
190
191
static
void
192
deserialize
(etl::bit_stream_reader &reader,
double
&x);
193
194
private
:
195
telecommand
();
196
197
uint32_t m_frame_count;
198
199
bool
200
parse_tlm_req(
msg_arbiter::msg
&m, etl::bit_stream_reader &reader);
201
202
bool
203
parse_ring_buffer_logs(
msg_arbiter::msg
&m, etl::bit_stream_reader &reader);
204
205
bool
206
parse_storage_tlm(
msg_arbiter::msg
&m, etl::bit_stream_reader &reader,
207
packet_id
id
);
208
};
209
210
}
// namespace satnogs::comms
satnogs::comms::msg_arbiter::msg
Definition
msg_arbiter.hpp:118
satnogs::comms::telecommand::ccsds_tc_header::ccsds_tc_header
ccsds_tc_header()
Definition
telecommand.hpp:124
satnogs::comms::telecommand::ccsds_tc_header::apid
uint16_t apid
Definition
telecommand.hpp:118
satnogs::comms::telecommand::ccsds_tc_header::count
uint16_t count
Definition
telecommand.hpp:120
satnogs::comms::telecommand::ccsds_tc_header::sec_hdr
uint8_t sec_hdr
Definition
telecommand.hpp:117
satnogs::comms::telecommand::ccsds_tc_header::group_flags
uint8_t group_flags
Definition
telecommand.hpp:119
satnogs::comms::telecommand::ccsds_tc_header::length
uint16_t length
Definition
telecommand.hpp:121
satnogs::comms::telecommand::ccsds_tc_header::size
static constexpr size_t size
Definition
telecommand.hpp:114
satnogs::comms::telecommand::ccsds_tc_header::packet_id_type
uint16_t packet_id_type
Definition
telecommand.hpp:122
satnogs::comms::telecommand::ccsds_tc_header::deserialize
void deserialize(etl::bit_stream_reader &reader)
Definition
telecommand.hpp:137
satnogs::comms::telecommand::ccsds_tc_header::version
uint8_t version
Definition
telecommand.hpp:115
satnogs::comms::telecommand::ccsds_tc_header::type
uint8_t type
Definition
telecommand.hpp:116
satnogs::comms::telecommand::parser
Definition
telecommand.hpp:103
satnogs::comms::telecommand::prefixed_string::deserialize
void deserialize(etl::bit_stream_reader &reader)
Definition
telecommand.hpp:159
satnogs::comms::telecommand::prefixed_string::value
etl::string< CONFIG_STORAGE_MAX_PATH_LEN > value
Definition
telecommand.hpp:156
satnogs::comms::telecommand::prefixed_string::prefixed_string
prefixed_string()=default
satnogs::comms::telecommand::prefixed_string::length
size_t length
Definition
telecommand.hpp:155
satnogs::comms::telecommand::storage_direction
storage_direction
Definition
telecommand.hpp:106
satnogs::comms::telecommand::storage_direction::MCU
@ MCU
Definition
telecommand.hpp:107
satnogs::comms::telecommand::storage_direction::FPGA
@ FPGA
Definition
telecommand.hpp:108
satnogs::comms::telecommand::deserialize
static void deserialize(etl::bit_stream_reader &reader, float &x)
Definition
telecommand.cpp:38
satnogs::comms::telecommand::telecommand
telecommand(telecommand const &)=delete
satnogs::comms::telecommand::operator=
void operator=(telecommand const &)=delete
satnogs::comms::telecommand::get_frame_count
int get_frame_count()
Definition
telecommand.cpp:68
satnogs::comms::telecommand::decode_ccsds_xtce
bool decode_ccsds_xtce(msg_arbiter::msg &m, int wdgid)
satnogs::comms::telecommand::get_instance
static telecommand & get_instance()
Definition
telecommand.hpp:37
satnogs::comms::telecommand::ccsds_frame_valid
bool ccsds_frame_valid(const uint8_t *b, size_t len)
Definition
telecommand.cpp:52
satnogs::comms::telecommand::packet_id
packet_id
Definition
telecommand.hpp:44
satnogs::comms::telecommand::packet_id::STOP_WDT_UPDATE
@ STOP_WDT_UPDATE
Definition
telecommand.hpp:55
satnogs::comms::telecommand::packet_id::FPGA_SET_BOOT_MODE
@ FPGA_SET_BOOT_MODE
Definition
telecommand.hpp:92
satnogs::comms::telecommand::packet_id::SET_PLL_CLK_SRC
@ SET_PLL_CLK_SRC
Definition
telecommand.hpp:66
satnogs::comms::telecommand::packet_id::STORAGE_LS
@ STORAGE_LS
Definition
telecommand.hpp:69
satnogs::comms::telecommand::packet_id::STORAGE_DIRECTION
@ STORAGE_DIRECTION
Definition
telecommand.hpp:54
satnogs::comms::telecommand::packet_id::TX_INHIBIT
@ TX_INHIBIT
Definition
telecommand.hpp:57
satnogs::comms::telecommand::packet_id::TX_GAIN
@ TX_GAIN
Definition
telecommand.hpp:58
satnogs::comms::telecommand::packet_id::SET_GAIN0_CONF
@ SET_GAIN0_CONF
Definition
telecommand.hpp:81
satnogs::comms::telecommand::packet_id::SET_TX_FSK_CONF
@ SET_TX_FSK_CONF
Definition
telecommand.hpp:84
satnogs::comms::telecommand::packet_id::SET_RTC
@ SET_RTC
Definition
telecommand.hpp:64
satnogs::comms::telecommand::packet_id::RESET_RADIO_STATS
@ RESET_RADIO_STATS
Definition
telecommand.hpp:62
satnogs::comms::telecommand::packet_id::SET_RX_GAIN_MODE
@ SET_RX_GAIN_MODE
Definition
telecommand.hpp:60
satnogs::comms::telecommand::packet_id::EMMC_TEST
@ EMMC_TEST
Definition
telecommand.hpp:61
satnogs::comms::telecommand::packet_id::SET_GAIN1_CONF
@ SET_GAIN1_CONF
Definition
telecommand.hpp:82
satnogs::comms::telecommand::packet_id::RESET_OTA_SESSION
@ RESET_OTA_SESSION
Definition
telecommand.hpp:95
satnogs::comms::telecommand::packet_id::RESET_SETTINGS
@ RESET_SETTINGS
Definition
telecommand.hpp:67
satnogs::comms::telecommand::packet_id::STORAGE_READ
@ STORAGE_READ
Definition
telecommand.hpp:70
satnogs::comms::telecommand::packet_id::STORAGE_MKDIR
@ STORAGE_MKDIR
Definition
telecommand.hpp:71
satnogs::comms::telecommand::packet_id::OTA_FINISH
@ OTA_FINISH
Definition
telecommand.hpp:48
satnogs::comms::telecommand::packet_id::SET_RADIO_DUTY_CYCLE
@ SET_RADIO_DUTY_CYCLE
Definition
telecommand.hpp:97
satnogs::comms::telecommand::packet_id::SET_TX_WAIT_MS
@ SET_TX_WAIT_MS
Definition
telecommand.hpp:98
satnogs::comms::telecommand::packet_id::STORAGE_RMDIR
@ STORAGE_RMDIR
Definition
telecommand.hpp:72
satnogs::comms::telecommand::packet_id::SET_THERMAL_MONITOR_PARAMS
@ SET_THERMAL_MONITOR_PARAMS
Definition
telecommand.hpp:90
satnogs::comms::telecommand::packet_id::DISK_SECTORS_ERASE
@ DISK_SECTORS_ERASE
Definition
telecommand.hpp:88
satnogs::comms::telecommand::packet_id::STORAGE_WRITE
@ STORAGE_WRITE
Definition
telecommand.hpp:74
satnogs::comms::telecommand::packet_id::RESET_ALL_OTA_SESSIONS
@ RESET_ALL_OTA_SESSIONS
Definition
telecommand.hpp:94
satnogs::comms::telecommand::packet_id::CONFIRM_IMAGE
@ CONFIRM_IMAGE
Definition
telecommand.hpp:96
satnogs::comms::telecommand::packet_id::REBOOT
@ REBOOT
Definition
telecommand.hpp:65
satnogs::comms::telecommand::packet_id::SET_RX_FSK_CONF
@ SET_RX_FSK_CONF
Definition
telecommand.hpp:85
satnogs::comms::telecommand::packet_id::IO_WDT_PERIOD
@ IO_WDT_PERIOD
Definition
telecommand.hpp:59
satnogs::comms::telecommand::packet_id::SET_RADIO_ENABLE
@ SET_RADIO_ENABLE
Definition
telecommand.hpp:89
satnogs::comms::telecommand::packet_id::TELEMETRY_REQ
@ TELEMETRY_REQ
Definition
telecommand.hpp:46
satnogs::comms::telecommand::packet_id::STORAGE_ENABLE
@ STORAGE_ENABLE
Definition
telecommand.hpp:53
satnogs::comms::telecommand::packet_id::OTA_DATA
@ OTA_DATA
Definition
telecommand.hpp:49
satnogs::comms::telecommand::packet_id::TESTS_STOP
@ TESTS_STOP
Definition
telecommand.hpp:51
satnogs::comms::telecommand::packet_id::STORAGE_FSTATS
@ STORAGE_FSTATS
Definition
telecommand.hpp:76
satnogs::comms::telecommand::packet_id::STORAGE_WRITE_OFFSET
@ STORAGE_WRITE_OFFSET
Definition
telecommand.hpp:75
satnogs::comms::telecommand::packet_id::RING_BUFFER_LOGS
@ RING_BUFFER_LOGS
Definition
telecommand.hpp:77
satnogs::comms::telecommand::packet_id::SET_RFFE_PARAMS
@ SET_RFFE_PARAMS
Definition
telecommand.hpp:63
satnogs::comms::telecommand::packet_id::SET_AGC1_CONF
@ SET_AGC1_CONF
Definition
telecommand.hpp:80
satnogs::comms::telecommand::packet_id::SET_FLASH_MONITOR_DELAY_SEC
@ SET_FLASH_MONITOR_DELAY_SEC
Definition
telecommand.hpp:93
satnogs::comms::telecommand::packet_id::SET_MODULATION
@ SET_MODULATION
Definition
telecommand.hpp:83
satnogs::comms::telecommand::packet_id::SAVE_SETTINGS
@ SAVE_SETTINGS
Definition
telecommand.hpp:78
satnogs::comms::telecommand::packet_id::DISK_RAW_WRITE
@ DISK_RAW_WRITE
Definition
telecommand.hpp:86
satnogs::comms::telecommand::packet_id::STORAGE_RM
@ STORAGE_RM
Definition
telecommand.hpp:73
satnogs::comms::telecommand::packet_id::FREQ_SET
@ FREQ_SET
Definition
telecommand.hpp:56
satnogs::comms::telecommand::packet_id::SET_FILTER
@ SET_FILTER
Definition
telecommand.hpp:68
satnogs::comms::telecommand::packet_id::FPGA_ENABLE
@ FPGA_ENABLE
Definition
telecommand.hpp:52
satnogs::comms::telecommand::packet_id::PING
@ PING
Definition
telecommand.hpp:45
satnogs::comms::telecommand::packet_id::DISK_RAW_READ
@ DISK_RAW_READ
Definition
telecommand.hpp:87
satnogs::comms::telecommand::packet_id::TEST_TX_SIMPLE
@ TEST_TX_SIMPLE
Definition
telecommand.hpp:50
satnogs::comms::telecommand::packet_id::SET_TX_GS_TURNAROUND_TIME
@ SET_TX_GS_TURNAROUND_TIME
Definition
telecommand.hpp:91
satnogs::comms::telecommand::packet_id::SET_AGC0_CONF
@ SET_AGC0_CONF
Definition
telecommand.hpp:79
satnogs::comms::telecommand::packet_id::OTA_REQUEST
@ OTA_REQUEST
Definition
telecommand.hpp:47
msg_arbiter.hpp
satnogs::comms
Definition
bsp.cpp:28
ota.hpp
src
telecommand.hpp
Generated by
1.17.0