Skip to content

Conversation

@lucarin91
Copy link
Contributor

@lucarin91 lucarin91 commented Nov 21, 2025

Motivation

We should check if the board is connected before returning an ADBConnetion object.

Change description

Use adb get-state for checking if the board is there and it is connected.

Additional Notes

Reviewer checklist

  • PR addresses a single concern.
  • PR title and description are properly filled.
  • Changes will be merged in main.
  • Changes are covered by tests.
  • Logging is meaningful in case of troubleshooting.

@lucarin91 lucarin91 marked this pull request as ready for review November 21, 2025 17:18
@Xayton Xayton linked an issue Nov 24, 2025 that may be closed by this pull request
@lucarin91 lucarin91 requested a review from dido18 November 25, 2025 14:18
}
if err := cmd.Run(); err != nil {
return nil, fmt.Errorf("failed to connect to ADB host %s: %w", host, err)
if out, err := cmd.RunAndCaptureCombinedOutput(context.TODO()); err != nil {
Copy link
Contributor

Choose a reason for hiding this comment

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

Why not context.Background()?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

that's exactly the same, but TODO, remember to add it in the future.

Copy link
Contributor

@dido18 dido18 left a comment

Choose a reason for hiding this comment

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

Only for reference, the other possible states of the get-state are the following:

adb  get-state                print offline | bootloader | device

@lucarin91 lucarin91 merged commit 7e2e6ba into arduino:main Nov 25, 2025
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[pkg] return better error in case of device offline in adb

4 participants