Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add component state machine getter #532

Merged
merged 5 commits into from
Nov 13, 2024
Merged

Add component state machine getter #532

merged 5 commits into from
Nov 13, 2024

Conversation

Kronos3
Copy link
Collaborator

@Kronos3 Kronos3 commented Nov 12, 2024

Adds a protected *_getState function for each state machine.

Closes #530

@Kronos3 Kronos3 requested a review from bocchino November 12, 2024 18:57
Copy link
Collaborator

@bocchino bocchino left a comment

Choose a reason for hiding this comment

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

Looks good!

I forgot to mention that you can run ./check-cpp in fpp-to-cpp/test or fpp-to-cpp/test/component/base to check that the generated code compiles. When I did that I saw that the state type in the generated state machine class is not State but ActiveStateMachines_S1_States. Can you fix it and run ./check-cpp to make sure it compiles? Thanks!

@bocchino
Copy link
Collaborator

The externally generated code is here: fpp-to-cpp/test/component/ActiveStateMachines_S1.hpp.

@Kronos3
Copy link
Collaborator Author

Kronos3 commented Nov 13, 2024

Looks like this requires the FPRIME environment variable to be set. I tried this with the latest devel and v3.5.0 of https://github.com/nasa/fprime which doesn't seem to work properly:

$ ../../../../../scripts/fprime-gcc -c ActiveAsyncProductPortsOnlyComponentAc.cpp -I../../../.. -I.. -I../../fprime -I../../fprime/config -Wno-sign-conversion -Wno-unused-parameter -Wno-vla-extension -Wno-zero-length-array
In file included from ActiveAsyncProductPortsOnlyComponentAc.cpp:12:
In file included from ../base/ActiveAsyncProductPortsOnlyComponentAc.hpp:12:
../../fprime/Fw/Dp/DpRequestPortAc.hpp:19:10: fatal error: 'config/FwDpIdType.hpp' file not found
   19 | #include "config/FwDpIdType.hpp"
      |          ^~~~~~~~~~~~~~~~~~~~~~~
1 error generated.

When I use FPRIME=.../compiler/tools/fpp-to-cpp/test/fprime looks like I'm missing some configuration files. I'm betting I'm missing some untracked git files that you have in your working environment but I'm not sure how to set things up properly.

@bocchino
Copy link
Collaborator

bocchino commented Nov 13, 2024

I think the problem is that fpp-check is using an older FPP version that is in your PATH, instead of the one that's installed in the bin directory of your working repo. This patch should fix it:

diff --git a/compiler/tools/fpp-to-cpp/test/fprime/generate_cpp b/compiler/tools/fpp-to-cpp/test/fprime/generate_cpp
index d33ebbdc..ebd8417d 100755
--- a/compiler/tools/fpp-to-cpp/test/fprime/generate_cpp
+++ b/compiler/tools/fpp-to-cpp/test/fprime/generate_cpp
@@ -9,7 +9,7 @@ cd `dirname $0`
 echo "generating framework C++"
 
 fpp_files=`find . -name '*.fpp'`
-fpp-to-cpp -p $PWD $fpp_files
+../../../../bin/fpp-to-cpp -p $PWD $fpp_files
 
 # Move config files into place
 for base in FppConstantsAc ProcTypeEnumAc

Can you try applying that?

You should set FPRIME to a local copy of nasa/fprime/devel.

@Kronos3
Copy link
Collaborator Author

Kronos3 commented Nov 13, 2024

Ah yes good call, I had residual packages (including fprime-fpp) installed globally from an older version of Python3. I cleaned those up and pointed FPRIME to the devel checkout and it's working as expected now.

I just pushed a fix for the above.

Copy link
Collaborator

@bocchino bocchino left a comment

Choose a reason for hiding this comment

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

Looks good!

I updated the path to fpp-to-cpp in the generate script. That way the script will pick up fpp-to-cpp from the repo instead of the environment.

It's not needed, since the guard is true if and only if the computed
list is nonempty.
@bocchino bocchino merged commit 2753fd4 into main Nov 13, 2024
11 checks passed
@bocchino bocchino deleted the tumbar-sm-getter branch November 13, 2024 18:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Phase 1 state machines] Add a protected function for getting the state
2 participants