Created
June 18, 2014 14:20
-
-
Save mba7/63eff49085600d6b8b52 to your computer and use it in GitHub Desktop.
enumerate the availables serial ports using pyserial
This file contains 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
def enumerate_serial_ports(): | |
""" | |
Purpose: scan for available ports | |
Return: return a list containing the names of | |
the availables serial ports | |
""" | |
outAvailablePorts = [] | |
for i in range(256): | |
try: | |
s = serial.Serial(i) | |
outAvailablePorts.append(s.portstr) | |
s.close() | |
except serial.SerialException: | |
pass | |
return outAvailablePorts |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment