[Mono-bugs] [Bug 76149][Maj] New - Writing to /dev/ttyACM* fails
bugzilla-daemon at bugzilla.ximian.com
bugzilla-daemon at bugzilla.ximian.com
Mon Sep 19 14:29:24 EDT 2005
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 gustav.petersson at karlskrona.net.
http://bugzilla.ximian.com/show_bug.cgi?id=76149
--- shadow/76149 2005-09-19 14:29:24.000000000 -0400
+++ shadow/76149.tmp.8812 2005-09-19 14:29:24.000000000 -0400
@@ -0,0 +1,170 @@
+Bug#: 76149
+Product: Mono: Class Libraries
+Version: unspecified
+OS:
+OS Details: Debian 3.1/unstable kernel 2.6.13
+Status: NEW
+Resolution:
+Severity:
+Priority: Major
+Component: System
+AssignedTo: mono-bugs at ximian.com
+ReportedBy: gustav.petersson at karlskrona.net
+QAContact: mono-bugs at ximian.com
+TargetMilestone: ---
+URL:
+Cc:
+Summary: Writing to /dev/ttyACM* fails
+
+Description of Problem:
+Writing a string to /dev/ttyACM0 fails on FileStream.Flush(). If the
+Flush() call is left out the error shows itself when doing a read (implicit
+Flush())
+
+A small sample program is attached that shows this problem.
+
+Steps to reproduce the problem:
+// created on 9/19/2005 at 6:23 PM
+
+using System;
+using System.IO;
+using System.Text;
+
+/*
+public class NoSeekStream : FileStream
+{
+ public NoSeekStream(string name, FileMode mode, FileAccess access) :
+base(name, mode, access)
+ {
+ }
+
+ public override bool CanSeek
+ {
+ get { return false; }
+ }
+}
+*/
+
+public class GsmDevice
+{
+ private string myDevicePort = "/dev/ttyACM0";
+ private FileStream myAtStream;
+ private ASCIIEncoding myCmdEncoder;
+
+ public static void Main(string[] args)
+ {
+ GsmDevice d = new GsmDevice();
+
+ d.Connect();
+ Console.WriteLine(d.GetModel());
+ d.Disconnect();
+ }
+
+ public GsmDevice()
+ {
+ myCmdEncoder = new ASCIIEncoding();
+ }
+
+ public void Connect()
+ {
+ try
+ {
+ myAtStream = new FileStream(myDevicePort, FileMode.Open,
+FileAccess.ReadWrite);
+ }
+ catch(FileNotFoundException ex)
+ {
+ Console.WriteLine("Connect: " + ex.Message);
+ }
+ }
+
+ public void Disconnect()
+ {
+ try
+ {
+ myAtStream.Close();
+ }
+ catch(Exception ex)
+ {
+ Console.WriteLine("Disconnect: " + ex.Message);
+ }
+ }
+
+ public string GetModel()
+ {
+ SendCommand("AT+CGMM\r\n");
+ string at = ReadAnswer();
+
+ return at;
+ }
+
+ public void SendCommand(string theCommand)
+ {
+ try
+ {
+ byte[] buf = myCmdEncoder.GetBytes(theCommand);
+ Console.Write("Command: " + myCmdEncoder.GetString(buf));
+ myAtStream.Write(buf, 0, buf.Length);
+ myAtStream.Flush();
+ }
+ catch(Exception ex)
+ {
+ Console.WriteLine("SendCommand: " + ex.Message);
+ }
+ }
+
+ public string ReadAnswer()
+ {
+ string at = "";
+
+ try
+ {
+ byte[] buf = new byte[4096];
+ myAtStream.Read(buf, 0, buf.Length);
+
+ at = myCmdEncoder.GetString(buf);
+ }
+ catch(Exception ex)
+ {
+ Console.WriteLine("ReadResponse: Exception: " + ex.Message);
+ Console.WriteLine(ex.StackTrace);
+ }
+
+ return at;
+ }
+}
+
+
+Actual Results:
+Command: AT+CGMM
+SendCommand: Win32 IO returned 25. Path: /dev/ttyACM0
+ReadResponse: Exception: Win32 IO returned 25. Path: /dev/ttyACM0
+in [0x0005a] (at
+/tmp/scratch/BUILD/mono-1.1.9/mcs/class/corlib/System.IO/FileStream.cs:910)
+System.IO.FileStream:FlushBuffer ()
+in [0x00001] (at
+/tmp/scratch/BUILD/mono-1.1.9/mcs/class/corlib/System.IO/FileStream.cs:935)
+System.IO.FileStream:RefillBuffer ()
+in [0x00056] (at
+/tmp/scratch/BUILD/mono-1.1.9/mcs/class/corlib/System.IO/FileStream.cs:450)
+System.IO.FileStream:ReadInternal (System.Byte[] dest, Int32 dest_offset,
+Int32 count)
+in [0x000be] (at
+/tmp/scratch/BUILD/mono-1.1.9/mcs/class/corlib/System.IO/FileStream.cs:417)
+System.IO.FileStream:Read (System.Byte[] dest, Int32 dest_offset, Int32 count)
+in [0x0001c] (at /home/wilco/Projects/gnome-mobile/GsmDevice.cs:97)
+GsmDevice:ReadAnswer ()
+
+Disconnect: Win32 IO returned 25. Path: /dev/ttyACM0
+
+
+Expected Results:
+Command: AT+CGMM
+
+How often does this happen?
+Every time.
+
+Additional Information:
+
+I've tried this with both the debian supplied mono packages (1.1.8) and the
+latest mono installer (1.1.9). Both are giving the same error.
More information about the mono-bugs
mailing list