Repository navigation
Auto-reconnect USB boards and fix reconnect crash (3.3.1) - #24
Merged
Merged
Conversation
The SerialPort.config setter caches the config and SerialPort.dispose() frees it, so disposing it ourselves after assignment double-freed it in sp_free_config on the next disconnect. That aborted the app when reconnecting after an abrupt unplug. Also handle the reader erroring or closing: tear the port down immediately and report a new TransportStatus.lost. shutdown() is now single-flight so a link-loss teardown and a user disconnect can't dispose the port twice. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
When the USB transport reports a lost link, ConnectionController keeps
the session (descriptor, buffers, packet listeners, so an active
recording continues) and polls for the port to come back: by the same
name, or by USB serial number if the OS renamed it. Once present it waits
1.2 s for the bootloader to hand over, resets the framer and reopens the
port. It gives up after 30 s; a link that drops again within 5 s of a
reconnect counts toward the same outage.
The Live view stays up with a "reconnecting" banner and Cancel button,
and the Home card shows the reconnecting state. A desktop-only setting
("Reconnect automatically", on by default) turns the feature off.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Makes USB sessions survive a board reset or replug, and fixes the crash that happened when reconnecting after an abrupt unplug. Also bumps the version to 3.3.1+137 for release.
Crash fix and link-loss handling
sp_free_config:SerialPort.dispose()already frees the config, so disposing it ourselves aborted the app on the next disconnect.TransportStatus.lostis reported.shutdown()is now single-flight, so a link-loss teardown and a user disconnect can't dispose the port twice.Auto-reconnect
ConnectionControllerkeeps the session (descriptor, buffers, packet listeners), so an active recording continues.Testing
flutter test: all 42 tests pass. None of them cover the reconnect path, as this PR adds no tests.flutter analyze: 11 info-level lints, no errors or warnings.🤖 Generated with Claude Code