@@ -177,6 +177,7 @@ def _fs_before_id_check(self, device, filter_function, include_extra_info):
177
177
"""Filter device after touching the file system of the device.
178
178
Said another way: Touch the file system before filtering
179
179
"""
180
+ device ['target_id' ] = device ['target_id_usb_id' ]
180
181
self ._update_device_from_fs (device , include_extra_info )
181
182
if not filter_function or filter_function (device ):
182
183
return device
@@ -204,17 +205,16 @@ def _update_device_from_fs(self, device, include_extra_info):
204
205
205
206
device ['device_type' ] = self ._detect_device_type (device ['mount_point' ])
206
207
207
- # details.txt check happens in here now
208
+ device [ 'target_id' ] = device [ 'target_id_usb_id' ]
208
209
self ._update_device_details (device , include_extra_info )
209
210
210
- device ['platform_name' ] = self .plat_db .get (device ['target_id' ][0 :4 ],
211
- device_type = device ['device_type' ])
212
-
213
- def _detect_device_type (self , device ):
211
+ def _detect_device_type (self , mount_point ):
214
212
""" Returns a string of the device type
215
213
@return 'daplink' or 'jlink'
216
214
"""
217
- raise NotImplementedError
215
+
216
+ files = [f .lower () for f in os .listdir (mount_point )]
217
+ return 'jlink' if 'segger.html' in files else 'daplink'
218
218
219
219
def _update_device_details (self , device , include_extra_info ):
220
220
""" Updates device dict with information from the filesystem
@@ -235,8 +235,30 @@ def _update_device_details_daplink(self, device, include_extra_info):
235
235
device .update ({"daplink_%s" % f .lower ().replace (' ' , '_' ): v
236
236
for f , v in details_txt .items ()})
237
237
238
+ device ['platform_name' ] = self .plat_db .get (device ['target_id' ][0 :4 ],
239
+ device_type = 'daplink' )
240
+
238
241
def _update_device_details_jlink (self , device , include_extra_info ):
239
- raise NotImplementedError
242
+ files = os .listdir (device ['mount_point' ])
243
+ lower_case_map = {f .lower (): f for f in files }
244
+
245
+ if 'board.html' in lower_case_map :
246
+ board_file_key = 'board.html'
247
+ elif 'user guide.html' in lower_case_map :
248
+ board_file_key = 'user guide.html'
249
+
250
+ board_file_path = os .path .join (device ['mount_point' ], lower_case_map [board_file_key ])
251
+ with open (board_file_path , 'r' ) as board_file :
252
+ board_file_lines = board_file .readlines ()
253
+
254
+ for line in board_file_lines :
255
+ m = re .search (r'url=([\w\d\:\-/\\\?\.=-_]+)' , line )
256
+ if m :
257
+ device ['url' ] = m .group (1 ).strip ()
258
+ identifier = device ['url' ].split ('/' )[- 1 ]
259
+ device ['platform_name' ] = self .plat_db .get (identifier , device_type = 'jlink' )
260
+ break
261
+
240
262
241
263
def _update_device_from_htm (self , device ):
242
264
"""Set the 'target_id', 'target_id_mbed_htm', 'platform_name' and
0 commit comments