Skip to content

Commit bed1a6d

Browse files
authored
NullPrmDb Component (#51)
* Bring over nullprmdb * try
1 parent 3f8c021 commit bed1a6d

File tree

9 files changed

+165
-12
lines changed

9 files changed

+165
-12
lines changed

FprimeZephyrReference/Components/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
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/")
6+
add_fprime_subdirectory("${CMAKE_CURRENT_LIST_DIR}/NullPrmDb/")
67
add_fprime_subdirectory("${CMAKE_CURRENT_LIST_DIR}/Watchdog")
78
add_fprime_subdirectory("${CMAKE_CURRENT_LIST_DIR}/Burnwire/")
89
add_fprime_subdirectory("${CMAKE_CURRENT_LIST_DIR}/BootloaderTrigger/")
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}/NullPrmDb.fpp"
20+
SOURCES
21+
"${CMAKE_CURRENT_LIST_DIR}/NullPrmDb.cpp"
22+
# DEPENDS
23+
# MyPackage_MyOtherModule
24+
)
25+
26+
### Unit Tests ###
27+
# register_fprime_ut(
28+
# AUTOCODER_INPUTS
29+
# "${CMAKE_CURRENT_LIST_DIR}/NullPrmDb.fpp"
30+
# SOURCES
31+
# "${CMAKE_CURRENT_LIST_DIR}/test/ut/NullPrmDbTestMain.cpp"
32+
# "${CMAKE_CURRENT_LIST_DIR}/test/ut/NullPrmDbTester.cpp"
33+
# DEPENDS
34+
# STest # For rules-based testing
35+
# UT_AUTO_HELPERS
36+
# )
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
// ======================================================================
2+
// \title NullPrmDb.cpp
3+
// \author starchmd
4+
// \brief cpp file for NullPrmDb component implementation class
5+
// ======================================================================
6+
7+
#include "FprimeZephyrReference/Components/NullPrmDb/NullPrmDb.hpp"
8+
9+
namespace Components {
10+
11+
// ----------------------------------------------------------------------
12+
// Component construction and destruction
13+
// ----------------------------------------------------------------------
14+
15+
NullPrmDb ::NullPrmDb(const char* const compName) : NullPrmDbComponentBase(compName) {}
16+
17+
NullPrmDb ::~NullPrmDb() {}
18+
19+
// ----------------------------------------------------------------------
20+
// Handler implementations for typed input ports
21+
// ----------------------------------------------------------------------
22+
23+
Fw::ParamValid NullPrmDb ::getPrm_handler(FwIndexType portNum, FwPrmIdType id, Fw::ParamBuffer& val) {
24+
return Fw::ParamValid::INVALID;
25+
}
26+
27+
void NullPrmDb ::setPrm_handler(FwIndexType portNum, FwPrmIdType id, Fw::ParamBuffer& val) {}
28+
29+
} // namespace Components
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
module Components {
2+
@ Null parameter database
3+
passive component NullPrmDb {
4+
@ Port to get parameter values
5+
sync input port getPrm: Fw.PrmGet
6+
7+
@ Port to update parameters
8+
sync input port setPrm: Fw.PrmSet
9+
}
10+
}
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
// ======================================================================
2+
// \title NullPrmDb.hpp
3+
// \author starchmd
4+
// \brief hpp file for NullPrmDb component implementation class
5+
// ======================================================================
6+
7+
#ifndef Components_NullPrmDb_HPP
8+
#define Components_NullPrmDb_HPP
9+
10+
#include "FprimeZephyrReference/Components/NullPrmDb/NullPrmDbComponentAc.hpp"
11+
12+
namespace Components {
13+
14+
class NullPrmDb final : public NullPrmDbComponentBase {
15+
public:
16+
// ----------------------------------------------------------------------
17+
// Component construction and destruction
18+
// ----------------------------------------------------------------------
19+
20+
//! Construct NullPrmDb object
21+
NullPrmDb(const char* const compName //!< The component name
22+
);
23+
24+
//! Destroy NullPrmDb object
25+
~NullPrmDb();
26+
27+
private:
28+
// ----------------------------------------------------------------------
29+
// Handler implementations for typed input ports
30+
// ----------------------------------------------------------------------
31+
32+
//! Handler implementation for getPrm
33+
//!
34+
//! Port to get parameter values
35+
Fw::ParamValid getPrm_handler(FwIndexType portNum, //!< The port number
36+
FwPrmIdType id, //!< Parameter ID
37+
Fw::ParamBuffer& val //!< Buffer containing serialized parameter value.
38+
//!< Unmodified if param not found.
39+
) override;
40+
41+
//! Handler implementation for setPrm
42+
//!
43+
//! Port to update parameters
44+
void setPrm_handler(FwIndexType portNum, //!< The port number
45+
FwPrmIdType id, //!< Parameter ID
46+
Fw::ParamBuffer& val //!< Buffer containing serialized parameter value
47+
) override;
48+
};
49+
50+
} // namespace Components
51+
52+
#endif
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# Components::NullPrmDb
2+
3+
Null parameter database. Returns error status on any call.
4+
5+
## Requirements
6+
7+
| Name | Description | Validation |
8+
|---|---|---|
9+
|NULL-PRM-DB-001| Return error on any port call | Inspection|
10+
11+
## Usage Examples
12+
13+
Add the instance to a topology:
14+
15+
```
16+
param connections instance nullPrmDb
17+
```
18+
19+
20+
## Port Descriptions
21+
| Name | Description |
22+
|---|---|
23+
| getPrm | Get parameter, returns `Fw::ParamValid::INVALID` |
24+
| setPrm | No-op |

FprimeZephyrReference/Components/Watchdog/Watchdog.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,21 +54,19 @@ 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-
5957
// call start handler
6058
this->start_handler(0);
6159

6260
// Provide command response
61+
this->cmdResponse_out(opCode, cmdSeq, Fw::CmdResponse::OK);
6362
}
6463

6564
void Watchdog ::STOP_WATCHDOG_cmdHandler(FwOpcodeType opCode, U32 cmdSeq) {
66-
this->cmdResponse_out(opCode, cmdSeq, Fw::CmdResponse::OK);
67-
6865
// call stop handler
6966
this->stop_handler(0);
7067

7168
// Provide command response
69+
this->cmdResponse_out(opCode, cmdSeq, Fw::CmdResponse::OK);
7270
}
7371

7472
} // namespace Components

FprimeZephyrReference/ReferenceDeployment/Top/instances.fpp

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,6 @@ module ReferenceDeployment {
3636
stack size Default.STACK_SIZE \
3737
priority 4
3838

39-
instance prmDb: Svc.PrmDb base id 0x10003000 \
40-
queue size Default.QUEUE_SIZE \
41-
stack size Default.STACK_SIZE \
42-
priority 6
43-
4439
# ----------------------------------------------------------------------
4540
# Queued component instances
4641
# ----------------------------------------------------------------------
@@ -76,4 +71,6 @@ module ReferenceDeployment {
7671
instance gpioBurnwire0: Zephyr.ZephyrGpioDriver base id 0x10022000
7772

7873
instance gpioBurnwire1: Zephyr.ZephyrGpioDriver base id 0x10023000
74+
75+
instance prmDb: Components.NullPrmDb base id 0x10024000
7976
}

FprimeZephyrReference/test/bootloader_trigger.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,20 @@
11
import os
2+
import signal
23
import subprocess
34
import time
45

56
import pytest
67
from fprime_gds.common.testing_fw.api import IntegrationTestAPI
78

89

9-
@pytest.fixture(scope="session", autouse=True)
10+
@pytest.fixture(scope="session")
1011
def start_gds(fprime_test_api_session: IntegrationTestAPI):
11-
process = subprocess.Popen(["make", "gds-integration"], cwd=os.getcwd())
12+
pro = subprocess.Popen(
13+
["make", "gds-integration"],
14+
cwd=os.getcwd(),
15+
stdout=subprocess.PIPE,
16+
preexec_fn=os.setsid,
17+
)
1218

1319
gds_working = False
1420
timeout_time = time.time() + 30
@@ -24,7 +30,7 @@ def start_gds(fprime_test_api_session: IntegrationTestAPI):
2430
assert gds_working
2531

2632
yield
27-
process.kill()
33+
os.killpg(os.getpgid(pro.pid), signal.SIGTERM)
2834

2935

3036
def test_bootloader(fprime_test_api: IntegrationTestAPI):

0 commit comments

Comments
 (0)