Skip to content

Add serial facade #4402

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 6 commits into from
Mar 30, 2025
Merged

Add serial facade #4402

merged 6 commits into from
Mar 30, 2025

Conversation

haslinghuis
Copy link
Member

@haslinghuis haslinghuis commented Mar 24, 2025

This pull request includes several changes aimed at refactoring the serial communication modules and improving the handling of different device protocols. The most important changes include replacing serialShim with serial, renaming and refactoring protocol files, and improving device event handling.

image

Refactoring serial communication modules:

Renaming and refactoring protocol files:

Improving device event handling:

These changes collectively improve the codebase by streamlining serial communication, organizing protocol files more effectively, and enhancing the handling of various device protocols.

Tested so far

  • connect and disconnect (serial and virtual)
  • save and reboot (serial and virtual)
  • auto-detect
  • auto-backup
  • flashing
  • presets
  • cli
  • websocket connection
  • unplug usb
  • reconnect after unplug
  • bluetooth

Copy link

netlify bot commented Mar 24, 2025

Deploy Preview for origin-betaflight-app ready!

Name Link
🔨 Latest commit 75320c7
🔍 Latest deploy log https://app.netlify.com/sites/origin-betaflight-app/deploys/67e32df3add28b0008e31ef2
😎 Deploy Preview https://deploy-preview-4402.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.

@haslinghuis haslinghuis marked this pull request as draft March 25, 2025 18:26
@haslinghuis haslinghuis marked this pull request as ready for review March 25, 2025 21:50
Copy link

Quality Gate Failed Quality Gate failed

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

See analysis details on SonarQube Cloud

@nerdCopter
Copy link
Member

nerdCopter commented Mar 26, 2025

75320c77

  • everything seems to work.
  • had a DFU dialog selection go stalled (failed to open serial port), but second time worked without a dialog popping up. this could be loose connection, maybe not PR issue, need further testing with permissions reset.
  • CLI seems slower but only in some cases. example support id delay between blocks. diff all was fast, then immediate dump all had a delay before dumping fast.

Copy link
Member

@VitroidFPV VitroidFPV left a comment

Choose a reason for hiding this comment

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

Backs up, flashes, connects and does CLI at basically the same speed at which it does on master

Copy link
Member

@McGiverGim McGiverGim left a comment

Choose a reason for hiding this comment

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

It seems good to me. Is not the path that I was in mind, but it seems it will work.

I always thougt that part where we must "differentiate" the different serial connections must be the serial_backend. So in the serial_backend we must decide wich serial to use, and connect with it. It must give too the "public" methods (read, write, etc.) for the rest of the code (a kind of proxy to serial) and all the code must use only this public methods. The serial class must be only an interface and must be implemented by the different serial connections.

You have used a different approach. The serial class is the class used by the rest of the code, so the serial_backend is responsible of open/close and serial must be used to read/write. I'm not too sure if this is better or not that my thoughts, I prefer to have all in one place, but it's ok to me.

Great work. I'm sure this was not easy.

@mituritsyn
Copy link
Contributor

I checked a few scenarios: different types of connections and reconnections, they all seem to be OK.
bluetooth not tested

@mituritsyn
Copy link
Contributor

Are we able to determine whether FC is already connected to another tab or app, and hijack the connection or, at lest notify the user?

@nerdCopter
Copy link
Member

testing is already connected (or already plugged in) would be great, but not a blocking factor for me. since PWA, i've become accustomed to unplugging/plugging when the dialog sits rotating.

@haslinghuis haslinghuis merged commit 4aad8c6 into betaflight:master Mar 30, 2025
8 of 9 checks passed
@haslinghuis haslinghuis deleted the serial branch March 30, 2025 19:42
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.

5 participants