Skip to content

Commit

Permalink
Merge pull request #43 from mvolstad/serialnumber_regex_fix
Browse files Browse the repository at this point in the history
Serialnumber regex fix
  • Loading branch information
mazimkhan authored Oct 4, 2016
2 parents a07f517 + 90abb9f commit 198fcc4
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,7 @@ lrwxrwxrwx root 10 Dec 3 09:10 wwn-0x5000cca30ccffb77-part5 -> ../../sda5

***Note:*** ```mbed-ls``` tools pair only serial ports and mount points (not CMSIS-DAP - yet).

We can see that on our host machine (running Ubuntu) there are many 'disk type' devices visible under ```/dev/disk```. The mbed boards can be distinguished and filtered by their unique ```USB-ID``` conventions. In our case, we can see pairs of ```usb-ids``` in both ```/dev/serial/usb-id``` and ```/dev/disk/usb-id``` with embedded ``` TargetID```. ```TargetID``` can be filtered out, for example using this sudo-regexpr: ```(“MBED”|”mbed”|”STMicro”)_([a-zA-z_-]+)_([a-fA_F0-0]){4,}```
We can see that on our host machine (running Ubuntu) there are many 'disk type' devices visible under ```/dev/disk```. The mbed boards can be distinguished and filtered by their unique ```USB-ID``` conventions. In our case, we can see pairs of ```usb-ids``` in both ```/dev/serial/usb-id``` and ```/dev/disk/usb-id``` with embedded ``` TargetID```. ```TargetID``` can be filtered out, for example using this sudo-regexpr: ```(“MBED”|”mbed”|”STMicro”)_([a-zA-z_-]+)_([a-zA-Z0-9]){4,}```

For example, we can match the board 066EFF525257775087141721 by connecting a few dots:

Expand Down
4 changes: 2 additions & 2 deletions mbed_lstools/lstools_linux_generic.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,10 +88,10 @@ def list_mbeds(self):
self.ERRORLEVEL_FLAG = 0

result = []
tidhex = re.compile(r'_([0-9a-fA-F]+)-\d+:\d+')
tidpattern = re.compile(r'_([0-9a-zA-Z]+)-\d+:\d+')
for device in all_devices:
tid = None
m = tidhex.search(device[4])
m = tidpattern.search(device[4])
if m and len(m.groups()):
tid = m.group(1)
mbed = {'mount_point' : device[2],
Expand Down
2 changes: 1 addition & 1 deletion mbed_lstools/lstools_win7.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ def get_mbeds(self):
for mbed in self.get_mbed_devices():
mountpoint = re.match('.*\\\\(.:)$', mbed[0]).group(1)
# TargetID is a hex string with 10-48 chars
tid = re.search('[0-9A-Fa-f]{10,48}', mbed[1]).group(0)
tid = re.search('[0-9A-Za-z]{10,48}', mbed[1]).group(0)
mbeds += [(mountpoint, tid)]
self.debug(self.get_mbeds.__name__, (mountpoint, tid))
return mbeds
Expand Down

0 comments on commit 198fcc4

Please sign in to comment.