fix bug #8 - #10
Merged
Merged
Conversation
Make it work with macOS
wwj718
commented
Aug 15, 2018
ContributorAuthor
the mu-editor is cross-platform |
virtualabs
commented
Aug 15, 2018
Owner
I had a look at PySerial comports() function for MacOS, and it seems it fills VID and PID automatically. This is all we need to find a microbit. Also found this implementation: # Regular expression to match the device id of the micro:bitRE_VID_PID=re.compile("VID:PID=([0-9A-F]+):([0-9A-F]+)", re.I)
deffind_microbit():
""" Returns the port for the first micro:bit found connected to the computer running this script. If no micro:bit is found, returns None. """forport, desc, optsincomports():
match=RE_VID_PID.search(opts)
ifmatch:
vid, pid=match.groups()
vid, pid=int(vid, 16), int(pid, 16)
ifvid==MICROBIT_VIDandpid==MICROBIT_PID:
returnportifsys.platform.startswith('win'):
# No COM port found, so give an informative prompt.sys.stderr.write('Have you installed the micro:bit driver?\n')
sys.stderr.write('For more details see: {}\n'.format(ARM))
returnNoneI will try this fix until it fails for someone. Maybe a bad call. |
wwj718
commented
Aug 15, 2018
ContributorAuthor
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for freeto join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Make it work with macOS