[System] Removal of the NET_2_0 in the source code
[mono.git] / mcs / class / System / System.IO.Ports / SerialPort.cs
index d6f16be5d36c21991d8aaf6c7d1d2d54d54101a4..4dff4ca7540f87eed14ad5be1a3b5fee2f26e528 100644 (file)
@@ -17,8 +17,6 @@
 //     reads 
 //
 
-#if NET_2_0
-
 using System;
 using System.Collections.Generic;
 using System.ComponentModel;
@@ -388,7 +386,7 @@ namespace System.IO.Ports
                                return read_timeout;
                        }
                        set {
-                               if (value <= 0 && value != InfiniteTimeout)
+                               if (value < 0 && value != InfiniteTimeout)
                                        throw new ArgumentOutOfRangeException ("value");
 
                                if (is_open)
@@ -476,7 +474,7 @@ namespace System.IO.Ports
                                return write_timeout;
                        }
                        set {
-                               if (value <= 0 && value != InfiniteTimeout)
+                               if (value < 0 && value != InfiniteTimeout)
                                        throw new ArgumentOutOfRangeException ("value");
 
                                if (is_open)
@@ -525,9 +523,26 @@ namespace System.IO.Ports
                        // Are we on Unix?
                        if (p == 4 || p == 128 || p == 6) {
                                string[] ttys = Directory.GetFiles("/dev/", "tty*");
+                               bool linux_style = false;
+
+                               //
+                               // Probe for Linux-styled devices: /dev/ttyS* or /dev/ttyUSB*
+                               // 
+                               foreach (string dev in ttys) {
+                                       if (dev.StartsWith("/dev/ttyS") || dev.StartsWith("/dev/ttyUSB")){
+                                               linux_style = true;
+                                               break;
+                                       }
+                               }
+
                                foreach (string dev in ttys) {
-                                       if (dev.StartsWith("/dev/ttyS") || dev.StartsWith("/dev/ttyUSB"))
-                                               serial_ports.Add(dev);
+                                       if (linux_style){
+                                               if (dev.StartsWith("/dev/ttyS") || dev.StartsWith("/dev/ttyUSB"))
+                                                       serial_ports.Add (dev);
+                                       } else {
+                                               if (dev != "/dev/tty" && dev.StartsWith ("/dev/tty") && !dev.StartsWith ("/dev/ttyC"))
+                                                       serial_ports.Add (dev);
+                                       }
                                }
                        } else {
                                using (RegistryKey subkey = Registry.LocalMachine.OpenSubKey("HARDWARE\\DEVICEMAP\\SERIALCOMM"))
@@ -790,4 +805,3 @@ namespace System.IO.Ports
 
 }
 
-#endif