dotgnu-pnet-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[dotgnu-pnet-commits] pnetlib ChangeLog System/IO/Ports/SerialPort.cs...


From: Radek Polak
Subject: [dotgnu-pnet-commits] pnetlib ChangeLog System/IO/Ports/SerialPort.cs...
Date: Tue, 09 Oct 2007 12:19:44 +0000

CVSROOT:        /sources/dotgnu-pnet
Module name:    pnetlib
Changes by:     Radek Polak <radekp>    07/10/09 12:19:44

Modified files:
        .              : ChangeLog 
        System/IO/Ports: SerialPort.cs 
        System/Platform: PortMethods.cs 
        resources/de_DE/System: IO.txt 
        resources/en_US/System: IO.txt 

Log message:
        error checking for serial port's write methods

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/pnetlib/ChangeLog?cvsroot=dotgnu-pnet&r1=1.2514&r2=1.2515
http://cvs.savannah.gnu.org/viewcvs/pnetlib/System/IO/Ports/SerialPort.cs?cvsroot=dotgnu-pnet&r1=1.8&r2=1.9
http://cvs.savannah.gnu.org/viewcvs/pnetlib/System/Platform/PortMethods.cs?cvsroot=dotgnu-pnet&r1=1.5&r2=1.6
http://cvs.savannah.gnu.org/viewcvs/pnetlib/resources/de_DE/System/IO.txt?cvsroot=dotgnu-pnet&r1=1.3&r2=1.4
http://cvs.savannah.gnu.org/viewcvs/pnetlib/resources/en_US/System/IO.txt?cvsroot=dotgnu-pnet&r1=1.4&r2=1.5

Patches:
Index: ChangeLog
===================================================================
RCS file: /sources/dotgnu-pnet/pnetlib/ChangeLog,v
retrieving revision 1.2514
retrieving revision 1.2515
diff -u -b -r1.2514 -r1.2515
--- ChangeLog   24 Sep 2007 06:24:15 -0000      1.2514
+++ ChangeLog   9 Oct 2007 12:19:43 -0000       1.2515
@@ -1,3 +1,14 @@
+2007-10-09  Radek Polak  <address@hidden>
+
+       * System/IO/Ports/SerialPort.cs: Check return value from write to port
+       and throw exception on error.
+
+       * System/Platform/PortMethods.cs: Change prototype for write function
+       to return int.
+
+       * resources/en_US/System/IO.txt, resources/de_De/System/IO.txt: Added
+       strings for timeout exception message.
+
 2007-07-04  Heiko Weiss <address@hidden>
        * Xsharp/Application.cs: using  default display 0, if not given.
 

Index: System/IO/Ports/SerialPort.cs
===================================================================
RCS file: /sources/dotgnu-pnet/pnetlib/System/IO/Ports/SerialPort.cs,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -b -r1.8 -r1.9
--- System/IO/Ports/SerialPort.cs       23 Feb 2006 06:26:09 -0000      1.8
+++ System/IO/Ports/SerialPort.cs       9 Oct 2007 12:19:43 -0000       1.9
@@ -1174,6 +1174,24 @@
                                                (S._("IO_NotSupp_SetLength"));
                                }
 
+               // Throw exception according to retval.
+               // Timeout has value 0, otherwise it's generic IO exception.
+               private void ThrowPortException(int retval)
+                               {
+                                       if(retval == 0)
+                                       {
+                                               // TODO: throw 
System.ServiceProcess.TimeoutException
+                                               throw new 
SystemException(S._("IO_Timeout"));
+                                       }
+                                       else
+                                       {
+                                               // This exception is not in 
docs but is useful
+                                               Errno errno = 
SocketMethods.GetErrno();
+                                               String message = 
SocketMethods.GetErrnoMessage(errno);
+                                               throw new IOException(message);
+                                       }
+                               }
+
                // Write a buffer of bytes to this stream.
                public override void Write(byte[] buffer, int offset, int count)
                                {
@@ -1182,8 +1200,12 @@
                                        {
                                                if(port.handle != IntPtr.Zero)
                                                {
-                                                       PortMethods.Write
+                                                       int retval = 
PortMethods.Write
                                                                (port.handle, 
buffer, offset, count);
+                                                       if(retval <= 0)
+                                                       {
+                                                               
ThrowPortException(retval);
+                                                       }
                                                }
                                                else
                                                {
@@ -1201,8 +1223,12 @@
                                                if(port.handle != IntPtr.Zero)
                                                {
                                                        byteBuffer[0] = value;
-                                                       PortMethods.Write
+                                                       int retval = 
PortMethods.Write
                                                                (port.handle, 
byteBuffer, 0, 1);
+                                                       if(retval <= 0)
+                                                       {
+                                                               
ThrowPortException(retval);
+                                                       }
                                                }
                                                else
                                                {

Index: System/Platform/PortMethods.cs
===================================================================
RCS file: /sources/dotgnu-pnet/pnetlib/System/Platform/PortMethods.cs,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -b -r1.5 -r1.6
--- System/Platform/PortMethods.cs      23 Feb 2006 06:26:09 -0000      1.5
+++ System/Platform/PortMethods.cs      9 Oct 2007 12:19:44 -0000       1.6
@@ -122,7 +122,7 @@
 
        // Write data to a serial port.
        [MethodImpl(MethodImplOptions.InternalCall)]
-       extern public static void Write
+       extern public static int Write
                        (IntPtr handle, byte[] buffer, int offset, int count);
 
        // Wait for a change in pin status.  Returns non-zero when a pin

Index: resources/de_DE/System/IO.txt
===================================================================
RCS file: /sources/dotgnu-pnet/pnetlib/resources/de_DE/System/IO.txt,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -b -r1.3 -r1.4
--- resources/de_DE/System/IO.txt       30 Oct 2003 07:18:22 -0000      1.3
+++ resources/de_DE/System/IO.txt       9 Oct 2007 12:19:44 -0000       1.4
@@ -21,3 +21,4 @@
 IO_SocketNotBlocking=Der angegebene socket blockiert nicht
 IO_SocketNotConnected=Der angegebene socket ist nicht verbunden
 IO_SocketIncorrectType=Der angegebene socket ist nicht vom korrekten Typ
+IO_Timeout=Das zeitlimit fur die operation ablauft

Index: resources/en_US/System/IO.txt
===================================================================
RCS file: /sources/dotgnu-pnet/pnetlib/resources/en_US/System/IO.txt,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -b -r1.4 -r1.5
--- resources/en_US/System/IO.txt       21 Jul 2004 03:47:46 -0000      1.4
+++ resources/en_US/System/IO.txt       9 Oct 2007 12:19:44 -0000       1.5
@@ -32,3 +32,4 @@
 IO_Decompress_Checksum=The gzip checksum did not match
 IO_Decompress_Total=The gzip total byte counter did not match
 IO_Compress_Input=Could not deflate all input for some reason
+IO_Timeout=The operation has timed out




reply via email to

[Prev in Thread] Current Thread [Next in Thread]