Skip to content

Commit 9d8c1ce

Browse files
committed
Add FS telemetry component
1 parent 517bcc2 commit 9d8c1ce

File tree

9 files changed

+162
-0
lines changed

9 files changed

+162
-0
lines changed

FprimeZephyrReference/Components/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,4 @@ add_fprime_subdirectory("${CMAKE_CURRENT_LIST_DIR}/Watchdog")
99
add_fprime_subdirectory("${CMAKE_CURRENT_LIST_DIR}/Burnwire/")
1010
add_fprime_subdirectory("${CMAKE_CURRENT_LIST_DIR}/BootloaderTrigger/")
1111
add_fprime_subdirectory("${CMAKE_CURRENT_LIST_DIR}/AntennaDeployer/")
12+
add_fprime_subdirectory("${CMAKE_CURRENT_LIST_DIR}/FsSpace/")
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}/FsSpace.fpp"
20+
SOURCES
21+
"${CMAKE_CURRENT_LIST_DIR}/FsSpace.cpp"
22+
# DEPENDS
23+
# MyPackage_MyOtherModule
24+
)
25+
26+
### Unit Tests ###
27+
# register_fprime_ut(
28+
# AUTOCODER_INPUTS
29+
# "${CMAKE_CURRENT_LIST_DIR}/FsSpace.fpp"
30+
# SOURCES
31+
# "${CMAKE_CURRENT_LIST_DIR}/test/ut/FsSpaceTestMain.cpp"
32+
# "${CMAKE_CURRENT_LIST_DIR}/test/ut/FsSpaceTester.cpp"
33+
# DEPENDS
34+
# STest # For rules-based testing
35+
# UT_AUTO_HELPERS
36+
# )
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
// ======================================================================
2+
// \title FsSpace.cpp
3+
// \author starchmd
4+
// \brief cpp file for FsSpace component implementation class
5+
// ======================================================================
6+
7+
#include "FprimeZephyrReference/Components/FsSpace/FsSpace.hpp"
8+
#include <zephyr/kernel.h>
9+
#include <zephyr/sys/printk.h>
10+
#include "Os/FileSystem.hpp"
11+
12+
namespace Components {
13+
14+
// ----------------------------------------------------------------------
15+
// Component construction and destruction
16+
// ----------------------------------------------------------------------
17+
18+
FsSpace ::FsSpace(const char* const compName) : FsSpaceComponentBase(compName) {}
19+
20+
FsSpace ::~FsSpace() {}
21+
22+
// ----------------------------------------------------------------------
23+
// Handler implementations for typed input ports
24+
// ----------------------------------------------------------------------
25+
26+
void FsSpace ::run_handler(FwIndexType portNum, U32 context) {
27+
FwSizeType freeBytes = 0;
28+
FwSizeType totalBytes = 0;
29+
Os::FileSystem::Status status = Os::FileSystem::getFreeSpace("/prmDb.dat", totalBytes, freeBytes);
30+
if (status == Os::FileSystem::OP_OK) {
31+
this->tlmWrite_FreeSpace(freeBytes);
32+
this->tlmWrite_TotalSpace(totalBytes);
33+
}
34+
}
35+
36+
} // namespace Components
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
module Components {
2+
@ Read free space
3+
passive component FsSpace {
4+
5+
##############################################################################
6+
#### Uncomment the following examples to start customizing your component ####
7+
##############################################################################
8+
9+
@ Free disk space telemetry channel
10+
telemetry FreeSpace: FwSizeType
11+
12+
@ Total disk space telemetry channel
13+
telemetry TotalSpace: FwSizeType
14+
15+
sync input port run: Svc.Sched
16+
17+
###############################################################################
18+
# Standard AC Ports: Required for Channels, Events, Commands, and Parameters #
19+
###############################################################################
20+
@ Port for requesting the current time
21+
time get port timeCaller
22+
23+
@ Port for sending telemetry channels to downlink
24+
telemetry port tlmOut
25+
26+
}
27+
}
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
// ======================================================================
2+
// \title FsSpace.hpp
3+
// \author starchmd
4+
// \brief hpp file for FsSpace component implementation class
5+
// ======================================================================
6+
7+
#ifndef Components_FsSpace_HPP
8+
#define Components_FsSpace_HPP
9+
10+
#include "FprimeZephyrReference/Components/FsSpace/FsSpaceComponentAc.hpp"
11+
12+
namespace Components {
13+
14+
class FsSpace final : public FsSpaceComponentBase {
15+
public:
16+
// ----------------------------------------------------------------------
17+
// Component construction and destruction
18+
// ----------------------------------------------------------------------
19+
20+
//! Construct FsSpace object
21+
FsSpace(const char* const compName //!< The component name
22+
);
23+
24+
//! Destroy FsSpace object
25+
~FsSpace();
26+
27+
private:
28+
// ----------------------------------------------------------------------
29+
// Handler implementations for typed input ports
30+
// ----------------------------------------------------------------------
31+
32+
//! Handler implementation for run
33+
void run_handler(FwIndexType portNum, //!< The port number
34+
U32 context //!< The call order
35+
) override;
36+
};
37+
38+
} // namespace Components
39+
40+
#endif
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# Components::FsSpace
2+
3+
Read free space from the filesystem (specifically the filesystem containing /prmDb.dat)/
4+
5+
## Telemetry
6+
| Name | Description |
7+
|---|---|
8+
| FreeSpace | Free space in bytes |
9+
| TotalSpace | Total space in bytes |
10+
11+
12+
## Change Log
13+
| Date | Description |
14+
|---|---|
15+
|---| Initial Draft |

FprimeZephyrReference/ReferenceDeployment/Top/ReferenceDeploymentPackets.fppi

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ telemetry packets ReferenceDeploymentPackets {
3636
CdhCore.version.FrameworkVersion
3737
CdhCore.version.ProjectVersion
3838
CdhCore.version.LibraryVersion01
39+
fsSpace.FreeSpace
40+
fsSpace.TotalSpace
3941
}
4042

4143
packet Led id 5 group 4 {

FprimeZephyrReference/ReferenceDeployment/Top/instances.fpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,4 +87,6 @@ module ReferenceDeployment {
8787
instance comSplitterTelemetry: Svc.ComSplitter base id 0x10028000
8888

8989
instance antennaDeployer: Components.AntennaDeployer base id 0x10029000
90+
91+
instance fsSpace: Components.FsSpace base id 0x10030000
9092
}

FprimeZephyrReference/ReferenceDeployment/Top/topology.fpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,8 @@ module ReferenceDeployment {
4343
instance comSplitterTelemetry
4444
# For UART sideband communication
4545
instance comDriver
46+
instance fsSpace
47+
4648

4749
# ----------------------------------------------------------------------
4850
# Pattern graph specifiers
@@ -134,6 +136,7 @@ module ReferenceDeployment {
134136
rateGroup1Hz.RateGroupMemberOut[6] -> comDelay.run
135137
rateGroup1Hz.RateGroupMemberOut[7] -> burnwire.schedIn
136138
rateGroup1Hz.RateGroupMemberOut[8] -> antennaDeployer.schedIn
139+
rateGroup1Hz.RateGroupMemberOut[9] -> fsSpace.run
137140

138141
}
139142

0 commit comments

Comments
 (0)