2006-08-13 Miguel de Icaza <miguel@novell.com>
authorMiguel de Icaza <miguel@gnome.org>
Mon, 14 Aug 2006 01:18:03 +0000 (01:18 -0000)
committerMiguel de Icaza <miguel@gnome.org>
Mon, 14 Aug 2006 01:18:03 +0000 (01:18 -0000)
* SerialPort.cs: Also handle ttyUSB for Chris.

svn path=/trunk/mcs/; revision=63692

mcs/class/System/System.IO.Ports/ChangeLog
mcs/class/System/System.IO.Ports/SerialPort.cs

index 373af02154719e993def27ff1c646fba3af8d8df..8d858c21415a2d331b10e372a828e753c6031a29 100644 (file)
@@ -1,5 +1,7 @@
 2006-08-13  Miguel de Icaza  <miguel@novell.com>
 
+       * SerialPort.cs: Also handle ttyUSB for Chris.
+
        * SerialPortStream.cs (BytesToRead, BytesToWrite): Implement. 
 
        * SerialPort.cs (ReadByte): Go directly to the stream, no need to
index f75a9ba618f2a2ad64d49fe7bbd47d2f460579e3..1a13c329be1dea2a797b5a4bf9813dbc86f011fd 100644 (file)
@@ -455,9 +455,19 @@ namespace System.IO.Ports
                public static string [] GetPortNames ()
                {
                        int p = (int) Environment.OSVersion.Platform;
-                       if (p == 4 || p == 128) // Are we on Unix?
-                               return Directory.GetFiles ("/dev/", "ttyS*");
-
+                       
+                       // Are we on Unix?
+                       if (p == 4 || p == 128){
+                               string [] ttys = Directory.GetFiles ("/dev/", "tty*");
+                               List<string> serial_ports = new List<string> ();
+                               
+                               foreach (string dev in ttys){
+                                       if (dev.StartsWith ("ttyS") || dev.StartsWith ("ttyUSB"))
+                                               serial_ports.Add (dev);
+                                               
+                               }
+                               return serial_ports.ToArray ();
+                       }
                        throw new NotImplementedException ("Detection of ports is not implemented for this platform yet.");
                }