Skip to content

Commit 1dc5b09

Browse files
committed
Add pre-commit linting
1 parent e029b3e commit 1dc5b09

File tree

15 files changed

+159
-172
lines changed

15 files changed

+159
-172
lines changed

.pre-commit-config.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
repos:
2+
- repo: https://github.com/pre-commit/mirrors-clang-format
3+
rev: v20.1.8
4+
hooks:
5+
- id: clang-format

CMakePresets.json

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,22 @@
11
{
22
"version": 4,
33
"configurePresets": [
4-
{
5-
"name": "fprime-zephyr-teensy41",
6-
"displayName": "F´ Zephyr (teensy41)",
7-
"description": "F´ release build using local fprime-venv",
8-
"binaryDir": "${sourceDir}/build-fprime-automatic-zephyr",
9-
"environment": {
10-
"VIRTUAL_ENV": "${fileDir}/fprime-venv",
11-
"PATH": "$env{VIRTUAL_ENV}/bin:$penv{PATH}"
12-
},
13-
"cacheVariables": {
14-
"CMAKE_EXPORT_COMPILE_COMMANDS": "ON",
15-
"CMAKE_BUILD_TYPE": "Release",
16-
"BOARD": "teensy41"
17-
},
18-
"toolchainFile": "${fileDir}/lib/fprime-zephyr/cmake/toolchain/zephyr.cmake",
19-
"generator": "Ninja"
20-
}]
4+
{
5+
"name": "fprime-zephyr-teensy41",
6+
"displayName": "F´ Zephyr (teensy41)",
7+
"description": "F´ release build using local fprime-venv",
8+
"binaryDir": "${sourceDir}/build-fprime-automatic-zephyr",
9+
"environment": {
10+
"VIRTUAL_ENV": "${fileDir}/fprime-venv",
11+
"PATH": "$env{VIRTUAL_ENV}/bin:$penv{PATH}"
12+
},
13+
"cacheVariables": {
14+
"CMAKE_EXPORT_COMPILE_COMMANDS": "ON",
15+
"CMAKE_BUILD_TYPE": "Release",
16+
"BOARD": "teensy41"
17+
},
18+
"toolchainFile": "${fileDir}/lib/fprime-zephyr/cmake/toolchain/zephyr.cmake",
19+
"generator": "Ninja"
20+
}
21+
]
2122
}

FprimeZephyrReference/Components/FatalHandler/FatalHandler.cpp

Lines changed: 23 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -10,52 +10,39 @@
1010
//
1111
// ======================================================================
1212

13-
#include <Fw/Logger/Logger.hpp>
13+
#include <zephyr/sys/reboot.h>
1414
#include <FprimeZephyrReference/Components/FatalHandler/FatalHandler.hpp>
1515
#include <Fw/FPrimeBasicTypes.hpp>
16-
#include <zephyr/sys/reboot.h>
16+
#include <Fw/Logger/Logger.hpp>
1717

1818
namespace Components {
1919

20-
// ----------------------------------------------------------------------
21-
// Construction, initialization, and destruction
22-
// ----------------------------------------------------------------------
20+
// ----------------------------------------------------------------------
21+
// Construction, initialization, and destruction
22+
// ----------------------------------------------------------------------
2323

24-
FatalHandler ::
25-
FatalHandler(
26-
const char *const compName
27-
) : FatalHandlerComponentBase(compName)
28-
{
24+
FatalHandler ::FatalHandler(const char* const compName) : FatalHandlerComponentBase(compName) {}
2925

30-
}
26+
FatalHandler ::~FatalHandler() {}
3127

32-
FatalHandler ::
33-
~FatalHandler()
34-
{
35-
36-
}
37-
38-
void FatalHandler::reboot() {
39-
// When running in CI failsafe mode and the board is a teensy,
40-
// then we should invoke bkpt #251 to trigger the soft reboot enabling a
41-
// flash of new software
42-
#if defined(FPRIME_CI_FAILSAFE_CYCLE_COUNT)
43-
// Magic bootloader breakpoint, provided by PRJC
44-
if (strncmp(CONFIG_BOARD, "teensy", 6) == 0) {
28+
void FatalHandler::reboot() {
29+
// When running in CI failsafe mode and the board is a teensy,
30+
// then we should invoke bkpt #251 to trigger the soft reboot enabling a
31+
// flash of new software
32+
#if defined(FPRIME_CI_FAILSAFE_CYCLE_COUNT)
33+
// Magic bootloader breakpoint, provided by PRJC
34+
if (strncmp(CONFIG_BOARD, "teensy", 6) == 0) {
4535
asm("bkpt #251");
46-
}
47-
#endif
36+
}
37+
#endif
4838
// Otherwise, use Zephyr to reboot the system
4939
sys_reboot(SYS_REBOOT_COLD);
50-
}
51-
52-
void FatalHandler::FatalReceive_handler(
53-
const FwIndexType portNum,
54-
FwEventIdType Id) {
55-
Fw::Logger::log("FATAL %" PRI_FwEventIdType "handled.\n",Id);
56-
Os::Task::delay(Fw::TimeInterval(0, 1000)); // Delay to allow log to be processed
57-
this->reboot(); // Reboot the system
58-
}
40+
}
5941

42+
void FatalHandler::FatalReceive_handler(const FwIndexType portNum, FwEventIdType Id) {
43+
Fw::Logger::log("FATAL %" PRI_FwEventIdType "handled.\n", Id);
44+
Os::Task::delay(Fw::TimeInterval(0, 1000)); // Delay to allow log to be processed
45+
this->reboot(); // Reboot the system
46+
}
6047

61-
} // end namespace Svc
48+
} // namespace Components

FprimeZephyrReference/Components/FatalHandler/FatalHandler.hpp

Lines changed: 32 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -17,44 +17,37 @@
1717

1818
namespace Components {
1919

20-
class FatalHandler final :
21-
public FatalHandlerComponentBase
22-
{
23-
24-
public:
25-
26-
// ----------------------------------------------------------------------
27-
// Construction, initialization, and destruction
28-
// ----------------------------------------------------------------------
29-
30-
//! Construct object FatalHandler
31-
//!
32-
FatalHandler(
33-
const char *const compName /*!< The component name*/
34-
);
35-
36-
//! Destroy object FatalHandler
37-
//!
38-
~FatalHandler();
39-
40-
//! Reboot the device
41-
//!
42-
void reboot();
43-
44-
private:
45-
46-
// ----------------------------------------------------------------------
47-
// Handler implementations for user-defined typed input ports
48-
// ----------------------------------------------------------------------
49-
50-
//! Handler implementation for FatalReceive
51-
//!
52-
void FatalReceive_handler(
53-
const FwIndexType portNum, /*!< The port number*/
54-
FwEventIdType Id /*!< The ID of the FATAL event*/
55-
);
56-
};
57-
58-
} // end namespace Svc
20+
class FatalHandler final : public FatalHandlerComponentBase {
21+
public:
22+
// ----------------------------------------------------------------------
23+
// Construction, initialization, and destruction
24+
// ----------------------------------------------------------------------
25+
26+
//! Construct object FatalHandler
27+
//!
28+
FatalHandler(const char* const compName /*!< The component name*/
29+
);
30+
31+
//! Destroy object FatalHandler
32+
//!
33+
~FatalHandler();
34+
35+
//! Reboot the device
36+
//!
37+
void reboot();
38+
39+
private:
40+
// ----------------------------------------------------------------------
41+
// Handler implementations for user-defined typed input ports
42+
// ----------------------------------------------------------------------
43+
44+
//! Handler implementation for FatalReceive
45+
//!
46+
void FatalReceive_handler(const FwIndexType portNum, /*!< The port number*/
47+
FwEventIdType Id /*!< The ID of the FATAL event*/
48+
);
49+
};
50+
51+
} // namespace Components
5952

6053
#endif

FprimeZephyrReference/Components/Led/Led.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,7 @@ Led ::~Led() {}
2222
// ----------------------------------------------------------------------
2323

2424
void Led ::run_handler(FwIndexType portNum, U32 context) {
25-
26-
U32 interval = this->m_blinkInterval; // Get the blink interval from the member variable
25+
U32 interval = this->m_blinkInterval; // Get the blink interval from the member variable
2726

2827
// Only perform actions when set to blinking
2928
if (this->m_blinking && (interval != 0)) {
@@ -77,10 +76,10 @@ void Led ::BLINKING_ON_OFF_cmdHandler(FwOpcodeType opCode, U32 cmdSeq, Fw::On on
7776
void Led ::SET_BLINK_INTERVAL_cmdHandler(FwOpcodeType opCode, U32 cmdSeq, U32 interval) {
7877
// Update the member variable
7978
this->m_blinkInterval = interval;
80-
79+
8180
// Log the event
8281
this->log_ACTIVITY_HI_BlinkIntervalSet(interval);
83-
82+
8483
// Provide command response
8584
this->cmdResponse_out(opCode, cmdSeq, Fw::CmdResponse::OK);
8685
}

FprimeZephyrReference/Components/Led/Led.hpp

Lines changed: 28 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -24,42 +24,38 @@ class Led : public LedComponentBase {
2424
//! Destroy Led object
2525
~Led();
2626

27-
private :
27+
private:
28+
// ----------------------------------------------------------------------
29+
// Handler implementations for user-defined typed input ports
30+
// ----------------------------------------------------------------------
2831

29-
// ----------------------------------------------------------------------
30-
// Handler implementations for user-defined typed input ports
31-
// ----------------------------------------------------------------------
32+
//! Handler implementation for run
33+
//!
34+
//! Port receiving calls from the rate group
35+
void run_handler(FwIndexType portNum, //!< The port number
36+
U32 context //!< The call order
37+
) override;
3238

33-
//! Handler implementation for run
34-
//!
35-
//! Port receiving calls from the rate group
36-
void
37-
run_handler(FwIndexType portNum, //!< The port number
38-
U32 context //!< The call order
39-
) override;
39+
private:
40+
// ----------------------------------------------------------------------
41+
// Handler implementations for commands
42+
// ----------------------------------------------------------------------
4043

41-
private :
42-
// ----------------------------------------------------------------------
43-
// Handler implementations for commands
44-
// ----------------------------------------------------------------------
44+
//! Handler implementation for command BLINKING_ON_OFF
45+
//!
46+
//! Command to turn on or off the blinking LED
47+
void BLINKING_ON_OFF_cmdHandler(FwOpcodeType opCode, //!< The opcode
48+
U32 cmdSeq, //!< The command sequence number
49+
Fw::On onOff //!< Indicates whether the blinking should be on or off
50+
) override;
4551

46-
//! Handler implementation for command BLINKING_ON_OFF
47-
//!
48-
//! Command to turn on or off the blinking LED
49-
void
50-
BLINKING_ON_OFF_cmdHandler(FwOpcodeType opCode, //!< The opcode
51-
U32 cmdSeq, //!< The command sequence number
52-
Fw::On onOff //!< Indicates whether the blinking should be on or off
53-
) override;
54-
55-
//! Handler implementation for command SET_BLINK_INTERVAL
56-
//!
57-
//! Command to set the LED blink interval
58-
void
59-
SET_BLINK_INTERVAL_cmdHandler(FwOpcodeType opCode, //!< The opcode
60-
U32 cmdSeq, //!< The command sequence number
61-
U32 interval //!< Blink interval in rate group ticks
62-
) override;
52+
//! Handler implementation for command SET_BLINK_INTERVAL
53+
//!
54+
//! Command to set the LED blink interval
55+
void SET_BLINK_INTERVAL_cmdHandler(FwOpcodeType opCode, //!< The opcode
56+
U32 cmdSeq, //!< The command sequence number
57+
U32 interval //!< Blink interval in rate group ticks
58+
) override;
6359

6460
Fw::On m_state = Fw::On::OFF; //! Keeps track if LED is on or off
6561
U64 m_transitions = 0; //! The number of on/off transitions that have occurred

FprimeZephyrReference/ReferenceDeployment/Main.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,28 +4,28 @@
44
//
55
// ======================================================================
66
// Used to access topology functions
7-
#include <FprimeZephyrReference/ReferenceDeployment/Top/ReferenceDeploymentTopology.hpp>
8-
#include <zephyr/sys/printk.h>
97
#include <zephyr/kernel.h>
8+
#include <zephyr/sys/printk.h>
9+
#include <FprimeZephyrReference/ReferenceDeployment/Top/ReferenceDeploymentTopology.hpp>
1010

11-
const struct device *serial = DEVICE_DT_GET(DT_NODELABEL(cdc_acm_uart0));
11+
const struct device* serial = DEVICE_DT_GET(DT_NODELABEL(cdc_acm_uart0));
1212

1313
int main(int argc, char* argv[]) {
1414
// ** DO NOT REMOVE **//
1515
//
1616
// This sleep is necessary to allow the USB CDC ACM interface to initialize before
1717
// the application starts writing to it.
1818
k_sleep(K_MSEC(3000));
19-
19+
2020
Os::init();
2121
// Object for communicating state to the topology
2222
ReferenceDeployment::TopologyState inputs;
2323
inputs.uartDevice = serial;
2424
inputs.baudRate = 115200;
25-
25+
2626
// Setup, cycle, and teardown topology
2727
ReferenceDeployment::setupTopology(inputs);
28-
ReferenceDeployment::startRateGroups(); // Program loop
28+
ReferenceDeployment::startRateGroups(); // Program loop
2929
ReferenceDeployment::teardownTopology(inputs);
3030
return 0;
3131
}

FprimeZephyrReference/ReferenceDeployment/Top/ReferenceDeploymentTopology.cpp

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
// Provides access to autocoded functions
77
#include <FprimeZephyrReference/ReferenceDeployment/Top/ReferenceDeploymentTopologyAc.hpp>
88
// Note: Uncomment when using Svc:TlmPacketizer
9-
//#include <FprimeZephyrReference/ReferenceDeployment/Top/ReferenceDeploymentPacketsAc.hpp>
9+
// #include <FprimeZephyrReference/ReferenceDeployment/Top/ReferenceDeploymentPacketsAc.hpp>
1010

1111
// Necessary project-specified types
1212
#include <Fw/Types/MallocAllocator.hpp>
@@ -21,20 +21,19 @@ using namespace ReferenceDeployment;
2121
// Instantiate a malloc allocator for cmdSeq buffer allocation
2222
Fw::MallocAllocator mallocator;
2323

24-
constexpr FwSizeType BASE_RATEGROUP_PERIOD_MS = 1; // 1Khz
24+
constexpr FwSizeType BASE_RATEGROUP_PERIOD_MS = 1; // 1Khz
2525

2626
// Helper function to calculate the period for a given rate group frequency
2727
constexpr FwSizeType getRateGroupPeriod(const FwSizeType hz) {
2828
return 1000 / (hz * BASE_RATEGROUP_PERIOD_MS);
2929
}
3030

3131
// The reference topology divides the incoming clock signal (1Hz) into sub-signals: 1Hz, 1/2Hz, and 1/4Hz with 0 offset
32-
Svc::RateGroupDriver::DividerSet rateGroupDivisorsSet{
33-
{ // Array of divider objects
34-
{getRateGroupPeriod(10), 0}, // 10Hz
35-
{getRateGroupPeriod(1), 0}, // 1Hz
36-
}
37-
};
32+
Svc::RateGroupDriver::DividerSet rateGroupDivisorsSet{{
33+
// Array of divider objects
34+
{getRateGroupPeriod(10), 0}, // 10Hz
35+
{getRateGroupPeriod(1), 0}, // 1Hz
36+
}};
3837

3938
// Rate groups may supply a context token to each of the attached children whose purpose is set by the project. The
4039
// reference topology sets each token to zero as these contexts are unused in this project.
@@ -77,7 +76,7 @@ void setupTopology(const TopologyState& state) {
7776
loadParameters();
7877
// Autocoded task kick-off (active components). Function provided by autocoder.
7978
startTasks(state);
80-
79+
8180
// Uplink is configured for receive so a socket task is started
8281
comDriver.configure(state.uartDevice, state.baudRate);
8382
}

FprimeZephyrReference/ReferenceDeployment/Top/ReferenceDeploymentTopology.hpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
// ======================================================================
66
#ifndef REFERENCEDEPLOYMENT_REFERENCEDEPLOYMENTTOPOLOGY_HPP
77
#define REFERENCEDEPLOYMENT_REFERENCEDEPLOYMENTTOPOLOGY_HPP
8-
// Included for access to ReferenceDeployment::TopologyState and ReferenceDeployment::ConfigObjects::pingEntries. These definitions are required by the
9-
// autocoder, but are also used in this hand-coded topology.
8+
// Included for access to ReferenceDeployment::TopologyState and ReferenceDeployment::ConfigObjects::pingEntries. These
9+
// definitions are required by the autocoder, but are also used in this hand-coded topology.
1010
#include <FprimeZephyrReference/ReferenceDeployment/Top/ReferenceDeploymentTopologyDefs.hpp>
1111

1212
// Remove unnecessary ReferenceDeployment:: qualifications
@@ -68,11 +68,11 @@ void teardownTopology(const TopologyState& state);
6868
void startRateGroups();
6969

7070
/**
71-
* \brief stop the rate groups
71+
* \brief stop the rate groups
7272
*
7373
* This stops the cycle started by startRateGroups.
7474
*/
7575
void stopRateGroups();
7676

77-
} // namespace ReferenceDeployment
77+
} // namespace ReferenceDeployment
7878
#endif

0 commit comments

Comments
 (0)