[Mono-list] C#/Mono Serial port communication
Jon-Eirik Pettersen
lists@jonepet.net
Wed, 24 Nov 2004 20:13:01 +0100
Jon-Eirik Pettersen wrote:
> George Birbilis wrote:
>
>> are you trying this on Windows?
>> I assume the other guys meant to try this on Linux/UNIX
>>
>> can try installing POSIX extensions for Windows I think (is called UNIX
>> SERVICES, free from MS/MSDN)
>> else just try opening the file "com1:" or maybe "com1"
>>
>> also may need to tell Writeln method if it should spit out CR (#13) or
>> CRLF
>> (#13#10, 2 chars), or use Write method to not spit out a carriage-return
>> and/or line-feed character at all
>>
>> btw, on Windows using .NET you can make use of the COMinterop layer of
>> .NET (not sure if Mono implements that one, may have to use MS
>> implementation of .NET) and talk to the COMM ActiveX control from MS
>> (see code at
>> http://www.mech.upatras.gr/~robgroup/teams/logic/demos/index.html, the
>> VJ#.net, VB6 and Delphi5 demos in particular, since the SunJava1.3
>> demo uses Java COMM API instead of that ActiveX control)
>>
>> cheers,
>> George
>>
>> -----
>> George Birbilis (birbilis@kagi.com)
>> Microsoft MVP J# for 2004
>> http://www.kagi.com/birbilis
>> --------------
>>
>>> 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 ()
>>>
>>>
>>> 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 <0x00029> System.IO.FileStream:Dispose (bool)
>>> in <0x00013> System.IO.FileStream:Close ()
>>> in <0x0001e> System.IO.StreamReader:Dispose (bool)
>>> in <0x00010> System.IO.TextReader:System.IDisposable.Dispose ()
>>> in <0x00119> serialchattest.serialchattest:Main ()
>>>
>>>
>>> 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 <0x00029> System.IO.FileStream:Dispose (bool)
>>> in <0x00013> System.IO.FileStream:Close ()
>>> in <0x0000b> System.IO.Stream:System.IDisposable.Dispose ()
>>> in <0x0013f> serialchattest.serialchattest:Main ()
Seems that it is trying to seek in the file. Any way to stop that?
I made a simple PHP-script:
$fp = fopen("/dev/rfcomm0","w"); fwrite($fp, "ATDxxxxxxxx\r\n");
sleep(10000); fclose($fp);
This script works.