Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New Deployment generation feature #123

Merged
merged 21 commits into from
Apr 4, 2023
Merged
Show file tree
Hide file tree
Changes from 14 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"deployment_name": "MyDeployment",
"path_to_fprime": "./fprime",
"author_name": ""
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#####
# '{{cookiecutter.deployment_name}}' Deployment:
#
# This sets up the build for the '{{cookiecutter.deployment_name}}' Application, including custom
# components. In addition, it imports FPrime.cmake, which includes the core F Prime components.
#
#####

###
# Basic Project Setup
###
cmake_minimum_required(VERSION 3.13)
cmake_policy(SET CMP0048 NEW)
project({{cookiecutter.deployment_name}} VERSION 1.0.0 LANGUAGES C CXX)

###
# F' Core Setup
# This includes all of the F prime core components, and imports the make-system.
###
include("${FPRIME_FRAMEWORK_PATH}/cmake/FPrime.cmake")
# NOTE: register custom targets between these two lines
include("${FPRIME_FRAMEWORK_PATH}/cmake/FPrime-Code.cmake")

###
# Components and Topology
###
add_fprime_subdirectory("${CMAKE_CURRENT_LIST_DIR}/Top/")

set(SOURCE_FILES "${CMAKE_CURRENT_LIST_DIR}/Main.cpp")
set(MOD_DEPS ${PROJECT_NAME}/Top)

register_fprime_deployment()
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
// ======================================================================
// \title Main.cpp
// \author {{cookiecutter.author_name}}
// \brief main program for the F' application. Intended for CLI-based systems (Linux, macOS)
//
// ======================================================================
// Used to access topology functions
#include <{{cookiecutter.deployment_name}}/Top/{{cookiecutter.deployment_name}}Topology.hpp>
// Used for signal handling shutdown
#include <signal.h>
// Used for command line argument processing
#include <getopt.h>
// Used for printf functions
#include <cstdlib>

/**
* \brief print commandline help message
*
* This will print a command line help message including the available command line arguments.
*
* @param app: name of application
*/
void print_usage(const char* app) {
(void)printf("Usage: ./%s [options]\n-a\thostname/IP address\n-p\tport_number\n", app);
}

/**
* \brief shutdown topology cycling on signal
*
* The reference topology allows for a simulated cycling of the rate groups. This simulated cycling needs to be stopped
* in order for the program to shutdown. This is done via handling signals such that it is performed via Ctrl-C
*
* @param signum
*/
static void signalHandler(int signum) {
{{cookiecutter.deployment_name}}::stopSimulatedCycle();
}

/**
* \brief execute the program
*
* This F´ program is designed to run in standard environments (e.g. Linux/macOs running on a laptop). Thus it uses
* command line inputs to specify how to connect.
*
* @param argc: argument count supplied to program
* @param argv: argument values supplied to program
* @return: 0 on success, something else on failure
*/
int main(int argc, char* argv[]) {
U32 port_number = 0;
I32 option = 0;
char* hostname = nullptr;

// Loop while reading the getopt supplied options
while ((option = getopt(argc, argv, "hp:a:")) != -1) {
switch (option) {
// Handle the -a argument for address/hostname
case 'a':
hostname = optarg;
break;
// Handle the -p port number argument
case 'p':
port_number = static_cast<U32>(atoi(optarg));
break;
// Cascade intended: help output
case 'h':
// Cascade intended: help output
case '?':
// Default case: output help and exit
default:
print_usage(argv[0]);
return (option == 'h') ? 0 : 1;
}
}
// Object for communicating state to the reference topology
{{cookiecutter.deployment_name}}::TopologyState inputs;
inputs.hostname = hostname;
inputs.port = port_number;

// Setup program shutdown via Ctrl-C
signal(SIGINT, signalHandler);
signal(SIGTERM, signalHandler);
(void)printf("Hit Ctrl-C to quit\n");

// Setup, cycle, and teardown topology
{{cookiecutter.deployment_name}}::setupTopology(inputs);
{{cookiecutter.deployment_name}}::startSimulatedCycle(1000); // Program loop cycling rate groups at 1Hz
{{cookiecutter.deployment_name}}::teardownTopology(inputs);
(void)printf("Exiting...\n");
return 0;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# {{cookiecutter.deployment_name}} Application

This deployment was auto-generated by the F' utility tool.

## Building and Running the {{cookiecutter.deployment_name}} Application

In order to build the {{cookiecutter.deployment_name}} application, or any other F´ application, we first need to generate a build directory. This can be done with the following commands:

```
cd {{cookiecutter.deployment_name}}
fprime-util generate
```

The next step is to build the {{cookiecutter.deployment_name}} application's code.
```
fprime-util build
```

## Running the application and F' GDS

The following command will spin up the F' GDS as well as run the application binary and the components necessary for the GDS and application to communicate.

```
cd {{cookiecutter.deployment_name}}
fprime-gds
```

To run the ground system without starting the {{cookiecutter.deployment_name}} app:
```
cd {{cookiecutter.deployment_name}}
fprime-gds --no-app
```

The application binary may then be run independently from the created 'bin' directory.

```
cd {{cookiecutter.deployment_name}}/build-artifacts/<platform>/bin/
./{{cookiecutter.deployment_name}} -a 127.0.0.1 -p 50000
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
####
# F prime CMakeLists.txt:
#
# SOURCE_FILES: combined list of source and autocoding files
# MOD_DEPS: (optional) module dependencies
####

set(SOURCE_FILES
"${CMAKE_CURRENT_LIST_DIR}/instances.fpp"
"${CMAKE_CURRENT_LIST_DIR}/{{cookiecutter.deployment_name}}Packets.xml"
"${CMAKE_CURRENT_LIST_DIR}/topology.fpp"
"${CMAKE_CURRENT_LIST_DIR}/{{cookiecutter.deployment_name}}Topology.cpp"
)
set(MOD_DEPS
Fw/Logger
Svc/LinuxTime
# Communication Implementations
Drv/Udp
Drv/TcpClient
)

register_fprime_module()
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
module {{cookiecutter.deployment_name}} {

# ----------------------------------------------------------------------
# Defaults
# ----------------------------------------------------------------------

module Default {
constant QUEUE_SIZE = 10
constant STACK_SIZE = 64 * 1024
}

# ----------------------------------------------------------------------
# Active component instances
# ----------------------------------------------------------------------

instance blockDrv: Drv.BlockDriver base id 0x0100 \
queue size Default.QUEUE_SIZE \
stack size Default.STACK_SIZE \
priority 140

instance rateGroup1: Svc.ActiveRateGroup base id 0x0200 \
queue size Default.QUEUE_SIZE \
stack size Default.STACK_SIZE \
priority 120

instance rateGroup2: Svc.ActiveRateGroup base id 0x0300 \
queue size Default.QUEUE_SIZE \
stack size Default.STACK_SIZE \
priority 119

instance rateGroup3: Svc.ActiveRateGroup base id 0x0400 \
queue size Default.QUEUE_SIZE \
stack size Default.STACK_SIZE \
priority 118

instance cmdDisp: Svc.CommandDispatcher base id 0x0500 \
queue size 20 \
stack size Default.STACK_SIZE \
priority 101

instance cmdSeq: Svc.CmdSequencer base id 0x0600 \
queue size Default.QUEUE_SIZE \
stack size Default.STACK_SIZE \
priority 100

instance fileDownlink: Svc.FileDownlink base id 0x0700 \
queue size 30 \
stack size Default.STACK_SIZE \
priority 100

instance fileManager: Svc.FileManager base id 0x0800 \
queue size 30 \
stack size Default.STACK_SIZE \
priority 100

instance fileUplink: Svc.FileUplink base id 0x0900 \
queue size 30 \
stack size Default.STACK_SIZE \
priority 100

instance eventLogger: Svc.ActiveLogger base id 0x0B00 \
queue size Default.QUEUE_SIZE \
stack size Default.STACK_SIZE \
priority 98

# comment in Svc.TlmChan or Svc.TlmPacketizer
# depending on which form of telemetry downlink
# you wish to use

instance tlmSend: Svc.TlmChan base id 0x0C00 \
queue size Default.QUEUE_SIZE \
stack size Default.STACK_SIZE \
priority 97

#instance tlmSend: Svc.TlmPacketizer base id 0x0C00 \
# queue size Default.QUEUE_SIZE \
# stack size Default.STACK_SIZE \
# priority 97

instance prmDb: Svc.PrmDb base id 0x0D00 \
queue size Default.QUEUE_SIZE \
stack size Default.STACK_SIZE \
priority 96

# ----------------------------------------------------------------------
# Queued component instances
# ----------------------------------------------------------------------

instance $health: Svc.Health base id 0x2000 \
queue size 25

# ----------------------------------------------------------------------
# Passive component instances
# ----------------------------------------------------------------------

@ Communications driver. May be swapped with other comm drivers like UART
@ Note: Here we have TCP reliable uplink and UDP (low latency) downlink
instance comm: Drv.ByteStreamDriverModel base id 0x4000 \
type "Drv::TcpClient" \ # type specified to select implementor of ByteStreamDriverModel
at "../../Drv/TcpClient/TcpClient.hpp" # location of above implementor must also be specified

instance downlink: Svc.Framer base id 0x4100

instance fatalAdapter: Svc.AssertFatalAdapter base id 0x4200

instance fatalHandler: Svc.FatalHandler base id 0x4300

instance fileUplinkBufferManager: Svc.BufferManager base id 0x4400

instance linuxTime: Svc.Time base id 0x4500 \
type "Svc::LinuxTime" \
at "../../Svc/LinuxTime/LinuxTime.hpp"

instance rateGroupDriver: Svc.RateGroupDriver base id 0x4600

instance staticMemory: Svc.StaticMemory base id 0x4700

instance textLogger: Svc.PassiveTextLogger base id 0x4800

instance uplink: Svc.Deframer base id 0x4900

instance systemResources: Svc.SystemResources base id 0x4A00

}
Loading