Author: miguel
Date: 2006-11-18 11:40:43 -0500 (Sat, 18 Nov 2006)
New Revision: 68125

Modified:
   trunk/mcs/class/System/System.IO.Ports/ChangeLog
   trunk/mcs/class/System/System.IO.Ports/SerialPortStream.cs
Log:
2006-11-18  Jelle Hissink <[EMAIL PROTECTED]>

        * SerialPortStream.cs: Fix the parameters in Read, and also poll
        before the read, so we can thorw the TimeoutException.

Modified: trunk/mcs/class/System/System.IO.Ports/ChangeLog
===================================================================
--- trunk/mcs/class/System/System.IO.Ports/ChangeLog    2006-11-18 16:40:25 UTC 
(rev 68124)
+++ trunk/mcs/class/System/System.IO.Ports/ChangeLog    2006-11-18 16:40:43 UTC 
(rev 68125)
@@ -1,3 +1,8 @@
+2006-11-18  Jelle Hissink <[EMAIL PROTECTED]>
+
+       * SerialPortStream.cs: Fix the parameters in Read, and also poll
+       before the read, so we can thorw the TimeoutException.
+
 2006-09-28  Andrew Skiba  <[EMAIL PROTECTED]>
 
        * SerialPort.cs,WinSerialStream.cs: TARGET_JVM

Modified: trunk/mcs/class/System/System.IO.Ports/SerialPortStream.cs
===================================================================
--- trunk/mcs/class/System/System.IO.Ports/SerialPortStream.cs  2006-11-18 
16:40:25 UTC (rev 68124)
+++ trunk/mcs/class/System/System.IO.Ports/SerialPortStream.cs  2006-11-18 
16:40:43 UTC (rev 68125)
@@ -118,8 +118,12 @@
                }
 
                [DllImport ("MonoPosixHelper")]
-               static extern int read_serial (int fd, byte [] buffer, int 
offset, int count, int timeout);
+               static extern int read_serial (int fd, byte [] buffer, int 
offset, int count);
+               
 
+               [DllImport ("MonoPosixHelper")]
+               static extern bool poll_serial (int fd, out int error, int 
timeout);
+
                public override int Read ([In,Out] byte[] buffer, int offset, 
int count)
                {
                        CheckDisposed ();
@@ -132,7 +136,18 @@
                                throw new ArgumentException ("offset+count",
                                                              "The size of the 
buffer is less than offset + count.");
                        
-                       return read_serial (fd, buffer, offset, count, 
read_timeout);
+                       int error;
+                       bool poll_result = poll_serial (fd, out error, 
read_timeout);
+                       if (error == -1)
+                               throw new IOException ();
+
+                       if (!poll_result) {
+                               // see bug 79735   
http://bugzilla.ximian.com/show_bug.cgi?id=79735
+                               // should the next line read: return -1; 
+                               throw new TimeoutException();
+                       }
+
+                       return read_serial (fd, buffer, offset, count);
                }
 
                public override long Seek (long offset, SeekOrigin origin)

_______________________________________________
Mono-patches maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches

Reply via email to