diff options
author | Carlos Alberto Cortez <calberto.cortez@gmail.com> | 2006-02-22 02:33:47 +0300 |
---|---|---|
committer | Carlos Alberto Cortez <calberto.cortez@gmail.com> | 2006-02-22 02:33:47 +0300 |
commit | 57ae6892c021efd484279080c565774db0e2b28f (patch) | |
tree | f9cb7c30eb65c5ab0ef3716c0c94f37acb4c8c61 /mcs/class | |
parent | 6ad83ea46246e8089d8d9a75faf1ec29f25e603d (diff) |
2006-02-21 Carlos Alberto Cortez <calberto.cortez@gmail.com>
* SerialPort.cs: Little work on support the Read methods.
svn path=/trunk/mcs/; revision=57117
Diffstat (limited to 'mcs/class')
-rw-r--r-- | mcs/class/System/System.IO.Ports/ChangeLog | 4 | ||||
-rw-r--r-- | mcs/class/System/System.IO.Ports/SerialPort.cs | 25 |
2 files changed, 28 insertions, 1 deletions
diff --git a/mcs/class/System/System.IO.Ports/ChangeLog b/mcs/class/System/System.IO.Ports/ChangeLog index 891470bddf1..58fb4d2022f 100644 --- a/mcs/class/System/System.IO.Ports/ChangeLog +++ b/mcs/class/System/System.IO.Ports/ChangeLog @@ -1,3 +1,7 @@ +2006-02-21 Carlos Alberto Cortez <calberto.cortez@gmail.com> + + * SerialPort.cs: Little work on support the Read methods. + 2006-02-14 Carlos Alberto Cortez <calberto.cortez@gmail.com> * SerialPort.cs: Little work on default values and diff --git a/mcs/class/System/System.IO.Ports/SerialPort.cs b/mcs/class/System/System.IO.Ports/SerialPort.cs index 153e845f024..f14e673f079 100644 --- a/mcs/class/System/System.IO.Ports/SerialPort.cs +++ b/mcs/class/System/System.IO.Ports/SerialPort.cs @@ -516,12 +516,35 @@ namespace System.IO.Ports public int Read (byte[] buffer, int offset, int count) { + if (!isOpen) + throw new InvalidOperationException (); + if (buffer == null) + throw new ArgumentNullException ("buffer"); + if (offset < 0 || offset >= buffer.Length) + throw new ArgumentOutOfRangeException ("offset"); + if (count < 0 || count > buffer.Length) + throw new ArgumentOutOfRangeException ("count"); + if (count > buffer.Length - offset) + throw new ArgumentException ("count > buffer.Length - offset"); + return read_serial (unixFd, buffer, offset, count, readTimeout); } public int Read (char[] buffer, int offset, int count) { - throw new NotImplementedException (); + if (!isOpen) + throw new InvalidOperationException (); + if (buffer == null) + throw new ArgumentNullException ("buffer"); + if (offset < 0 || offset >= buffer.Length) + throw new ArgumentOutOfRangeException ("offset"); + if (count < 0 || count > buffer.Length) + throw new ArgumentOutOfRangeException ("count"); + if (count > buffer.Length - offset) + throw new ArgumentException ("count > buffer.Length - offset"); + + byte [] bytes = encoding.GetBytes (buffer, offset, count); + return read_serial (unixFd, bytes, 0, bytes.Length, readTimeout); } byte[] read_buffer = new byte[4096]; |