Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
1 change: 1 addition & 0 deletions .fpp-lsp
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
buildCache: build-fprime-automatic-teensy41
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ build-fprime-*
/.idea/
/.vscode/
.DS_Store
*.gcov
*.gcov
8 changes: 4 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
####
# This sets up the build system for the 'arduino-led-blinker' project, including
# This sets up the build system for the 'LedBlinker' project, including
# components and deployments from project.cmake. In addition, it imports the core F Prime components.
####

cmake_minimum_required(VERSION 3.13)
project(fprime-arduino-led-blinker C CXX)
cmake_minimum_required(VERSION 3.24.2)
project(LedBlinker C CXX)

###
# F' Core Setup
Expand All @@ -16,4 +16,4 @@ fprime_setup_included_code()


# This includes project-wide objects
include("${CMAKE_CURRENT_LIST_DIR}/project.cmake")
add_fprime_subdirectory("${CMAKE_CURRENT_LIST_DIR}/LedBlinker")
39 changes: 39 additions & 0 deletions CMakePresets.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
{
"version": 4,
"configurePresets": [
{
"name": "fprime",
"displayName": "F´ Release Preset",
"description": "F´ release build using local fprime-venv",
"binaryDir": "${sourceDir}/build-fprime-automatic-native",
"generator": "Ninja",
"environment": {
"VIRTUAL_ENV": "${fileDir}/fprime-venv",
"PATH": "$env{VIRTUAL_ENV}/bin:$penv{PATH}"
},
"cacheVariables": {
"CMAKE_EXPORT_COMPILE_COMMANDS": "ON",
"CMAKE_BUILD_TYPE": "Release"
}
},
{
"name": "fprime-debug",
"inherits": "fprime",
"displayName": "F´ Debug Preset",
"description": "F´ debug build using local fprime-venv",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Debug"
}
},
{
"name": "fprime-ut",
"inherits": "fprime-debug",
"displayName": "F´ Unit Test Preset",
"description": "F´ debug build including unit tests using local fprime-venv",
"binaryDir": "${sourceDir}/build-fprime-automatic-native-ut",
"cacheVariables": {
"BUILD_TESTING": "ON"
}
}
]
}
31 changes: 4 additions & 27 deletions LedBlinker/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,28 +1,5 @@
#####
# 'LedBlinker' Deployment:
#
# This registers the 'LedBlinker' deployment to the build system.
# Custom components that have not been added at the project-level should be added to
# the list below.
#
#####
# This CMake file is intended to register project-wide objects.
# This allows for reuse between deployments, or other projects.

# Deployment is only compatible with the Arduino platform
restrict_platforms(ArduinoFw)

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

# Add custom components to this specific deployment here
# add_fprime_subdirectory("${CMAKE_CURRENT_LIST_DIR}/MyComponent/")


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

register_fprime_deployment()

finalize_arduino_executable("${FPRIME_CURRENT_MODULE}")
add_fprime_subdirectory("${CMAKE_CURRENT_LIST_DIR}/Components")
add_fprime_subdirectory("${CMAKE_CURRENT_LIST_DIR}/LedBlinkerDeployment/")
File renamed without changes.
File renamed without changes.
8 changes: 4 additions & 4 deletions Components/Led/Led.cpp → LedBlinker/Components/Led/Led.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
// \brief cpp file for Led component implementation class
// ======================================================================

#include "Components/Led/Led.hpp"
#include "LedBlinker/Components/Led/Led.hpp"

namespace Components {
namespace LedBlinker {

// ----------------------------------------------------------------------
// Component construction and destruction
Expand Down Expand Up @@ -84,7 +84,7 @@ void Led ::run_handler(FwIndexType portNum, U32 context) {
// Handler implementations for commands
// ----------------------------------------------------------------------

void Led ::BLINKING_ON_OFF_cmdHandler(FwOpcodeType opCode, U32 cmdSeq, Fw::On onOff) {
void Led ::BLINKING_ON_OFF_cmdHandler(FwOpcodeType opCode, U32 cmdSeq, const Fw::On& onOff) {
this->m_toggleCounter = 0; // Reset count on any successful command
this->m_blinking = Fw::On::ON == onOff; // Update blinking state

Expand All @@ -96,4 +96,4 @@ void Led ::BLINKING_ON_OFF_cmdHandler(FwOpcodeType opCode, U32 cmdSeq, Fw::On on
this->cmdResponse_out(opCode, cmdSeq, Fw::CmdResponse::OK);
}

} // namespace Components
} // namespace LedBlinker
4 changes: 2 additions & 2 deletions Components/Led/Led.fpp → LedBlinker/Components/Led/Led.fpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module Components {
module LedBlinker {
@ Component to blink an LED driven by a rate group
active component Led {

Expand Down Expand Up @@ -68,4 +68,4 @@ module Components {
param set port prmSetOut

}
}
}
14 changes: 7 additions & 7 deletions Components/Led/Led.hpp → LedBlinker/Components/Led/Led.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@
// \brief hpp file for Led component implementation class
// ======================================================================

#ifndef Components_Led_HPP
#define Components_Led_HPP
#ifndef LedBlinker_Led_HPP
#define LedBlinker_Led_HPP

#include "Components/Led/LedComponentAc.hpp"
#include "LedBlinker/Components/Led/LedComponentAc.hpp"

namespace Components {
namespace LedBlinker {

class Led final : public LedComponentBase {
public:
Expand Down Expand Up @@ -51,15 +51,15 @@ class Led final : public LedComponentBase {
//! Command to turn on or off the blinking LED
void BLINKING_ON_OFF_cmdHandler(FwOpcodeType opCode, //!< The opcode
U32 cmdSeq, //!< The command sequence number
Fw::On onOff //!< Indicates whether the blinking should be on or off
const Fw::On& onOff //!< Indicates whether the blinking should be on or off
) override;

Fw::On m_state = Fw::On::OFF; //! Keeps track if LED is on or off
U64 m_transitions = 0; //! The number of on/off transitions that have occurred from FSW boot up
U32 m_toggleCounter = 0; //! Keeps track of how many ticks the LED has been on for
bool m_blinking = true; //! Flag: if true then LED blinking will occur else no blinking will happen
bool m_blinking = true; //! Flag: if true then LED blinking will occur else no blinking will happen
};

} // namespace Components
} // namespace LedBlinker

#endif
29 changes: 29 additions & 0 deletions LedBlinker/LedBlinkerDeployment/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#####
# 'LedBlinkerDeployment' Deployment:
#
# This registers the 'LedBlinkerDeployment' deployment to the build system.
# Custom components that have not been added at the project-level should be added to
# the list below.
#
#####

# Deployment is only compatible with the Arduino platform
restrict_platforms(ArduinoFw)

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

# Add custom components to this specific deployment here
# add_fprime_subdirectory("${CMAKE_CURRENT_LIST_DIR}/MyComponent/")

register_fprime_deployment(
SOURCES
"${CMAKE_CURRENT_LIST_DIR}/Main.cpp"
DEPENDS
${FPRIME_CURRENT_MODULE}_Top
)

finalize_arduino_executable("${FPRIME_CURRENT_MODULE}")
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,16 @@
//
// ======================================================================
// Used to access topology functions
#include <LedBlinker/Top/LedBlinkerTopologyAc.hpp>
#include <LedBlinker/Top/LedBlinkerTopology.hpp>
#include <LedBlinker/LedBlinkerDeployment/Top/LedBlinkerDeploymentTopologyAc.hpp>
#include <LedBlinker/LedBlinkerDeployment/Top/LedBlinkerDeploymentTopology.hpp>

// Used for Baremetal TaskRunner
#include <fprime-baremetal/Os/TaskRunner/TaskRunner.hpp>

// Used for logging
#include <Arduino/Os/Console.hpp>


/**
* \brief setup the program
*
Expand Down
54 changes: 54 additions & 0 deletions LedBlinker/LedBlinkerDeployment/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
# LedBlinkerDeployment Application

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

## Building and Running the LedBlinkerDeployment Application

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

```sh
cd LedBlinker/LedBlinkerDeployment
fprime-util generate
```

The next step is to build the LedBlinkerDeployment application's code. Build from the deployment's folder: building from the project root also builds every F´ framework module, and some of them don't build for Arduino boards.
```sh
fprime-util build
```

## Running the application and F' GDS

The following command will spin up the F' GDS. Examples are available for UART, TcpServer, and TcpClient:

### UART

```sh
fprime-gds -n --dictionary ./build-artifacts/<build name>/LedBlinker_LedBlinkerDeployment/dict/LedBlinkerDeploymentTopologyDictionary.json --communication-selection uart --uart-device /dev/ttyACM0 --uart-baud 115200
```

> [!NOTE]
> Change `<build name>` to the build of your deployment (i.e. `teensy41`, `featherM0`, etc.).
>
> `/dev/ttyACM0` may vary for your system/device. It may also be `/dev/ttyUSB0`. For MacOS, it will be along the lines of `/dev/tty.usbmodem12345`. Change accordingly.
>
> To view the list of your connected devices, run: `ls /dev/tty*`.

### TcpServer

```sh
fprime-gds -n --dictionary ./build-artifacts/<build name>/LedBlinker_LedBlinkerDeployment/dict/LedBlinkerDeploymentTopologyDictionary.json --ip-client --ip-address <device-ip-address>
```

> [!NOTE]
> Change `<build name>` to the build of your deployment (i.e. `teensy41`, `featherM0`, etc.).
>
> Change `<device-ip-address>` to the IP address of your board. Your machine must be in the same network as the board.

### TcpClient

```sh
fprime-gds -n --dictionary ./build-artifacts/<build name>/LedBlinker_LedBlinkerDeployment/dict/LedBlinkerDeploymentTopologyDictionary.json
```

> [!NOTE]
> Change `<build name>` to the build of your deployment (i.e. `teensy41`, `featherM0`, etc.).
22 changes: 22 additions & 0 deletions LedBlinker/LedBlinkerDeployment/Top/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
####
# F Prime CMakeLists.txt:
#
# SOURCES: list of source files (to be compiled)
# AUTOCODER_INPUTS: list of files to be passed to the autocoders
# DEPENDS: list of libraries that this module depends on
#
# More information in the F´ CMake API documentation:
# https://fprime.jpl.nasa.gov/latest/docs/reference/api/cmake/API/
#
####

register_fprime_module(
AUTOCODER_INPUTS
"${CMAKE_CURRENT_LIST_DIR}/instances.fpp"
"${CMAKE_CURRENT_LIST_DIR}/topology.fpp"
SOURCES
"${CMAKE_CURRENT_LIST_DIR}/LedBlinkerDeploymentTopology.cpp"
DEPENDS
Arduino_Drv_StreamDriver
fprime-baremetal_Os_TaskRunner
)
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
// ======================================================================
// \title LedBlinkerTopology.cpp
// \title LedBlinkerDeploymentTopology.cpp
// \brief cpp file containing the topology instantiation code
//
// ======================================================================
// Provides access to autocoded functions
#include <LedBlinker/Top/LedBlinkerTopologyAc.hpp>
// Note: Uncomment when using Svc:TlmPacketizer
// #include <LedBlinker/Top/LedBlinkerPacketsAc.hpp>
#include <LedBlinker/LedBlinkerDeployment/Top/LedBlinkerDeploymentTopologyAc.hpp>
#include <config/FppConstantsAc.hpp>
#include <Fw/Logger/Logger.hpp>

// Necessary project-specified types
#include <Arduino/config/FprimeArduino.hpp>
Expand All @@ -20,7 +19,7 @@ Svc::RateGroupDriver::DividerSet rateGroupDivisors{{{100, 0}, {200, 0}, {1000, 0

// Rate groups may supply a context token to each of the attached children whose purpose is set by the project. The
// reference topology sets each token to zero as these contexts are unused in this project.
U32 rateGroup1Context[FppConstant_PassiveRateGroupOutputPorts::PassiveRateGroupOutputPorts] = {};
Svc::PassiveRateGroup::ContextArray rateGroup1Context(0);

/**
* \brief configure/setup components in project-specific way
Expand All @@ -34,12 +33,12 @@ void configureTopology() {
rateGroupDriver.configure(rateGroupDivisors);

// Rate groups require context arrays.
rateGroup1.configure(rateGroup1Context, FW_NUM_ARRAY_ELEMENTS(rateGroup1Context));
rateGroup1.configure(rateGroup1Context);

gpioDriver.open(Arduino::DEF_LED_BUILTIN, Arduino::GpioDriver::GpioDirection::OUT);
}

// Public functions for use in main program are namespaced with deployment name LedBlinker
// Public functions for use in main program are namespaced with deployment namespace LedBlinker
namespace LedBlinker {
void setupTopology(const TopologyState& state) {
// Autocoded initialization. Function provided by autocoder.
Expand All @@ -59,9 +58,10 @@ void setupTopology(const TopologyState& state) {
// loadParameters();
// Autocoded task kick-off (active components). Function provided by autocoder.
startTasks(state);

comDriver.configure(&Serial);

rateDriver.configure(1);
comDriver.configure(&Serial);
rateDriver.start();
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
// ======================================================================
// \title LedBlinkerTopology.hpp
// \title LedBlinkerDeploymentTopology.hpp
// \brief header file containing the topology instantiation definitions
//
// ======================================================================
#ifndef LEDBLINKER_LEDBLINKERTOPOLOGY_HPP
#define LEDBLINKER_LEDBLINKERTOPOLOGY_HPP
#ifndef LEDBLINKERDEPLOYMENT_LEDBLINKERDEPLOYMENTTOPOLOGY_HPP
#define LEDBLINKERDEPLOYMENT_LEDBLINKERDEPLOYMENTTOPOLOGY_HPP
// Included for access to LedBlinker::TopologyState and LedBlinker::ConfigObjects::pingEntries. These definitions are required by the
// autocoder, but are also used in this hand-coded topology.
#include <LedBlinker/Top/LedBlinkerTopologyDefs.hpp>
#include <LedBlinker/LedBlinkerDeployment/Top/LedBlinkerDeploymentTopologyDefs.hpp>

// Remove unnecessary LedBlinker:: qualifications
using namespace LedBlinker;
Expand All @@ -32,7 +32,7 @@ namespace LedBlinker {
* custom tasks often start radio communication it is convenient to start them last.
*
* The state argument carries command line inputs used to setup the topology. For an explanation of the required type
* LedBlinker::TopologyState see: LedBlinkerTopologyDefs.hpp.
* LedBlinker::TopologyState see: LedBlinkerDeploymentTopologyDefs.hpp.
*
* \param state: object shuttling CLI arguments (hostname, port) needed to construct the topology
*/
Expand All @@ -53,7 +53,7 @@ void setupTopology(const TopologyState& state);
* Step 1, 2, 3, and 4 must occur in-order as the tasks must be stopped before being joined. These tasks must be stopped
* and joined before any active resources may be deallocated.
*
* For an explanation of the required type LedBlinker::TopologyState see: LedBlinkerTopologyDefs.hpp.
* For an explanation of the required type LedBlinker::TopologyState see: LedBlinkerDeploymentTopologyDefs.hpp.
*
* \param state: state object provided to setupTopology
*/
Expand Down
Loading