Please do not reply to this email- if you want to comment on the bug, go to the
URL shown below and enter your comments there.

Changed by [EMAIL PROTECTED]

http://bugzilla.ximian.com/show_bug.cgi?id=82574

--- shadow/82574        2007-08-24 12:18:19.000000000 -0400
+++ shadow/82574.tmp.19651      2007-08-24 12:18:19.000000000 -0400
@@ -0,0 +1,76 @@
+Bug#: 82574
+Product: Mono: Class Libraries
+Version: 1.2
+OS: 
+OS Details: Ubuntu Feisty AMD64
+Status: NEW   
+Resolution: 
+Severity: 
+Priority: Wishlist
+Component: System
+AssignedTo: [EMAIL PROTECTED]                            
+ReportedBy: [EMAIL PROTECTED]               
+QAContact: [EMAIL PROTECTED]
+TargetMilestone: ---
+URL: 
+Cc: 
+Summary: Implementation of SerialPort.ReadByte may be inconsistent with MSDN 
documentation
+
+Please fill in this template when reporting a bug, unless you know what you
+are doing.
+Description of Problem:
+Implementation of SerialPort.ReadByte is inconsistent with MSDN
+documentation: ReadByte returns -1 if an error occurs:
+
+internal int read_byte ()
+{
+       byte [] buff = new byte [1];
+       if (stream.Read (buff, 0, 1) > 0)
+               return buff [0];
+
+       return -1;
+}
+               
+public int ReadByte ()
+{
+       CheckOpen ();
+       return read_byte ();
+}
+
+AFAIK it should return a InvalidOperationException:
+
+MSDN:
+"InvalidOperationException The specified port is not open."
+
+
+Steps to reproduce the problem:
+1. Open serial port
+2. Generate some error (unplug usb-serial cable, ...)
+3.  
+
+Actual Results:
+If reading a byte from the stream returns -1, the ReadByte method also
+returns -1.
+
+Expected Results:
+An exception should be thrown
+
+How often does this happen? 
+Always
+
+Additional Information:
+When reading a line from the serial port (ReadLine) and an error occurs
+(cable of an usb-to-serial converter is unplugged, for instance), the
+ReadLine method is stuck in its read loop:
+
+public string ReadLine ()
+[...]
+while (true){
+       int n = stream.Read (buff, 0, 1);
+       if (n == -1 || buff [0] == '\n')
+               break;
+       bytes_read.Add (buff [0]);
+} 
+
+This is because stream.Read() may also return 0 (in case of an error). This
+is a similar bug so I didn't report another one.
_______________________________________________
mono-bugs maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/mono-bugs

Reply via email to