Skip to content

Revise code generation for parameters#1002

Open
bocchino wants to merge 42 commits into
mainfrom
issue-984-extern-param-defaults
Open

Revise code generation for parameters#1002
bocchino wants to merge 42 commits into
mainfrom
issue-984-extern-param-defaults

Conversation

@bocchino
Copy link
Copy Markdown
Collaborator

@bocchino bocchino commented May 5, 2026

  • Make the behavior of external parameters consistent with the behavior of internal parameters. In particular, respect the default values provided for external parameters.
  • Move the scratch parameter buffer from the stack to a component instance member, to avoid overflowing the stack.
  • Clean up the generated code.

Closes #984.

Tandem with https://github.com/bocchino/fprime/tree/fpp-issue-984-extern-param-defaults.

Implementation Note

In the old code for loading external parameters, if there was no valid value to send to the external parameter interface, the interface was never called. In the new code, the interface is called with an INVALID flag argument. The new behavior provides more information to the external interface. However, the external interface will need to respect the rule that if it is called with an INVALID flag argument, then the data buffer does not contain valid data.

Review Notes

The diff of the C++ output for the component base classes may be hard to review. Here is a simple model that illustrates the new code generation strategy:

module Fw {
  port Time
  port PrmGet
  port PrmSet
  port Cmd
  port CmdResponse
  port CmdReg
}

passive component C {

  time get port timeGetOut

  param get port paramGet

  param set port paramSet

  command recv port cmdIn

  command resp port cmdResponseOut

  command reg port cmdRegIn

  param InternalU32Default: U32 default 42

  external param ExternalU32Default: U32 default 42

  param InternalU32NoDefault: U32

  external param ExternalU32NoDefault: U32

}

You can run this model through fpp-to-cpp to see the four cases: internal parameter with default, external parameter with default, internal parameter with no default, and external parameter with no default.

@bocchino bocchino requested review from Kronos3 and LeStarch May 5, 2026 22:32
@bocchino bocchino added the fprime-fpp tandem F Prime and FPP tandem development label May 5, 2026
Copy link
Copy Markdown
Collaborator

@Kronos3 Kronos3 left a comment

Choose a reason for hiding this comment

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

I think this codegen looks good though we may want to revisit the use of the scratch buffer instead of stack buffer in the future.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

fprime-fpp tandem F Prime and FPP tandem development

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Default External Parameters Do Not Enforce Defaults

2 participants