Skip to content

Refactor port handler #3984

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

Merged
merged 7 commits into from
May 30, 2024
Merged

Conversation

McGiverGim
Copy link
Member

This is an intent to simplify the port_handler.js. The way it is now, is a very complicated structure produced from patch after patch, and using callback handlers to do the things, but now we have events.

This let's the file in a clean way to add the next things missing. All the callback system can be removed by simply sending events and listen in the other place (for example, when detected a DFU port send an event and in listen to it in the firmare flasher to start to flash).

The changes are big, and GitHub does not help in the merge view, it shows a lot more changes than what really are, because I moved the code from one place to another.

Copy link

netlify bot commented May 25, 2024

Deploy Preview for origin-betaflight-app ready!

Name Link
🔨 Latest commit 68043dd
🔍 Latest deploy log https://app.netlify.com/sites/origin-betaflight-app/deploys/665896657ed49e00085ae18d
😎 Deploy Preview https://deploy-preview-3984.dev.app.betaflight.com
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@McGiverGim McGiverGim force-pushed the refactor_port_handler branch from c699b1d to e07947a Compare May 25, 2024 09:11
@haslinghuis haslinghuis added this to the 11.0 milestone May 25, 2024
@haslinghuis haslinghuis mentioned this pull request May 26, 2024
53 tasks
@McGiverGim McGiverGim mentioned this pull request May 27, 2024
@McGiverGim McGiverGim force-pushed the refactor_port_handler branch 4 times, most recently from 1a33f83 to 9fe595c Compare May 29, 2024 13:34
@McGiverGim McGiverGim force-pushed the refactor_port_handler branch from 9fe595c to d457473 Compare May 29, 2024 13:36
@McGiverGim
Copy link
Member Author

I think this is finally ready to be reviewed...

@haslinghuis
Copy link
Member

Please also check

image

Putting a ? on line 222 and 231 would solve it

for (let i = this.port_detected_callbacks?.length - 1; i >= 0; i--) {

@McGiverGim
Copy link
Member Author

Fixed as per review, and tested the flashing with the fix suggested. Thanks!

Copy link
Member

@haslinghuis haslinghuis left a comment

Choose a reason for hiding this comment

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

Already tested with latest changes.

@nerdCopter
Copy link
Member

nerdCopter commented May 29, 2024

  • 22948381 yarn dev
  • i had to toggle auto-connect off/on a couple times for auto-connect = off to work proper -- maybe the setting was cached. up until it was resolved, it had auto-connected even when off. also had auto-connected to virtual-mode 🤪 . but after resolved, seemed to work well and as expected... until:
  • cleared cache: exited Chrome, restarted yarn dev; selected i can't find my device, pair with STM32, drop-down does not populate with the new STM32 until page-refresh (reproducible).

@McGiverGim
Copy link
Member Author

The auto connect problem is a problem with switchery, the library that we use to show the checboxes. It does not refresh when vue changes the state of it. I don't know what will be a good fix for that, but it's out of this PR.
About the I can't find my device problem I will test it tomorrow.

@McGiverGim
Copy link
Member Author

Pushed a change to not auto-connect for virtual/manual ports.

cleared cache: exited Chrome, restarted yarn dev; selected i can't find my device, pair with STM32, drop-down does not populate with the new STM32 until page-refresh (reproducible)

@nerdCopter I think there must be some other variable in game. I can't reproduce it. In my case it's populated, and selected, and, if I have auto-connect enabled, it connects with it. I will continue testing but until now, no luck...

@McGiverGim
Copy link
Member Author

Added a new commit, that fixes the auto-connect state... finally it was not a switchery problem, it was a simple bug...

The checkbox is "hidden" under the switchary
library, so move to the parent to be able to show
it.
@McGiverGim
Copy link
Member Author

@nerdCopter I think I've reproduced it. It happens when the ports has permissions (it appears in the combo) but you select I can't find my device and selects it. I will look into it.

@McGiverGim
Copy link
Member Author

@nerdCopter I think I fixed it in the latest commit. Can you test it again?

}
return null;
return newPermissionPort;
Copy link
Member

Choose a reason for hiding this comment

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

newPermissionPort remains null ?

Copy link
Member Author

Choose a reason for hiding this comment

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

When the user does not select any port in the request permission yes. It's a way to know if it has selected one or not.

Copy link
Member

Choose a reason for hiding this comment

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

Cannot find where newPermissionPort is set (only on line 97) ?

Copy link
Member Author

Choose a reason for hiding this comment

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

True, at some change I lost it... good catch, I will fix it asap

Copy link
Member Author

Choose a reason for hiding this comment

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

@haslinghuis fixed!!!

@nerdCopter
Copy link
Member

7ac0ebca tested good.

  • clear cache + reset permissions, i can't find my device, pair STM32, populated lists and selected properly. (reproducible)
  • tested auto-connect on and off successfully.

Copy link

Quality Gate Failed Quality Gate failed

Failed conditions
5.6% Duplication on New Code (required ≤ 3%)

See analysis details on SonarCloud

@haslinghuis haslinghuis merged commit ff83600 into betaflight:master May 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Development

Successfully merging this pull request may close these issues.

3 participants