Skip to content
Merged
Show file tree
Hide file tree
Changes from 20 commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
f96677b
create Ina219 manager and driver components (not impl)
asiemsen Nov 1, 2025
14819e2
Add Ina219 Driver to CMAKE
nateinaction Nov 1, 2025
700544e
fixing power monitor generations
asiemsen Nov 1, 2025
2fa08f7
Merge branch 'power-monitor' of https://github.com/Open-Source-Space-…
asiemsen Nov 1, 2025
56fdece
Impl PowerMonitor
nateinaction Nov 1, 2025
0c5314b
implemented ina219 manager cpp
asiemsen Nov 1, 2025
313debc
add run handler function
asiemsen Nov 3, 2025
31ab047
Add comments
nateinaction Nov 3, 2025
bd118fd
add powermonitorManager and inu219Manager to topology
asiemsen Nov 3, 2025
3d00b38
fix typo
asiemsen Nov 3, 2025
84d8e66
Override min number of rate group ports
nateinaction Nov 3, 2025
bdb101e
add helper function for power monitor device configure and add solar …
asiemsen Nov 3, 2025
6413cd8
fixed instances
asiemsen Nov 3, 2025
bc2a83e
change member variable naming
asiemsen Nov 3, 2025
816d1e3
fix build errors
asiemsen Nov 3, 2025
1a81717
fixing build errors
asiemsen Nov 3, 2025
1e51e8c
Update Device Tree
Mikefly123 Nov 3, 2025
8df88e4
Fixed Pin Names
Mikefly123 Nov 3, 2025
51a9a31
Added Bus Voltage Range
Mikefly123 Nov 3, 2025
cad87d7
Fixed Telem Writes
Mikefly123 Nov 3, 2025
2fe4c95
Feedback
nateinaction Nov 3, 2025
fe27a58
Unify power monitor
nateinaction Nov 3, 2025
7121696
Fill out power monitor sdd
nateinaction Nov 3, 2025
cc753a4
Initial power monitor test
nateinaction Nov 4, 2025
98dc73c
Test passing
nateinaction Nov 4, 2025
7252219
More Device Tree Tweaks!
Mikefly123 Nov 4, 2025
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
11 changes: 6 additions & 5 deletions FprimeZephyrReference/Components/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
# Include project-wide components here

add_fprime_subdirectory("${CMAKE_CURRENT_LIST_DIR}/Drv/")
add_fprime_subdirectory("${CMAKE_CURRENT_LIST_DIR}/AntennaDeployer/")
add_fprime_subdirectory("${CMAKE_CURRENT_LIST_DIR}/BootloaderTrigger/")
add_fprime_subdirectory("${CMAKE_CURRENT_LIST_DIR}/Burnwire/")
add_fprime_subdirectory("${CMAKE_CURRENT_LIST_DIR}/ComDelay/")
add_fprime_subdirectory("${CMAKE_CURRENT_LIST_DIR}/Drv/")
add_fprime_subdirectory("${CMAKE_CURRENT_LIST_DIR}/FatalHandler")
add_fprime_subdirectory("${CMAKE_CURRENT_LIST_DIR}/FsSpace/")
add_fprime_subdirectory("${CMAKE_CURRENT_LIST_DIR}/ImuManager/")
add_fprime_subdirectory("${CMAKE_CURRENT_LIST_DIR}/NullPrmDb/")
add_fprime_subdirectory("${CMAKE_CURRENT_LIST_DIR}/PowerMonitor/")
add_fprime_subdirectory("${CMAKE_CURRENT_LIST_DIR}/Watchdog")
add_fprime_subdirectory("${CMAKE_CURRENT_LIST_DIR}/Burnwire/")
add_fprime_subdirectory("${CMAKE_CURRENT_LIST_DIR}/BootloaderTrigger/")
add_fprime_subdirectory("${CMAKE_CURRENT_LIST_DIR}/AntennaDeployer/")
add_fprime_subdirectory("${CMAKE_CURRENT_LIST_DIR}/FsSpace/")
1 change: 1 addition & 0 deletions FprimeZephyrReference/Components/Drv/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
add_fprime_subdirectory("${CMAKE_CURRENT_LIST_DIR}/Helpers/")
add_fprime_subdirectory("${CMAKE_CURRENT_LIST_DIR}/Ina219Manager/")
add_fprime_subdirectory("${CMAKE_CURRENT_LIST_DIR}/Lis2mdlManager/")
add_fprime_subdirectory("${CMAKE_CURRENT_LIST_DIR}/Lsm6dsoManager/")
add_fprime_subdirectory("${CMAKE_CURRENT_LIST_DIR}/RtcManager")
Expand Down
36 changes: 36 additions & 0 deletions FprimeZephyrReference/Components/Drv/Ina219Manager/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
####
# 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/
#
####

# Module names are derived from the path from the nearest project/library/framework
# root when not specifically overridden by the developer. i.e. The module defined by
# `Ref/SignalGen/CMakeLists.txt` will be named `Ref_SignalGen`.

register_fprime_library(
AUTOCODER_INPUTS
"${CMAKE_CURRENT_LIST_DIR}/Ina219Manager.fpp"
SOURCES
"${CMAKE_CURRENT_LIST_DIR}/Ina219Manager.cpp"
# DEPENDS
# MyPackage_MyOtherModule
)

### Unit Tests ###
# register_fprime_ut(
# AUTOCODER_INPUTS
# "${CMAKE_CURRENT_LIST_DIR}/Ina219Manager.fpp"
# SOURCES
# "${CMAKE_CURRENT_LIST_DIR}/test/ut/Ina219ManagerTestMain.cpp"
# "${CMAKE_CURRENT_LIST_DIR}/test/ut/Ina219ManagerTester.cpp"
# DEPENDS
# STest # For rules-based testing
# UT_AUTO_HELPERS
# )
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A bit of a big nit pick, but we should probably just name this component INA219 or INA219PowerMonitor or something to maintain the Application / Manager / Driver design pattern separation between things.

A higher level PowerMonitorManager component might group together all of the individual power monitor components into a single interface with a little bit of logic that can be used to manipulate them.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah the lack of consistency around component naming is maddening. This specific plan where we create specific device "managers" in the Drv dir was discussed with @LeStarch but as long as we are consistent it doesn't matter. In this case this device manager is consistent with the Lis2mdl and Lsm6dso managers. I vote to keep the names as-is so we don't spend time futzing with the small potatoes stuff before launch. Some time post launch let's find agreement on a component naming scheme.

Also, as you said the power monitor component will likely change before launch similar to the imu component shifting to a detumble component so there will likely be a chance to change that higher level component this month.

Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
// ======================================================================
// \title Ina219Manager.cpp
// \author nate
// \brief cpp file for Ina219Manager component implementation class
// ======================================================================

#include "FprimeZephyrReference/Components/Drv/Ina219Manager/Ina219Manager.hpp"
#include <Fw/Types/Assert.hpp>

namespace Drv {

// ----------------------------------------------------------------------
// Component construction and destruction
// ----------------------------------------------------------------------

Ina219Manager ::Ina219Manager(const char* const compName) : Ina219ManagerComponentBase(compName) {}

Ina219Manager ::~Ina219Manager() {}

void Ina219Manager::configure(const struct device* dev) {
this->m_dev = dev;
}

// ----------------------------------------------------------------------
// Handler implementations for typed input ports
// ----------------------------------------------------------------------

F64 Ina219Manager ::currentGet_handler(FwIndexType portNum) {
if (!device_is_ready(this->m_dev)) {
this->log_WARNING_HI_DeviceNotReady();
return 0;
}
this->log_WARNING_HI_DeviceNotReady_ThrottleClear();

struct sensor_value current;

sensor_sample_fetch_chan(this->m_dev, SENSOR_CHAN_CURRENT);

sensor_channel_get(this->m_dev, SENSOR_CHAN_CURRENT, &current);

this->tlmWrite_Current(sensor_value_to_double(&current));

return sensor_value_to_double(&current);
}

F64 Ina219Manager ::powerGet_handler(FwIndexType portNum) {
if (!device_is_ready(this->m_dev)) {
this->log_WARNING_HI_DeviceNotReady();
return 0;
}
this->log_WARNING_HI_DeviceNotReady_ThrottleClear();

struct sensor_value power;

sensor_sample_fetch_chan(this->m_dev, SENSOR_CHAN_POWER);

sensor_channel_get(this->m_dev, SENSOR_CHAN_POWER, &power);

this->tlmWrite_Power(sensor_value_to_double(&power));

return sensor_value_to_double(&power);
}

F64 Ina219Manager ::voltageGet_handler(FwIndexType portNum) {
if (!device_is_ready(this->m_dev)) {
this->log_WARNING_HI_DeviceNotReady();
return 0;
}
this->log_WARNING_HI_DeviceNotReady_ThrottleClear();

struct sensor_value voltage;

sensor_sample_fetch_chan(this->m_dev, SENSOR_CHAN_VOLTAGE);

sensor_channel_get(this->m_dev, SENSOR_CHAN_VOLTAGE, &voltage);

this->tlmWrite_Voltage(sensor_value_to_double(&voltage));

return sensor_value_to_double(&voltage);
}

} // namespace Drv
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
module Drv {
port VoltageGet -> F64
port CurrentGet -> F64
port PowerGet -> F64
}

module Drv {
@ Manager for Ina219 device
passive component Ina219Manager {

#Ports
@ Port to read the voltage in volts
sync input port voltageGet: VoltageGet

@ Port to read the current in amps
sync input port currentGet: CurrentGet

@ Port to read the power in watts
sync input port powerGet: PowerGet

# Telemetry channels

@ Telemetry channel for voltage in volts
telemetry Voltage: F64

@ Telemetry channel for current in amps
telemetry Current: F64

@ Telemetry channel for power in watts
telemetry Power: F64

@ Event for reporting INA219 not ready error
event DeviceNotReady() severity warning high format "INA219 device not ready" throttle 5


###############################################################################
# Standard AC Ports: Required for Channels, Events, Commands, and Parameters #
###############################################################################
@ Port for requesting the current time
time get port timeCaller

@ Port for sending textual representation of events
text event port logTextOut

@ Port for sending events to downlink
event port logOut

@ Port for sending telemetry channels to downlink
telemetry port tlmOut

}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
// ======================================================================
// \title Ina219Manager.hpp
// \author nate
// \brief hpp file for Ina219Manager component implementation class
// ======================================================================

#ifndef Drv_Ina219Manager_HPP
#define Drv_Ina219Manager_HPP

#include "FprimeZephyrReference/Components/Drv/Ina219Manager/Ina219ManagerComponentAc.hpp"

#include <zephyr/device.h>
#include <zephyr/drivers/sensor.h>
#include <zephyr/kernel.h>
namespace Drv {

class Ina219Manager final : public Ina219ManagerComponentBase {
public:
// ----------------------------------------------------------------------
// Component construction and destruction
// ----------------------------------------------------------------------

//! Construct Ina219Manager object
Ina219Manager(const char* const compName //!< The component name
);

//! Destroy Ina219Manager object
~Ina219Manager();

void configure(const struct device* dev); // helper function to configure device for the class

private:
// ----------------------------------------------------------------------
// Handler implementations for typed input ports
// ----------------------------------------------------------------------

//! Handler implementation for currentGet
//!
//! Port to read the current in amps
F64 currentGet_handler(FwIndexType portNum //!< The port number
) override;

//! Handler implementation for powerGet
//!
//! Port to read the power in watts
F64 powerGet_handler(FwIndexType portNum //!< The port number
) override;

//! Handler implementation for voltageGet
//!
//! Port to read the voltage in volts
F64 voltageGet_handler(FwIndexType portNum //!< The port number
) override;

// ----------------------------------------------------------------------
// Member variables
// ----------------------------------------------------------------------

//! Zephyr device stores the initialized LIS2MDL sensor
const struct device* m_dev;
};

} // namespace Drv

#endif
66 changes: 66 additions & 0 deletions FprimeZephyrReference/Components/Drv/Ina219Manager/docs/sdd.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
# Drv::Ina219Manager

Manager for Ina219 device

## Usage Examples
Add usage examples here

### Diagrams
Add diagrams here

### Typical Usage
And the typical usage of the component here

## Class Diagram
Add a class diagram here

## Port Descriptions
| Name | Description |
|---|---|
|---|---|

## Component States
Add component states in the chart below
| Name | Description |
|---|---|
|---|---|

## Sequence Diagrams
Add sequence diagrams here

## Parameters
| Name | Description |
|---|---|
|---|---|

## Commands
| Name | Description |
|---|---|
|---|---|

## Events
| Name | Description |
|---|---|
|---|---|

## Telemetry
| Name | Description |
|---|---|
|---|---|

## Unit Tests
Add unit test descriptions in the chart below
| Name | Description | Output | Coverage |
|---|---|---|---|
|---|---|---|---|

## Requirements
Add requirements in the chart below
| Name | Description | Validation |
|---|---|---|
|---|---|---|

## Change Log
| Date | Description |
|---|---|
|---| Initial Draft |
36 changes: 36 additions & 0 deletions FprimeZephyrReference/Components/PowerMonitor/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
####
# 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/
#
####

# Module names are derived from the path from the nearest project/library/framework
# root when not specifically overridden by the developer. i.e. The module defined by
# `Ref/SignalGen/CMakeLists.txt` will be named `Ref_SignalGen`.

register_fprime_library(
AUTOCODER_INPUTS
"${CMAKE_CURRENT_LIST_DIR}/PowerMonitor.fpp"
SOURCES
"${CMAKE_CURRENT_LIST_DIR}/PowerMonitor.cpp"
# DEPENDS
# MyPackage_MyOtherModule
)

### Unit Tests ###
# register_fprime_ut(
# AUTOCODER_INPUTS
# "${CMAKE_CURRENT_LIST_DIR}/PowerMonitor.fpp"
# SOURCES
# "${CMAKE_CURRENT_LIST_DIR}/test/ut/PowerMonitorTestMain.cpp"
# "${CMAKE_CURRENT_LIST_DIR}/test/ut/PowerMonitorTester.cpp"
# DEPENDS
# STest # For rules-based testing
# UT_AUTO_HELPERS
# )
29 changes: 29 additions & 0 deletions FprimeZephyrReference/Components/PowerMonitor/PowerMonitor.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
// ======================================================================
// \title PowerMonitor.cpp
// \author nate
// \brief cpp file for PowerMonitor component implementation class
// ======================================================================

#include "FprimeZephyrReference/Components/PowerMonitor/PowerMonitor.hpp"

namespace Components {

// ----------------------------------------------------------------------
// Component construction and destruction
// ----------------------------------------------------------------------

PowerMonitor ::PowerMonitor(const char* const compName) : PowerMonitorComponentBase(compName) {}

PowerMonitor ::~PowerMonitor() {}

// ----------------------------------------------------------------------
// Handler implementations for typed input ports
// ----------------------------------------------------------------------

void PowerMonitor ::run_handler(FwIndexType portNum, U32 context) {
this->voltageGet_out(0);
this->currentGet_out(0);
this->powerGet_out(0);
}

} // namespace Components
Loading
Loading