Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/mono.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMiguel de Icaza <miguel@gnome.org>2006-11-18 19:40:43 +0300
committerMiguel de Icaza <miguel@gnome.org>2006-11-18 19:40:43 +0300
commitd8714697c3d869bd9ee7b77b6dabcb6b52bf49cb (patch)
tree95b0312bd53cfd1a7a39affde1b21513ccd90ee2 /mcs/class/System/System.IO.Ports
parentd7aac05b28a1d6cdc647a12254cbcbf96b727902 (diff)
2006-11-18 Jelle Hissink <Jelle.Hissink@C-it.nl>
* SerialPortStream.cs: Fix the parameters in Read, and also poll before the read, so we can thorw the TimeoutException. svn path=/trunk/mcs/; revision=68125
Diffstat (limited to 'mcs/class/System/System.IO.Ports')
-rw-r--r--mcs/class/System/System.IO.Ports/ChangeLog5
-rw-r--r--mcs/class/System/System.IO.Ports/SerialPortStream.cs19
2 files changed, 22 insertions, 2 deletions
diff --git a/mcs/class/System/System.IO.Ports/ChangeLog b/mcs/class/System/System.IO.Ports/ChangeLog
index bcb947fc5cc..bc5a2c037c1 100644
--- a/mcs/class/System/System.IO.Ports/ChangeLog
+++ b/mcs/class/System/System.IO.Ports/ChangeLog
@@ -1,3 +1,8 @@
+2006-11-18 Jelle Hissink <Jelle.Hissink@C-it.nl>
+
+ * SerialPortStream.cs: Fix the parameters in Read, and also poll
+ before the read, so we can thorw the TimeoutException.
+
2006-09-28 Andrew Skiba <andrews@mainsoft.com>
* SerialPort.cs,WinSerialStream.cs: TARGET_JVM
diff --git a/mcs/class/System/System.IO.Ports/SerialPortStream.cs b/mcs/class/System/System.IO.Ports/SerialPortStream.cs
index e53823e1e7b..8a775cd35e8 100644
--- a/mcs/class/System/System.IO.Ports/SerialPortStream.cs
+++ b/mcs/class/System/System.IO.Ports/SerialPortStream.cs
@@ -118,7 +118,11 @@ namespace System.IO.Ports
}
[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)
{
@@ -132,7 +136,18 @@ namespace System.IO.Ports
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)