SatNOGS-COMMS  4.1.0
A COMMS subsystem for CubeSats
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
31namespace satnogs::comms
32{
34{
35public:
36 static telecommand &
38 {
39 static telecommand instance;
40 return instance;
41 }
42
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,
109 };
110
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;
123
125 : version(0),
126 type(0),
127 sec_hdr(0),
128 apid(0),
129 group_flags(0),
130 count(0),
131 length(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
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
180
181 bool
183
184 bool
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
194private:
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
void deserialize(etl::bit_stream_reader &reader)
void deserialize(etl::bit_stream_reader &reader)
etl::string< CONFIG_STORAGE_MAX_PATH_LEN > value
static void deserialize(etl::bit_stream_reader &reader, float &x)
telecommand(telecommand const &)=delete
void operator=(telecommand const &)=delete
bool decode_ccsds_xtce(msg_arbiter::msg &m, int wdgid)
static telecommand & get_instance()
bool ccsds_frame_valid(const uint8_t *b, size_t len)