@@ -69,6 +69,12 @@ class MbedLsToolsBase(object):
69
69
DETAILS_TXT_NAME = 'DETAILS.TXT'
70
70
MBED_HTM_NAME = 'mbed.htm'
71
71
72
+ VENDOR_ID_DEVICE_TYPE_MAP = {
73
+ '0483' : 'stlink' ,
74
+ '0d28' : 'daplink' ,
75
+ '1366' : 'jlink'
76
+ }
77
+
72
78
def __init__ (self , list_unmounted = False , ** kwargs ):
73
79
""" ctor
74
80
"""
@@ -211,13 +217,13 @@ def _update_device_from_fs(self, device, read_details_txt):
211
217
try :
212
218
directory_entries = os .listdir (device ['mount_point' ])
213
219
device ['directory_entries' ] = directory_entries
214
- device ['device_type' ] = self ._detect_device_type (directory_entries )
220
+ device ['device_type' ] = self ._detect_device_type (device )
215
221
device ['target_id' ] = device ['target_id_usb_id' ]
216
222
217
223
{
218
224
'daplink' : self ._update_device_details_daplink ,
219
225
'jlink' : self ._update_device_details_jlink
220
- }[device ['device_type' ]](device , read_details_txt , directory_entries )
226
+ }[device ['device_type' ] or 'daplink' ](device , read_details_txt , directory_entries )
221
227
except (OSError , IOError ) as e :
222
228
logger .warning (
223
229
'Marking device with mount point "%s" as unmounted due to the '
@@ -226,13 +232,13 @@ def _update_device_from_fs(self, device, read_details_txt):
226
232
device ['device_type' ] = 'unknown'
227
233
228
234
229
- def _detect_device_type (self , directory_entries ):
235
+ def _detect_device_type (self , device ):
230
236
""" Returns a string of the device type
231
- @param directory_entries List of directories and files on the device
232
- @return 'daplink' or 'jlink'
237
+ @param device Dictionary containing device information
238
+ @return Device type located in VENDOR_ID_DEVICE_TYPE_MAP or None if unknown
233
239
"""
234
240
235
- return 'jlink' if 'segger.html' in [ e . lower () for e in directory_entries ] else 'daplink'
241
+ return self . VENDOR_ID_DEVICE_TYPE_MAP . get ( device . get ( 'vendor_id' ))
236
242
237
243
238
244
def _update_device_details_daplink (self , device , read_details_txt , directory_entries ):
0 commit comments