summaryrefslogtreecommitdiff
path: root/examples/scanlinux.py
diff options
context:
space:
mode:
Diffstat (limited to 'examples/scanlinux.py')
-rw-r--r--examples/scanlinux.py20
1 files changed, 20 insertions, 0 deletions
diff --git a/examples/scanlinux.py b/examples/scanlinux.py
new file mode 100644
index 0000000..7cf6383
--- /dev/null
+++ b/examples/scanlinux.py
@@ -0,0 +1,20 @@
+#! /usr/bin/env python
+"""\
+Scan for serial ports. Linux specific variant that also includes USB/Serial
+adapters.
+
+Part of pySerial (http://pyserial.sf.net)
+(C) 2009 <cliechti@gmx.net>
+"""
+
+import serial
+import glob
+
+def scan():
+ """scan for available ports. return a list of device names."""
+ return glob.glob('/dev/ttyS*') + glob.glob('/dev/ttyUSB*')
+
+if __name__=='__main__':
+ print "Found ports:"
+ for name in scan():
+ print name