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

solved the logical error in grouping of escs into 4 #25156

Merged
merged 1 commit into from Apr 23, 2024

Conversation

adityaomar3
Copy link
Contributor

ESC_Telemetry will not send MAVLink MSG_ESC_TELEMETRY_1_TO_4 if ESC_TELEM_MAX_ESCS (PWM/SERVO) count is <=3 as logic was to keep idx = ESC_TELEM_MAX_ESCS/4 It gives rise to 3 big issues that are :-
1.It will leave some values if ESC_TELEM_MAX_ESCS which are not completely divisible by 4 e.g. 1,2,3,5,6,7,9....
2. (next_idx + idx) % num_idx it will give error if escs are less than 4
3. for loop will never start if escs count is less than 4 i.e the message inside loop will be skipped even if escs are present. Also if escs are not in multiple of 4 then it will skip 1 iteration

Solution in commit:
This is rectified by logic to add 1 to num_idx if ESC_TELEM_MAX_ESCS is not multiple of 4.

@adityaomar3
Copy link
Contributor Author

adityaomar3 commented Oct 10, 2023

I think the issue is still open, @IamPete1 @magicrub can you please review it.
#24925 this was the old PR can be taken as referance.
Sorry but I messed something with my git so opened this one.

const uint8_t num_idx = ESC_TELEM_MAX_ESCS/4;

// ensure we send out partially-full groups:
const uint8_t num_idx = (ESC_TELEM_MAX_ESCS % 4 == 0) ? ESC_TELEM_MAX_ESCS / 4 : (ESC_TELEM_MAX_ESCS / 4) + 1;
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
const uint8_t num_idx = (ESC_TELEM_MAX_ESCS % 4 == 0) ? ESC_TELEM_MAX_ESCS / 4 : (ESC_TELEM_MAX_ESCS / 4) + 1;
const uint8_t num_idx = (ESC_TELEM_MAX_ESCS + 3) / 4;

Copy link
Contributor

Choose a reason for hiding this comment

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

yes, Peters suggestion is correct

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for the review. Sure! I will rectify and update it.

@rmackay9
Copy link
Contributor

Thanks for this. Can you also modify the commit description to start with "AP_ESC_Telem:"?

@peterbarker
Copy link
Contributor

@adityaomar3 are you still interested in pursuing this one?

@adityaomar3
Copy link
Contributor Author

adityaomar3 commented Apr 16, 2024

Thanks for this. Can you also modify the commit description to start with "AP_ESC_Telem:"?

Sure I will amend it.

@adityaomar3
Copy link
Contributor Author

@adityaomar3 are you still interested in pursuing this one?

Yes, I think small changes are needed, I will complete that shortly.

@adityaomar3
Copy link
Contributor Author

Hi! I was trying to squash the commits to 1 but many commits have been added since first commit so they get merge with the latest ones, can I get some help about this or squashing is not needed at all? I am still a novice.
Thankyou!

@IamPete1
Copy link
Member

best bet is to make a new branch based on ardupilots master, then cherry pick the original commit and the update commit on to it. Then do a interactive rebase to squash the two commits into one. (see https://ardupilot.org/dev/docs/git-interactive-rebase.html). Then once your happy with that branch you can push it over this one to update the PR.

If you get stuck we can always do it for you.

@adityaomar3
Copy link
Contributor Author

Hi! Although it compiled in my pc earlier but failing some checks I was trying to understand the failing checks, but got a little understanding, can I get some help for better understanding and debugging.
Thanks a lot!

@IamPete1
Copy link
Member

@adityaomar3 Sometimes the tests fail randomly, I have started them again, hopefully they will pass this time.

@rmackay9 rmackay9 merged commit 9abcd6b into ArduPilot:master Apr 23, 2024
91 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants