Skip to content

fix(usb): Suppress expected serial close warnings#5932

Merged
jamesarich merged 1 commit into
meshtastic:mainfrom
jeremiah-k:bugfix/usb-serial-close-log-noise
Jun 24, 2026
Merged

fix(usb): Suppress expected serial close warnings#5932
jamesarich merged 1 commit into
meshtastic:mainfrom
jeremiah-k:bugfix/usb-serial-close-log-noise

Conversation

@jeremiah-k

Copy link
Copy Markdown
Contributor

Overview

This pull request suppresses warning-log noise from expected USB serial closes.

After the USB replug recovery work, explicit serial transport shutdown correctly suppresses disconnect propagation, but the serial reader callback could still log scary warning messages before checking whether the disconnect was caused by an explicit close(). That made normal teardown look like an unexpected USB/cable failure.

This change moves the explicit-close guard to the top of SerialRadioTransport.onDisconnected(...), before uptime calculation and warning logging.

Key Changes

  • Return early from SerialRadioTransport.onDisconnected(...) when explicitCloseInProgress is set.
  • Avoid warning logs for expected reader-thread termination during explicit close().
  • Preserve warning logs and transient disconnect forwarding for real USB unplug, cable, or I/O failures.
  • Keep service-layer close semantics unchanged.

Testing

  • Existing USB recovery behavior remains unchanged.

Migration Notes

  • No API changes.
  • No behavior change for unexpected USB disconnects.
  • This PR should land before a USB permission-denial follow-up, which touches the same callback path.

In SerialRadioTransport.onDisconnected(), the explicitCloseInProgress
guard sat below both Logger.w calls. During an explicit close() the
reader-thread teardown fires onDisconnected synchronously, so the guard
was always too late: every expected close emitted a "Serial error" and
"Serial device disconnected" warning, even though nothing went wrong.

Hoist the guard above the warning logs. Real USB unplug / I/O errors
(thrown != null, or unexpected reader termination) still surface at
warning level; only the path where explicitCloseInProgress.get() is
true — i.e. our own close() — is now silent.
@github-actions github-actions Bot added the bugfix PR tag label Jun 24, 2026
@jeremiah-k jeremiah-k marked this pull request as ready for review June 24, 2026 15:56
@jamesarich jamesarich added this pull request to the merge queue Jun 24, 2026
Merged via the queue into meshtastic:main with commit 0180661 Jun 24, 2026
22 checks passed
@jeremiah-k jeremiah-k deleted the bugfix/usb-serial-close-log-noise branch June 24, 2026 18:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bugfix PR tag

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants