Skip to content

Commit 3f8c021

Browse files
ineskhouhrfarmer
andauthored
Burnwire (#12)
* added burnwire component (2) * impl from sdd * appease linter * Readme with notes to the connecty stuff to be refined and edited and appease linter * added rate group * feedback from deign review * added input ports * appease linter, remove test files * finished the writeup and appeased the linter * cleared writeer * added open back in bc make was being sad * tests folder gone fix * appease linter * appease linters * port and command call same functions * properlly parameters for REAL * ypdated dosc and edflt value * got the param propertlu, added tests * removed the old example guide * Update sdd.md * Incorperated Feedback (1) * make clearnere * trying to pass int tests * change where we clear commit histroy: * remove 2 check * checking which test * added how long was it event * correct clean=r histroies order, stop in a function * added sleep in case issue with events happening too late * assert seperate line than event * correct burnwire command * no reset * coorect OIMPORTS * remove sleeps * remove command box * added back the reset start * making the command response happen first * actually the burnwire this time * remove other [] * changed ordering, added checks for every event that should hapen * longer wait for more events after startup * no stop * event numbers * trying to gap stop event adn clean * clear histories first * send no asser command * remove all params * see reacieved events * linkt * rename run last * put parameter back * send and assert command * made second * imu at the end * put it back * added start gds * remover reset * reset gds * resert burnwire * burnwerie * formatting --------- Co-authored-by: aychar <[email protected]>
1 parent 2d92aeb commit 3f8c021

File tree

13 files changed

+455
-5
lines changed

13 files changed

+455
-5
lines changed
Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
// ======================================================================
2+
// \title Burnwire.cpp
3+
// \brief cpp file for Burnwire component implementation class
4+
// ======================================================================
5+
6+
#include "FprimeZephyrReference/Components/Burnwire/Burnwire.hpp"
7+
8+
namespace Components {
9+
10+
// ----------------------------------------------------------------------
11+
// Component construction and destruction
12+
// ----------------------------------------------------------------------
13+
14+
Burnwire ::Burnwire(const char* const compName) : BurnwireComponentBase(compName) {
15+
this->m_safetyCounter = 0;
16+
this->m_state = Fw::On::OFF;
17+
}
18+
19+
Burnwire ::~Burnwire() {}
20+
21+
// ----------------------------------------------------------------------
22+
// Handler implementations for typed input ports
23+
// ----------------------------------------------------------------------
24+
void Burnwire ::burnStart_handler(FwIndexType portNum) {
25+
this->startBurn();
26+
}
27+
28+
void Burnwire ::burnStop_handler(FwIndexType portNum) {
29+
this->stopBurn();
30+
}
31+
32+
void Burnwire::startBurn() {
33+
this->log_ACTIVITY_HI_SetBurnwireState(Fw::On::ON);
34+
this->m_safetyCounter = 0;
35+
this->m_state = Fw::On::ON;
36+
37+
Fw::ParamValid valid;
38+
U32 timeout = this->paramGet_SAFETY_TIMER(valid);
39+
this->log_ACTIVITY_HI_SafetyTimerState(timeout);
40+
}
41+
42+
void Burnwire::stopBurn() {
43+
this->log_ACTIVITY_HI_SetBurnwireState(Fw::On::OFF);
44+
this->gpioSet_out(0, Fw::Logic::LOW);
45+
this->gpioSet_out(1, Fw::Logic::LOW);
46+
47+
this->m_state = Fw::On::OFF;
48+
this->log_ACTIVITY_LO_BurnwireEndCount(m_safetyCounter);
49+
}
50+
51+
void Burnwire ::schedIn_handler(FwIndexType portNum, U32 context) {
52+
Fw::ParamValid valid;
53+
U32 timeout = this->paramGet_SAFETY_TIMER(valid);
54+
55+
if (this->m_state == Fw::On::ON) {
56+
this->m_safetyCounter++;
57+
if (this->m_safetyCounter == 1) {
58+
this->gpioSet_out(0, Fw::Logic::HIGH);
59+
this->gpioSet_out(1, Fw::Logic::HIGH);
60+
this->log_ACTIVITY_HI_SafetyTimerStatus(Fw::On::ON);
61+
}
62+
63+
if (this->m_safetyCounter >= timeout) {
64+
stopBurn();
65+
this->log_ACTIVITY_HI_SafetyTimerStatus(Fw::On::OFF);
66+
}
67+
}
68+
}
69+
70+
// ----------------------------------------------------------------------
71+
// Handler implementations for commands
72+
// ----------------------------------------------------------------------
73+
74+
void Burnwire ::START_BURNWIRE_cmdHandler(FwOpcodeType opCode, U32 cmdSeq) {
75+
this->cmdResponse_out(opCode, cmdSeq, Fw::CmdResponse::OK);
76+
this->startBurn();
77+
}
78+
79+
void Burnwire ::STOP_BURNWIRE_cmdHandler(FwOpcodeType opCode, U32 cmdSeq) {
80+
this->cmdResponse_out(opCode, cmdSeq, Fw::CmdResponse::OK);
81+
this->stopBurn();
82+
}
83+
84+
} // namespace Components
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
module Components {
2+
@ Turns Burnwire on and off
3+
passive component Burnwire {
4+
5+
@ START_BURNWIRE turns on the burnwire
6+
sync command START_BURNWIRE(
7+
)
8+
9+
@ STOP_BURNWIRE turns on the burnwire
10+
sync command STOP_BURNWIRE(
11+
)
12+
13+
event SetBurnwireState(burnwire_state: Fw.On) \
14+
severity activity high \
15+
format "Burnwire State: {}"
16+
17+
event SafetyTimerStatus(burnwire_state: Fw.On) \
18+
severity activity high\
19+
format "Safety Timer State: {} "
20+
21+
event SafetyTimerState(burnwire_status: U32) \
22+
severity activity high\
23+
format "Safety Timer Will Burn For: {} Seconds"
24+
25+
event BurnwireEndCount(end_count: U32) \
26+
severity activity low \
27+
format "Burnwire Burned for {} Seconds"
28+
29+
@ Port getting start signal
30+
sync input port burnStart: Fw.Signal
31+
32+
@ Port getting stop signal
33+
sync input port burnStop: Fw.Signal
34+
35+
@ Input Port to get the rate group
36+
sync input port schedIn: Svc.Sched
37+
38+
@ Port sending calls to the GPIO driver to stop and start the burnwire
39+
output port gpioSet: [2] Drv.GpioWrite
40+
41+
# @ SAFETY_TIMER parameter is the maximum time that the burn component will run
42+
param SAFETY_TIMER: U32 default 10
43+
44+
###############################################################################
45+
# Standard AC Ports: Required for Channels, Events, Commands, and Parameters #
46+
###############################################################################
47+
@ Port for requesting the current time
48+
time get port timeCaller
49+
50+
@ Port for sending command registrations
51+
command reg port cmdRegOut
52+
53+
@ Port for receiving commands
54+
command recv port cmdIn
55+
56+
@ Port for sending command responses
57+
command resp port cmdResponseOut
58+
59+
@ Port for sending textual representation of events
60+
text event port logTextOut
61+
62+
@ Port for sending events to downlink
63+
event port logOut
64+
65+
@ Port for sending telemetry channels to downlink
66+
telemetry port tlmOut
67+
68+
@ Port to return the value of a parameter
69+
param get port prmGetOut
70+
71+
@Port to set the value of a parameter
72+
param set port prmSetOut
73+
74+
}
75+
}
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
// ======================================================================
2+
// \title Burnwire.hpp
3+
// \brief hpp file for Burnwire component implementation class
4+
// ======================================================================
5+
6+
#ifndef Components_Burnwire_HPP
7+
#define Components_Burnwire_HPP
8+
9+
#include <atomic>
10+
#include "FprimeZephyrReference/Components/Burnwire/BurnwireComponentAc.hpp"
11+
12+
namespace Components {
13+
14+
class Burnwire final : public BurnwireComponentBase {
15+
public:
16+
// ----------------------------------------------------------------------
17+
// Component construction and destruction
18+
// ----------------------------------------------------------------------
19+
20+
//! Construct Burnwire object
21+
Burnwire(const char* const compName //!< The component name
22+
);
23+
24+
//! Destroy Burnwire object
25+
~Burnwire();
26+
27+
private:
28+
// ----------------------------------------------------------------------
29+
// Handler implementations for typed input ports
30+
// ----------------------------------------------------------------------
31+
32+
//! Handler implementation for burnStart
33+
//!
34+
//! Port getting start signal
35+
void burnStart_handler(FwIndexType portNum //!< The port number
36+
) override;
37+
38+
//! Handler implementation for burnStop
39+
//!
40+
//! Port getting stop signal
41+
void burnStop_handler(FwIndexType portNum //!< The port number
42+
) override;
43+
44+
void schedIn_handler(FwIndexType portNum, //!< The port number
45+
U32 context //!< The call order
46+
) override;
47+
48+
void startBurn();
49+
50+
void stopBurn();
51+
52+
private:
53+
// ----------------------------------------------------------------------
54+
// Handler implementations for commands
55+
// ----------------------------------------------------------------------
56+
57+
//! Handler implementation for command START_BURNWIRE
58+
void START_BURNWIRE_cmdHandler(FwOpcodeType opCode, U32 cmdSeq) override;
59+
60+
//! Handler implementation for command STOP_BURNWIRE
61+
void STOP_BURNWIRE_cmdHandler(FwOpcodeType opCode, U32 cmdSeq) override;
62+
63+
Fw::On m_state = Fw::On::OFF; // keeps track if burnwire is on or off
64+
std::atomic<U32> m_safetyCounter; // makes this an atomic variable (so its set only in one command),
65+
// you read and write half the value bc a corrupted read could be dangerouts
66+
};
67+
68+
} // namespace Components
69+
70+
#endif
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
####
2+
# F Prime CMakeLists.txt:
3+
#
4+
# SOURCES: list of source files (to be compiled)
5+
# AUTOCODER_INPUTS: list of files to be passed to the autocoders
6+
# DEPENDS: list of libraries that this module depends on
7+
#
8+
# More information in the F´ CMake API documentation:
9+
# https://fprime.jpl.nasa.gov/latest/docs/reference/api/cmake/API/
10+
#
11+
####
12+
13+
# Module names are derived from the path from the nearest project/library/framework
14+
# root when not specifically overridden by the developer. i.e. The module defined by
15+
# `Ref/SignalGen/CMakeLists.txt` will be named `Ref_SignalGen`.
16+
17+
register_fprime_library(
18+
AUTOCODER_INPUTS
19+
"${CMAKE_CURRENT_LIST_DIR}/Burnwire.fpp"
20+
SOURCES
21+
"${CMAKE_CURRENT_LIST_DIR}/Burnwire.cpp"
22+
# DEPENDS
23+
# MyPackage_MyOtherModule
24+
)
25+
26+
### Unit Tests ###
27+
# register_fprime_ut(
28+
# AUTOCODER_INPUTS
29+
# "${CMAKE_CURRENT_LIST_DIR}/Burnwire.fpp"
30+
# SOURCES
31+
# "${CMAKE_CURRENT_LIST_DIR}/test/ut/BurnwireTestMain.cpp"
32+
# "${CMAKE_CURRENT_LIST_DIR}/test/ut/BurnwireTester.cpp"
33+
# DEPENDS
34+
# STest # For rules-based testing
35+
# UT_AUTO_HELPERS
36+
# )
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
# Components::Burnwire
2+
3+
Driving the Burnwire on and off. This component activates the two pins that are required to heat the burnwire resisitor. The burnwire deployment will be handled by the Antenna Deployment, that will call the ports in the burnwire deployment. For testing, the commands to directly call the burnwire have been left in.
4+
5+
Burnwire is agnostic to the ideal safety count, it simply sets it to be whatever the port or command passes onto
6+
7+
## Sequence Diagrams
8+
Add sequence diagrams here
9+
10+
## Requirements
11+
Add requirements in the chart below
12+
| Name | Description | Validation |
13+
| ---- | ----------- | ------ |
14+
|BW-001|The burnwire shall turn on and off in response to a port calls (TBR for antenna deployer component) |Hardware Test|
15+
|BW-002|The burnwire shall turn on and off in response to commands (TBR for testing for now) |Hardware Test|
16+
|BW-003|The burnwire component shall provide an event when it is turned on and off |Integration Test|
17+
|BW-004|The burnwire component shall activate by turning both the GPIO pins that activate the burnwire | Hardware Test|
18+
|BW-005|The burnwire component shall be controlled by a safety timeout attached to a 1Hz rate group |Integration Test|
19+
|BW-006|The safety timeout shall emit an event when it is changes | Integration test|
20+
|BW-007|The burnwire safety time shall emit an event when it starts and stops |Integration Test|
21+
22+
## Port Descriptions
23+
Name | Type | Description |
24+
|----|---|---|
25+
|burnStop|`Fw::Signal`|Receive stop signal to stop the burnwire|
26+
|burnStart|`Fw::Signal`|Receive start signal to start burnwire|
27+
|gpioSet|`Drv::GpioWrite`|Control GPIO state to driver|
28+
|schedIn|[`Svc::Sched`]| run | Input | Synchronous | Receive periodic calls from rate group|
29+
30+
31+
## Commands
32+
| Name | Description |
33+
| ---- | ----------- |
34+
|START_BURNWIRE|Starts the Burn|
35+
|STOP_BURNWIRE|Stops the Burn|
36+
37+
## Events
38+
| Name | Description |
39+
|---|---|
40+
|SetBurnwireState| Emits burnwire state when the burnwire turns on or off|
41+
|SafetyTimerStatus| Emits safety timer state when the Safety Time has stopped or started|
42+
|SafetyTimerState| Emits the amount of time the safety time will run for when it starts|
43+
| BurnwireEndCount| How long the burnwire actually burned for |
44+
45+
## Component States
46+
Add component states in the chart below
47+
| Name | Description |
48+
|----|---|
49+
|m_state|Keeps track if the burnwire is on or off|
50+
51+
## Tests
52+
Add unit test descriptions in the chart below
53+
| Name | Description | Output | Coverage |
54+
|------|-------------|--------|----------|
55+
|TestSafety|Tests Burnwire turns off after SAFETY_TIMER seconds|Integration|---|
56+
|TestSafety|Tests Burnwire emits correct events after start and stop|Integration|---|
57+
58+
59+
## Parameter
60+
| Name | Description |
61+
| -----|-------------|
62+
| SAFETY_TIMER | By Default set in fpp (currently 10) is the max time the burnwire should ever run|

FprimeZephyrReference/Components/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,5 @@ add_fprime_subdirectory("${CMAKE_CURRENT_LIST_DIR}/Drv/")
44
add_fprime_subdirectory("${CMAKE_CURRENT_LIST_DIR}/FatalHandler")
55
add_fprime_subdirectory("${CMAKE_CURRENT_LIST_DIR}/ImuManager/")
66
add_fprime_subdirectory("${CMAKE_CURRENT_LIST_DIR}/Watchdog")
7+
add_fprime_subdirectory("${CMAKE_CURRENT_LIST_DIR}/Burnwire/")
78
add_fprime_subdirectory("${CMAKE_CURRENT_LIST_DIR}/BootloaderTrigger/")

FprimeZephyrReference/Components/Watchdog/Watchdog.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,19 +54,21 @@ void Watchdog ::stop_handler(FwIndexType portNum) {
5454
// ----------------------------------------------------------------------
5555

5656
void Watchdog ::START_WATCHDOG_cmdHandler(FwOpcodeType opCode, U32 cmdSeq) {
57+
this->cmdResponse_out(opCode, cmdSeq, Fw::CmdResponse::OK);
58+
5759
// call start handler
5860
this->start_handler(0);
5961

6062
// Provide command response
61-
this->cmdResponse_out(opCode, cmdSeq, Fw::CmdResponse::OK);
6263
}
6364

6465
void Watchdog ::STOP_WATCHDOG_cmdHandler(FwOpcodeType opCode, U32 cmdSeq) {
66+
this->cmdResponse_out(opCode, cmdSeq, Fw::CmdResponse::OK);
67+
6568
// call stop handler
6669
this->stop_handler(0);
6770

6871
// Provide command response
69-
this->cmdResponse_out(opCode, cmdSeq, Fw::CmdResponse::OK);
7072
}
7173

7274
} // namespace Components

FprimeZephyrReference/ReferenceDeployment/Top/ReferenceDeploymentTopology.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
#include <zephyr/drivers/gpio.h>
1515

1616
static const struct gpio_dt_spec ledGpio = GPIO_DT_SPEC_GET(DT_NODELABEL(led0), gpios);
17+
static const struct gpio_dt_spec burnwire0Gpio = GPIO_DT_SPEC_GET(DT_NODELABEL(burnwire0), gpios);
18+
static const struct gpio_dt_spec burnwire1Gpio = GPIO_DT_SPEC_GET(DT_NODELABEL(burnwire1), gpios);
1719

1820
// Allows easy reference to objects in FPP/autocoder required namespaces
1921
using namespace ReferenceDeployment;
@@ -55,6 +57,8 @@ void configureTopology() {
5557
rateGroup1Hz.configure(rateGroup1HzContext, FW_NUM_ARRAY_ELEMENTS(rateGroup1HzContext));
5658

5759
gpioDriver.open(ledGpio, Zephyr::ZephyrGpioDriver::GpioConfiguration::OUT);
60+
gpioBurnwire0.open(burnwire0Gpio, Zephyr::ZephyrGpioDriver::GpioConfiguration::OUT);
61+
gpioBurnwire1.open(burnwire1Gpio, Zephyr::ZephyrGpioDriver::GpioConfiguration::OUT);
5862
}
5963

6064
// Public functions for use in main program are namespaced with deployment name ReferenceDeployment

FprimeZephyrReference/ReferenceDeployment/Top/instances.fpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,4 +70,10 @@ module ReferenceDeployment {
7070
instance lsm6dsoManager: Drv.Lsm6dsoManager base id 0x10019000
7171

7272
instance bootloaderTrigger: Components.BootloaderTrigger base id 0x10020000
73+
74+
instance burnwire: Components.Burnwire base id 0x10021000
75+
76+
instance gpioBurnwire0: Zephyr.ZephyrGpioDriver base id 0x10022000
77+
78+
instance gpioBurnwire1: Zephyr.ZephyrGpioDriver base id 0x10023000
7379
}

0 commit comments

Comments
 (0)