WarpTwin
Documentation for WarpTwin models and classes.
Loading...
Searching...
No Matches
CommandManager.h
Go to the documentation of this file.
1/******************************************************************************
2* Copyright (c) ATTX INC 2025. All Rights Reserved.
3*
4* This software and associated documentation (the "Software") are the
5* proprietary and confidential information of ATTX, INC. The Software is
6* furnished under a license agreement between ATTX and the user organization
7* and may be used or copied only in accordance with the terms of the agreement.
8* Refer to 'license/attx_license.adoc' for standard license terms.
9*
10* EXPORT CONTROL NOTICE: THIS SOFTWARE MAY INCLUDE CONTENT CONTROLLED UNDER THE
11* INTERNATIONAL TRAFFIC IN ARMS REGULATIONS (ITAR) OR THE EXPORT ADMINISTRATION
12* REGULATIONS (EAR99). No part of the Software may be used, reproduced, or
13* transmitted in any form or by any means, for any purpose, without the express
14* written permission of ATTX, INC.
15******************************************************************************/
16/*
17Command Manager header file
18
19Author: Alex Reynolds
20*/
21#ifndef FLIGHT_COMMANDMANAGER_H
22#define FLIGHT_COMMANDMANAGER_H
23
25#include "flight/App.h"
26#include "flight/Setup.h"
27#include "types.h"
30namespace warpos {
31
33#define MAX_CMD_TABLE_SIZE 100
34
36#define CMD_INPUT_BUFFER_SIZE 256
37
40 App* assoc_app; // App associated with the command
41 uint16 apid; // Apid for the registered command
42 uint8 instance; // Instance for the apid
43};
44
52class CommandManager : public App {
53public:
59
65 virtual ~CommandManager();
66
71 int16 registerCmdPacket(App* cmd_app, uint16 cmd_apid);
72
78 int16 command(uint16 apid, uint8* buffer, uint16 size) override;
79
83
84protected:
85 int16 start() override;
86 int16 execute() override;
87
88
91 int16 handleCommands();
92
96 bool ingestCommand();
97
100 bool scanForHeader();
101
104 int16 routeCommand(App *cmd_app_ptr, uint16 apid, uint8 instance, uint8 *buffer, uint16 length);
105
110 int16 softResetCmd(uint8 *buffer, uint16 size);
115 int16 logLevelCmd(uint8 *buffer, uint16 size);
120 int16 scheduleCmd(uint8 *buffer, uint16 size);
125 int16 activateCmd(uint8 *buffer, uint16 size);
130 int16 deactivateCmd(uint8 *buffer, uint16 size);
131
133
135
136 uint16 _cmd_table_idx = 0;
137
139
140 uint8 _ccsds_data[CCSDS_FULL_HDR_LEN_BYTES];
141
143 uint16 _exc_error_count = 0;
145 uint16 _crc_error_count = 0;
146 uint16 _timeout_count = 0;
148
152};
153}
154
155#endif
#define MAX_CMD_TABLE_SIZE
The maximum amount of commands which can be registered.
Definition CommandManager.h:33
#define SIGNAL(NAME, TYPE, INITIAL_VALUE)
Definition appmacros.h:27
#define START_PARAMS
Definition appmacros.h:42
#define END_PARAMS
Definition appmacros.h:47
Simple Circular Buffer for data storage.
Definition CircularBuffer.hpp:37
Wrapper to manage and convert time as timespce.
Definition Time.h:53
Base app class for derived implementation.
Definition App.h:55
App(FlightExecutive &executive, const char *name, uint16 apid, uint8 instance=0)
Executive-based constructor for the task.
Definition App.cpp:21
uint8 & instance()
Get the instance of this app (used to differentiate between multiple instances of the same app).
Definition App.h:109
uint16 apid()
Get the apid for this app.
Definition App.h:105
FlightExecutive & exc
Override our executive to include the FlightExecutive instead.
Definition App.h:120
int16 deactivateCmd(uint8 *buffer, uint16 size)
Function to handle a deactivate command.
Definition CommandManager.cpp:370
bool ingestCommand()
Function to ingest commands from the HAL.
Definition CommandManager.cpp:46
RegisteredCommandInfo _reg_cmd_table[100]
Table of registered commands.
Definition CommandManager.h:132
uint16 numRegisteredPackets()
Get the number of registered command packets.
Definition CommandManager.h:82
int16 scheduleCmd(uint8 *buffer, uint16 size)
Function to handle Schedule change commands.
Definition CommandManager.cpp:327
tlm_cmd_mngr_status _tlm_cmd_mngr_status
Command manager status telemetry packet.
Definition CommandManager.h:151
uint8 _ccsds_data[CCSDS_FULL_HDR_LEN_BYTES]
Buffer to hold CCSDS header data when processing commands.
Definition CommandManager.h:140
CommandManager(FlightExecutive &exc)
Only available flight executive constructor.
Definition CommandManager.cpp:24
int16 start() override
Definition CommandManager.cpp:29
int16 handleCommands()
Function to handle ingesting and routing commands.
Definition CommandManager.cpp:127
uint16 _cmd_table_idx
Current index in the command table.
Definition CommandManager.h:136
uint16 _successful_cmd_count
Count of successfully processed commands.
Definition CommandManager.h:147
int16 softResetCmd(uint8 *buffer, uint16 size)
Function to handle a received softResetCommand.
Definition CommandManager.cpp:282
clockwerk::Time _last_read_time
Last time bytes were read from input hw queue.
Definition CommandManager.h:134
uint16 _crc_error_count
Count of commands received with CRC errors.
Definition CommandManager.h:145
bool scanForHeader()
Scans through the bytes in the command buffer for a valid CCSDS header.
Definition CommandManager.cpp:97
int16 activateCmd(uint8 *buffer, uint16 size)
Function to handle activate commands.
Definition CommandManager.cpp:349
int16 command(uint16 apid, uint8 *buffer, uint16 size) override
Process commands issued to the app.
Definition CommandManager.cpp:260
tlm_cmd_mngr_error _tlm_cmd_mngr_error
Telemetry Definitions.
Definition CommandManager.h:150
uint16 _pkt_not_registered_count
Count of commands received for unregistered packets.
Definition CommandManager.h:144
clockwerk::CircularBuffer< uint8, 256 > _cmd_input_byte_buff
Buffer of bytes input from hardware device.
Definition CommandManager.h:138
int16 logLevelCmd(uint8 *buffer, uint16 size)
Function to handle LogLevel change commands.
Definition CommandManager.cpp:303
int16 registerCmdPacket(App *cmd_app, uint16 cmd_apid)
Register a command with the command manager.
Definition CommandManager.cpp:237
int16 routeCommand(App *cmd_app_ptr, uint16 apid, uint8 instance, uint8 *buffer, uint16 length)
Routes a command to an associated app.
Definition CommandManager.cpp:66
uint16 _exc_error_count
Counters for various command manager stats, used in telemetry.
Definition CommandManager.h:143
int16 execute() override
Definition CommandManager.cpp:83
uint16 _timeout_count
Count of times the command queue has been cleared due to timeout.
Definition CommandManager.h:146
Executive derivation specifically to run flight systems.
Definition FlightExecutive.h:46
Definition DeadReckon.cpp:20
Command Manager error packet definition.
Definition tlm_CommandManager.h:54
Command Manager status packet definition.
Definition tlm_CommandManager.h:44
clockwerk::DataIO< clockwerk::Time > queue_clear_timeout
Definition CommandManager.h:57
Struct to store info on registered commands.
Definition CommandManager.h:39
uint8 instance
Definition CommandManager.h:42
App * assoc_app
Definition CommandManager.h:40
uint16 apid
Definition CommandManager.h:41