[chronojump] Chronopic-firmwarecord finds ports on Windows, Linux and Mac
- From: Xavier de Blas <xaviblas src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [chronojump] Chronopic-firmwarecord finds ports on Windows, Linux and Mac
- Date: Fri, 12 Sep 2014 13:55:00 +0000 (UTC)
commit 4f4c127774c7e4c60d9352480f45244eaac06d0a
Author: Xavier de Blas <xaviblas gmail com>
Date: Fri Sep 12 15:54:38 2014 +0200
Chronopic-firmwarecord finds ports on Windows, Linux and Mac
.../chronopic-firmwarecord.in | 49 ++++++++++++++-----
1 files changed, 36 insertions(+), 13 deletions(-)
---
diff --git a/chronopic-firmware/chronopic-firmwarecord/chronopic-firmwarecord.in
b/chronopic-firmware/chronopic-firmwarecord/chronopic-firmwarecord.in
index e427ab0..66648fa 100644
--- a/chronopic-firmware/chronopic-firmwarecord/chronopic-firmwarecord.in
+++ b/chronopic-firmware/chronopic-firmwarecord/chronopic-firmwarecord.in
@@ -479,20 +479,43 @@ class MyFrame(wx.Frame):
#-- Funcion para obtener la lista de puerto serie
#-- Esto depende de la plataforma en la que se ejecute
#---------------------------------------------------------
+#def getSerialPorts():
+#
+# #-- Windows
+# if os.name == 'nt':
+#
+# #-- Se usan los nueve primeros puertos serie
+# return ["COM1","COM2","COM3","COM4","COM5","COM6","COM7","COM8","COM9"]
+#
+# #-- Linux
+# elif os.name == 'posix':
+# return ["/dev/ttyUSB0","/dev/ttyUSB1"]
+#
+# else:
+# return []
+
+#Adapted from: http://stackoverflow.com/a/11398450
def getSerialPorts():
-
- #-- Windows
- if os.name == 'nt':
-
- #-- Se usan los nueve primeros puertos serie
- return ["COM1","COM2","COM3","COM4","COM5","COM6","COM7","COM8","COM9"]
-
- #-- Linux
- elif os.name == 'posix':
- return ["/dev/ttyUSB0","/dev/ttyUSB1"]
-
- else:
- return []
+ import glob
+
+ system_name = platform.system()
+ if system_name == "Windows":
+ # Scan for available ports.
+ available = []
+ for i in range(12):
+ try:
+ s = serial.Serial(i)
+ available.append(i)
+ s.close()
+ except serial.SerialException:
+ pass
+ return available
+ elif system_name == "Darwin":
+ # Mac
+ return glob.glob('/dev/tty.usbserial*')
+ else:
+ # Assume Linux or something else
+ return glob.glob('/dev/ttyUSB*')
class MyApp(wx.App):
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]