@@ -25,7 +25,7 @@ class MbedLsToolsLinuxGeneric(MbedLsToolsBase):
25
25
""" MbedLsToolsLinuxGeneric supports mbed-enabled platforms detection across Linux family
26
26
"""
27
27
def __init__ (self ):
28
- """ ctor
28
+ """! ctor
29
29
"""
30
30
MbedLsToolsBase .__init__ (self )
31
31
self .os_supported .append ('LinuxGeneric' )
@@ -35,11 +35,8 @@ def __init__(self):
35
35
36
36
def list_mbeds (self ):
37
37
"""! Returns detailed list of connected mbeds
38
-
39
38
@return Returns list of structures with detailed info about each mbed
40
-
41
39
@details Function returns list of dictionaries with mbed attributes such as mount point, TargetID name etc.
42
-
43
40
Function returns mbed list with platform names if possible
44
41
all_devices =
45
42
[
@@ -122,9 +119,7 @@ def list_mbeds(self):
122
119
123
120
def get_dev_by_id (self , subdir ):
124
121
"""! Lists disk devices by id
125
-
126
122
@return List of strings from 'ls' command executed in shell
127
-
128
123
@details Uses Linux shell command: 'ls -oA /dev/disk/by-id/'
129
124
"""
130
125
result = []
@@ -143,9 +138,7 @@ def get_dev_by_id(self, subdir):
143
138
144
139
def get_mounts (self ):
145
140
"""! Lists mounted devices with vfat file system (potential mbeds)
146
-
147
141
@result Returns list of all mounted vfat devices
148
-
149
142
@details Uses Linux shell command: 'mount | grep vfat'
150
143
"""
151
144
result = []
@@ -164,11 +157,8 @@ def get_mounts(self):
164
157
165
158
def get_disk_hex_ids (self , disk_list ):
166
159
"""! Get only hexadecimal IDs for mbed disks
167
-
168
160
@param disk_list List of disks in a system with USBID decoration
169
-
170
161
@return Returns map of disks and corresponding disks' Hex ids
171
-
172
162
@details Uses regular expressions to get Hex strings (TargeTIDs) from list of disks
173
163
"""
174
164
nlp = re .compile (self .name_link_pattern )
@@ -185,12 +175,9 @@ def get_disk_hex_ids(self, disk_list):
185
175
186
176
def get_mbed_serial (self , serial_list , dhi ):
187
177
"""! Get mbed serial by unique hex id (dhi) in disk name
188
-
189
- @return Returns None if corresponding serial device is not found, else returns serial device path
190
-
191
178
@param serial_list List of all serial ports
192
179
@param dhi Unique Hex id of possible mbed device
193
-
180
+ @return Returns None if corresponding serial device is not found, else returns serial device path
194
181
@details Devices are located in Linux '/dev/' directory structure
195
182
"""
196
183
nlp = re .compile (self .name_link_pattern )
@@ -205,14 +192,11 @@ def get_mbed_serial(self, serial_list, dhi):
205
192
206
193
def get_detected (self , tids , disk_list , serial_list , mount_list ):
207
194
"""! Find all known mbed devices and assign name by targetID
208
-
209
- @return list of lists [mbed_name, mbed_dev_disk, mbed_mount_point, mbed_dev_serial, disk_hex_id]
210
-
211
195
@param tids TargetID comprehensive list for detection (manufacturers_ids)
212
196
@param disk_list List of disks (mount points in /dev/disk)
213
197
@param serial_list List of serial devices (serial ports in /dev/serial)
214
198
@param mount_list List of lines from 'mount' command
215
-
199
+ @return list of lists [mbed_name, mbed_dev_disk, mbed_mount_point, mbed_dev_serial, disk_hex_id]
216
200
@details Find for all disk connected all MBED ones we know about from TID list
217
201
"""
218
202
# Find for all disk connected all MBED ones we know about from TID list
@@ -241,14 +225,11 @@ def get_detected(self, tids, disk_list, serial_list, mount_list):
241
225
242
226
def get_not_detected (self , tids , disk_list , serial_list , mount_list ):
243
227
"""! Find all unknown mbed-enabled devices (may have 'mbed' string in USBID name)
244
-
245
- @return list of lists [mbed_name, mbed_dev_disk, mbed_mount_point, mbed_dev_serial, disk_hex_id]
246
-
247
228
@param tids TargetID comprehensive list for detection (manufacturers_ids)
248
229
@param disk_list List of disks (mount points in /dev/disk)
249
230
@param serial_list List of serial devices (serial ports in /dev/serial)
250
231
@param mount_list List of lines from 'mount' command
251
-
232
+ @return list of lists [mbed_name, mbed_dev_disk, mbed_mount_point, mbed_dev_serial, disk_hex_id]
252
233
@details Find for all disk connected all MBED ones we know about from TID list
253
234
"""
254
235
map_tid_to_mbed = self .get_tid_mbed_name_remap (tids )
@@ -279,12 +260,12 @@ def get_not_detected(self, tids, disk_list, serial_list, mount_list):
279
260
return result
280
261
281
262
def get_tid_mbed_name_remap (self , tids ):
282
- """ Remap to get mapping: ID -> mbed name
263
+ """! Remap to get mapping: ID -> mbed name
283
264
"""
284
265
return tids
285
266
286
267
def get_dev_name (self , link ):
287
- """ Get device name from symbolic link list
268
+ """! Get device name from symbolic link list
288
269
"""
289
270
device_sufix_pattern = ".*/([a-zA-Z0-9]*)$"
290
271
dsp = re .compile (device_sufix_pattern )
@@ -293,16 +274,16 @@ def get_dev_name(self, link):
293
274
return mbed_dev
294
275
295
276
def get_mount_point (self , dev_name , mount_list ):
296
- """ Find mount points for MBED devices using mount command output
297
-
298
- @return Returns None if mount point not found. Else returns device mount path
299
-
277
+ """! Find mount points for MBED devices using mount command output
300
278
@param dev_name Device name (e.g 'sda')
301
279
@param mount_list List of all mounted devices (strings from Linux mount shell command)
302
-
303
- @details
280
+ @return Returns None if mount point not found. Else returns device mount path
281
+ @details We want to scan names of mount points like this:
282
+ /media/MBED_xxx
283
+ /media/MBED__xxx
284
+ /media/MBED-xxx
304
285
"""
305
- mount_media_pattern = "^/[a-zA-Z0-9/]*/" + dev_name + " on (/[a-zA-Z0-9 /]*) "
286
+ mount_media_pattern = "^/[a-zA-Z0-9/]*/" + dev_name + " on (/[a-zA-Z0-9_\- /]*) "
306
287
mmp = re .compile (mount_media_pattern )
307
288
for mount in mount_list :
308
289
m = mmp .search (mount )
0 commit comments