-
Notifications
You must be signed in to change notification settings - Fork 28
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
devices: Add IDs for devices when multiple of the same type are connected #198
Merged
Conversation
This file contains 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
Codecov Report
@@ Coverage Diff @@
## master #198 +/- ##
==========================================
+ Coverage 96.57% 96.63% +0.05%
==========================================
Files 94 94
Lines 2629 2671 +42
==========================================
+ Hits 2539 2581 +42
Misses 90 90
|
wernerlewis
force-pushed
the
dev-detect-multiple
branch
2 times, most recently
from
February 22, 2021 11:24
a9fab3e
to
cbdd242
Compare
rwalton-arm
requested changes
Feb 25, 2021
src/mbed_tools/cli/sterm.py
Outdated
Comment on lines
61
to
63
if "[" in target: | ||
target_name, target_id = target.replace("]", "").split("[", maxsplit=1) | ||
if target_id.isdigit() and int(target_id) >= 0: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should factor this repeated logic into a function.
When using compile, find_connected_device would only find the first device which matches the target given. When multiple devices of the same type are connected, this can give unclear behavior and require manual removal of devices to flash others. Adds find_connected_devices, which finds all matching devices and returns them in a list sorted by serial number. In the compile command, these will each then be flashed in sequence. find_connected_device is now a special case to be used when only one device is wanted, when using sterm for example.
When multiple devices of the same type are connected, it is not possible to choose one specific device to flash or to launch a serial terminal with. This behavior requires the user to manually manage which devices are connected, rather than being able to select a specific board in the tools. This adds support in sterm and compile for formatting target args as TARGET_NAME[ID], where the ID corresponds to the device's position when sorted by serial number. This does not affect behavior when only one device of the given type is connected, in which case no ID is needed.
When multiple devices of the same type are connected, they are listed in the detect subcommand with non-unique build targets. Adds unique build targets when multiple of the same board are connected by including the device's ID in the format TARGET[ID]. This can then be used in compile and sterm subcommands.
wernerlewis
force-pushed
the
dev-detect-multiple
branch
from
February 25, 2021 16:56
cbdd242
to
40b03b5
Compare
rwalton-arm
approved these changes
Mar 2, 2021
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.
Description
Refactor device detection to allow for use of multiple of the same device, without having to manually remove, and to clarify default flash behavior in this case.
Previously, if a user had multiple of the same
mbed-target
connected, the behavior ofmbed-tools
was to use the first device found which matches the givenmbed_target
, regardless of how many are connected. That leads to unclear behavior withcompile -f/--sterm
, andsterm
subcommands, and requires manual disconnecting of devices to flash or start a serial terminal with a specific device.Modified the default behavior of
compile -f
to find all connected devices of the target type, and flash all that are found, rather than just flashing the first one found.Allow users to specify a device to use with an ID in
compile
andsterm
:mbed_target[ID]
. This allows use of-f/--sterm
with any connected device even if others of the same type are connected. The unique build targets with the IDs are displayed withdetect
.For example the
detect
output from #181 would now be:Added a print statement to
compile -f
to tell the user how many files were copied, and whether they were.BIN
or.HEX
.Fixes #181
Test Coverage