31
31
# Imports related to mbed build api
32
32
from tools .build_api import mcu_toolchain_matrix
33
33
from tools .test_api import get_autodetected_MUTS_list
34
- from tools .test_api import get_mounted_details_txt
34
+ from tools .test_api import get_module_avail
35
35
from argparse import ArgumentParser
36
36
37
+ try :
38
+ import mbed_lstools
39
+ except :
40
+ pass
37
41
38
42
def main ():
39
43
"""Entry Point"""
@@ -76,17 +80,17 @@ def main():
76
80
count = 0
77
81
for mut in muts .values ():
78
82
if re .match (mcu_filter , mut ['mcu' ]):
79
- # Grab additional target details about the mut
80
- details_txt = get_mounted_details_txt (mut ['disk' ])
83
+ interface_version = get_interface_version (mut ['disk' ])
81
84
print ""
82
- print "[mbed] Detected %s, port %s, mounted %s, interface version %s" % \
83
- (mut ['mcu' ], mut ['port' ], mut ['disk' ], details_txt ['Interface Version' ])
85
+ print "[mbed] Detected %s, port %s, mounted %s, interface version %s:" % \
86
+ (mut ['mcu' ], mut ['port' ], mut ['disk' ], interface_version )
87
+
84
88
print "[mbed] Supported toolchains for %s" % mut ['mcu' ]
85
89
print mcu_toolchain_matrix (platform_filter = mut ['mcu' ])
86
90
count += 1
87
91
88
92
if count == 0 :
89
- print "[mbed] No mbed targets where detected on your system."
93
+ print "[mbed] No mbed targets were detected on your system."
90
94
91
95
except KeyboardInterrupt :
92
96
print "\n [CTRL+c] exit"
@@ -95,6 +99,23 @@ def main():
95
99
traceback .print_exc (file = sys .stdout )
96
100
print "[ERROR] %s" % str (exc )
97
101
sys .exit (1 )
102
+
103
+ def get_interface_version (mount_point ):
104
+ """ Function returns interface version from the target mounted on the specified mount point
105
+ mount_point = mut['port']
106
+ @param mount_point Name of disk where platform is connected to host machine.
107
+ """
108
+ if get_module_avail ('mbed_lstools' ):
109
+ mbeds = mbed_lstools .create ()
110
+ details_txt = mbeds .get_details_txt (mount_point )
111
+
112
+ if 'Interface Version' in details_txt :
113
+ return details_txt ['Interface Version' ]
114
+
115
+ elif 'Version' in details_txt :
116
+ return details_txt ['Version' ]
117
+
118
+ return 'unknown'
98
119
99
120
if __name__ == '__main__' :
100
121
main ()
0 commit comments