Skip to content

Adding suggestions when mbed detect fails #579

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 1 commit into from
Dec 5, 2017

Conversation

bridadan
Copy link
Contributor

@bridadan bridadan commented Dec 4, 2017

This was added in response to #352.

Currently if a board that is unknown to mbed-ls is plugged in and then mbed detect is ran, the output isn't that helpful.

Inside of an mbed OS project:

$ mbed detect
WARNING:mbedls.lstools_base:Call to deprecated function get_details_txt. This method will be removed from the public API. Please use 'list_mbeds' instead

[mbed] Detected K64F, port COM18, mounted D:, interface version 0244:
[mbed] Supported toolchains for K64F
+--------+-----------+-----------+-----------+-----------+-----------+-----------+
| Target | mbed OS 2 | mbed OS 5 |    ARM    |  GCC_ARM  |    IAR    |   ARMC6   |
+--------+-----------+-----------+-----------+-----------+-----------+-----------+
| K64F   | Supported | Supported | Supported | Supported | Supported | Supported |
+--------+-----------+-----------+-----------+-----------+-----------+-----------+
Supported targets: 1
Supported toolchains: 4
Traceback (most recent call last):
  File "C:\Users\bridan01\onedrive_arm\Documents\dev\mbed-os-example-blinky\mbed-os\tools\detect_targets.py", line 82, in main
    if re.match(mcu_filter, mut['mcu']):
  File "c:\python27\lib\re.py", line 141, in match
    return _compile(pattern, flags).match(string)
TypeError: expected string or buffer
[ERROR] expected string or buffer
[mbed] ERROR: "c:\python27\python.exe" returned error code 1.
[mbed] ERROR: Command "c:\python27\python.exe -u C:\Users\bridan01\onedrive_arm\Documents\dev\mbed-os-example-blinky\mbed-os\tools\detect_targets.py" in "C:\Users\bridan01\onedrive_arm\Documents\dev\mbed-os-example-blinky"

Outside of an mbed OS project:

$ mbed detect
[mbed] WARNING: The mbed tools were not found in "C:\Users\bridan01\onedrive_arm\Documents\dev\parking-lot-viewer\google".
[mbed] WARNING: Limited information will be shown about connected mbed targets/boards
---
[mbed] Detected "K64F" connected to "D:" and using com port "COM18"
[mbed] Detected "None" connected to "E:" and using com port "COM7"

This PR changes the output to the following:

Inside of an mbed OS project:

$ mbed detect
[mbed] ERROR: Failed to correctly detect all targets (run with '-vv' for more information)

$ mbed detect -vv
[mbed] Working path "C:\Users\bridan01\onedrive_arm\Documents\dev\mbed-os-example-blinky" (program)
[mbed] Query "c:\python27\python.exe -u C:\Users\bridan01\onedrive_arm\Documents\dev\mbed-os-example-blinky\mbed-os\tools\detect_targets.py" in C:\Users\bridan01\onedrive_arm\Documents\dev\mbed-os-example-blinky
[mbed] Detected K64F, port COM18, mounted D:, interface version 0244:
[mbed] Supported toolchains for K64F
+--------+-----------+-----------+-----------+-----------+-----------+-----------+
| Target | mbed OS 2 | mbed OS 5 |    ARM    |  GCC_ARM  |    IAR    |   ARMC6   |
+--------+-----------+-----------+-----------+-----------+-----------+-----------+
| K64F   | Supported | Supported | Supported | Supported | Supported | Supported |
+--------+-----------+-----------+-----------+-----------+-----------+-----------+
Supported targets: 1
Supported toolchains: 4
Traceback (most recent call last):
  File "C:\Users\bridan01\onedrive_arm\Documents\dev\mbed-os-example-blinky\mbed-os\tools\detect_targets.py", line 82, in main
    if re.match(mcu_filter, mut['mcu']):
  File "c:\python27\lib\re.py", line 141, in match
    return _compile(pattern, flags).match(string)
TypeError: expected string or buffer
[ERROR] expected string or buffer
[mbed] ERROR: Failed to correctly detect all targets (run with '-vv' for more information)
---

Outside of an mbed OS project:

$ mbed detect
[mbed] WARNING: The mbed tools were not found in "C:\Users\bridan01\onedrive_arm\Documents\dev\parking-lot-viewer\google".
[mbed] WARNING: Limited information will be shown about connected mbed targets/boards
---
[mbed] Detected "K64F" connected to "D:" and using com port "COM18"
[mbed] Detected unknown target connected to "E:" and using com port "COM7"
[mbed] WARNING: If you're developing a new target, you can mock the device to continue your development. Use 'mbedls --mock ID:NAME' to do so (see 'mbedls --help' for more information)
---

NOTE: the traceback caused by the mbed os tools should probably be patched as well.

@screamerbg
Copy link
Contributor

@bridadan please rebase

@bridadan bridadan force-pushed the detect_helpful_error branch from 0552579 to bf6b04f Compare December 5, 2017 21:44
@bridadan
Copy link
Contributor Author

bridadan commented Dec 5, 2017

Rebased!

@screamerbg screamerbg merged commit 6007f8d into ARMmbed:master Dec 5, 2017
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.

3 participants