[Mono-list] C#/Mono Serial port communication

Jon-Eirik Pettersen lists@jonepet.net
Wed, 24 Nov 2004 22:22:35 +0100


Gonzalo Paniagua Javier wrote:
> On Wed, 2004-11-24 at 18:46 +0100, Jon-Eirik Pettersen wrote:
> 
>>I have created a simple application to try this, but it does not seem to 
>>work.
>>
>>using System;
>>using System.IO;
>>
>>namespace serialchattest {
>>   class serialchattest {
>>     static string device = "/dev/rfcomm0";
>>
>>     static void Main() {
>>       using (FileStream fs = new FileStream(device, FileMode.Open, 
>>FileAccess.ReadWrite)) {
>>         using (StreamReader sr = new StreamReader(fs)) {
>>           using (StreamWriter sw = new StreamWriter(fs)) {
>>             sw.WriteLine("AT");
>>             Console.Write(sr.ReadLine());
>>           }
>>         }
>>       }
>>     }
>>   }
>>}
>>
>>Result:
>>
>>Unhandled Exception: System.IO.IOException: Win32 IO returned 
>>ERROR_SEEK. Path: /dev/rfcomm0
>>in <0x00083> System.IO.FileStream:FlushBuffer ()
>>in <0x0004f> (wrapper remoting-invoke-with-check) 
>>System.IO.FileStream:FlushBuffer ()
>>in <0x00043> System.IO.FileStream:Flush ()
>>in <0x00061> System.IO.StreamWriter:Flush ()
>>in <0x00025> System.IO.StreamWriter:Dispose (bool)
>>in <0x00010> System.IO.TextWriter:System.IDisposable.Dispose ()
>>in <0x000f3> serialchattest.serialchattest:Main ()
>>
> 
> 
> That looks a bug in mono. Please file a bug report in
> bugzilla.ximian.com.
> 
> -Gonzalo
> 

I don't think I have enough information to do it.

It says the stream is seek-able because it thinks it is a normal file it 
is opening, but seeking do not seems to work on devices.

But if I send the data  directly to the FileStream using the 
Write-function it works, but I have problems reading the data from the 
stream.