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

Implementation of the offsets in the RateGroupDriver #2166

Merged
merged 10 commits into from
Oct 26, 2023

Conversation

SMorettini
Copy link
Contributor

Originating Project/Creator
Affected Component Svc.RateGroupDriver
Affected Architectures(s)
Related Issue(s) #2135
Has Unit Tests (y/n) y
Builds Without Errors (y/n) y
Unit Tests Pass (y/n) y
Documentation Included (y/n) y

Change Description

This pull request adds the possibility to define some offset in the RateGroupDriver. This pull request was first created here but never merged. An issue was reopened here.

I apply the changes suggested in the previous pull request with the suggested changes from the reviewer @LeStarch .

@SMorettini SMorettini changed the title Implementation of the offsets Implementation of the offsets in the RateGroupDriver Aug 1, 2023
@csmith608
Copy link
Collaborator

@SMorettini upon initial inspection this looks good, thanks so much for (hopefully) taking it across the finish line

@LeStarch
Copy link
Collaborator

@SMorettini you should make sure to update the RPI deployment as well. This is the source of the code break.

Also, "No raw arrays in interfaces" is caused because you created an array of Dividers. To fix you could create a type called DividerSet, which is:

struct DivisderSet {
   Divider dividers[Svc::RateGroupDriver::DIVIDER_SIZE];
}

I'd prefer it if you'd make that adjustment as this was what we were trying to adjust last time.

@LeStarch LeStarch self-requested a review August 14, 2023 20:49
Copy link
Collaborator

@LeStarch LeStarch left a comment

Choose a reason for hiding this comment

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

Made some comments in the discussion. Let me know what you'd do and we'll pick-up the rest.

@SMorettini
Copy link
Contributor Author

@LeStarch I added the changes requested, let me know if some other improvements are required.

I also created a pull request to update the Led blinker tutorial to work with the new RateGroupDriver dividers: fprime-community/fprime-workshop-led-blinker#41

@@ -33,6 +33,24 @@
class RateGroupDriver : public RateGroupDriverComponentBase {

public:
//! Size of the divider table, provided as a constants to users passing the table in
static const NATIVE_UINT_TYPE DIVIDER_SIZE = NUM_CYCLEOUT_OUTPUT_PORTS;

Check notice

Code scanning / CodeQL

Use of basic integral type Note

DIVIDER_SIZE uses the basic integral type unsigned int rather than a typedef with size and signedness.
//! Divisor
NATIVE_INT_TYPE divisor;
//! Offset
NATIVE_INT_TYPE offset;

Check notice

Code scanning / CodeQL

Use of basic integral type Note

offset uses the basic integral type int rather than a typedef with size and signedness.
//! \brief Struct describing a divider
struct Divider{
//! Divisor
NATIVE_INT_TYPE divisor;

Check notice

Code scanning / CodeQL

Use of basic integral type Note

divisor uses the basic integral type int rather than a typedef with size and signedness.
Svc/RateGroupDriver/RateGroupDriver.cpp Fixed Show fixed Hide fixed
@LeStarch LeStarch added the Update Instructions Needed Need to add instructions in the release notes for updates. label Oct 12, 2023
@LeStarch
Copy link
Collaborator

I made some changes here:

  1. Added constructors to DivisorSet to guarantee when not explicitly initialized, that that pair was set to zero
  2. Removed argument "numDivisors" as when we transitioned to a set, this resulted in it being a constant.

Need to let CI run, but otherwise ready to go!

//! Initializes divisor and offset to passed-in pair
Divider(NATIVE_INT_TYPE divisorIn, NATIVE_INT_TYPE offsetIn) :
divisor(divisorIn), offset(offsetIn)
{}

Check notice

Code scanning / CodeQL

More than one statement per line Note

This line contains 2 statements; only one is allowed.
struct Divider{
//! Initializes divisor and offset to 0 (unused)
Divider() : divisor(0), offset(0)
{}

Check notice

Code scanning / CodeQL

More than one statement per line Note

This line contains 2 statements; only one is allowed.
Svc/RateGroupDriver/RateGroupDriver.cpp Fixed Show fixed Hide fixed
Divider() : divisor(0), offset(0)
{}
//! Initializes divisor and offset to passed-in pair
Divider(NATIVE_INT_TYPE divisorIn, NATIVE_INT_TYPE offsetIn) :

Check notice

Code scanning / CodeQL

Use of basic integral type Note

divisorIn uses the basic integral type int rather than a typedef with size and signedness.
Divider() : divisor(0), offset(0)
{}
//! Initializes divisor and offset to passed-in pair
Divider(NATIVE_INT_TYPE divisorIn, NATIVE_INT_TYPE offsetIn) :

Check notice

Code scanning / CodeQL

Use of basic integral type Note

offsetIn uses the basic integral type int rather than a typedef with size and signedness.
// copy provided array of dividers
for (NATIVE_INT_TYPE entry = 0; entry < numDividers; entry++) {
this->m_dividers[entry] = dividers[entry];
for (NATIVE_UINT_TYPE entry = 0; entry < RateGroupDriver::DIVIDER_SIZE; entry++) {

Check notice

Code scanning / CodeQL

Use of basic integral type Note

entry uses the basic integral type unsigned int rather than a typedef with size and signedness.
LeStarch added a commit to fprime-community/fprime-tutorial-hello-world that referenced this pull request Oct 12, 2023
LeStarch added a commit to fprime-community/fprime-tutorial-math-component that referenced this pull request Oct 12, 2023
LeStarch added a commit to fprime-community/fprime-tutorial-hello-world that referenced this pull request Oct 12, 2023
LeStarch added a commit to fprime-community/fprime-workshop-led-blinker that referenced this pull request Oct 12, 2023
LeStarch added a commit to fprime-community/fprime-tutorial-hello-world that referenced this pull request Oct 12, 2023
LeStarch added a commit to fprime-community/fprime-tutorial-math-component that referenced this pull request Oct 12, 2023
Copy link
Collaborator

@timcanham timcanham left a comment

Choose a reason for hiding this comment

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

Approve but with a general question about init() calls...

Svc/RateGroupDriver/RateGroupDriver.hpp Show resolved Hide resolved
@LeStarch
Copy link
Collaborator

@thomas-bc: core component, would you be a second set of 👀 ?


}

void RateGroupDriver::configure(NATIVE_INT_TYPE dividers[], NATIVE_INT_TYPE numDividers)
void RateGroupDriver::configure(const DividerSet& dividerSet)

Check notice

Code scanning / CodeQL

Long function without assertion Note

All functions of more than 10 lines should have at least one assertion.
static const NATIVE_UINT_TYPE DIVIDER_SIZE = NUM_CYCLEOUT_OUTPUT_PORTS;

//! has the configure method been called
bool m_configured;

Check notice

Code scanning / CodeQL

Use of basic integral type Note

m_configured uses the basic integral type bool rather than a typedef with size and signedness.

// Loop through each divider. For a given port, the port will be called when the divider value
// divides evenly into the number of ticks. For example, if the divider value for a port is 4,
// it would be called every fourth invocation of the CycleIn port.
for (NATIVE_INT_TYPE entry = 0; entry < this->m_numDividers; entry++) {
if (this->m_dividers[entry] != 0) {
for (NATIVE_UINT_TYPE entry = 0; entry < RateGroupDriver::DIVIDER_SIZE; entry++) {

Check notice

Code scanning / CodeQL

Use of basic integral type Note

entry uses the basic integral type unsigned int rather than a typedef with size and signedness.
LeStarch added a commit to fprime-community/fprime-tutorial-hello-world that referenced this pull request Oct 26, 2023
LeStarch added a commit to fprime-community/fprime-tutorial-math-component that referenced this pull request Oct 26, 2023
LeStarch added a commit to fprime-community/fprime-workshop-led-blinker that referenced this pull request Oct 26, 2023
Copy link
Collaborator

@thomas-bc thomas-bc left a comment

Choose a reason for hiding this comment

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

🚀

Copy link
Collaborator

@LeStarch LeStarch left a comment

Choose a reason for hiding this comment

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

Approved! Thanks for the fixes!

@LeStarch LeStarch merged commit 36a07dd into nasa:devel Oct 26, 2023
34 checks passed
thomas-bc added a commit to fprime-community/fprime-tutorial-hello-world that referenced this pull request Oct 26, 2023
thomas-bc added a commit to fprime-community/fprime-tutorial-math-component that referenced this pull request Oct 26, 2023
thomas-bc added a commit to fprime-community/fprime-workshop-led-blinker that referenced this pull request Oct 26, 2023
* Add support for new rate group dividers (#41)

* Add support for new rate group dividers

* Fix naming mistake

* Fixing topology for nasa/fprime#2166

---------

Co-authored-by: Simone Morettini <[email protected]>
Co-authored-by: M Starch <[email protected]>
@SMorettini SMorettini deleted the adding-offset-to-rate-group branch February 6, 2024 07:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Update Instructions Needed Need to add instructions in the release notes for updates.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants