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