[Mono-list] Fwd: System.IO.SerialPort.BytesToRead closes program

Daniel trampster at gmail.com
Wed Apr 8 04:53:27 EDT 2009


You can use.
System.IO.Ports.SerialPort.GetPortNames()
to find what ports are available on your PC, just pick one

Cheers,
Daniel

Mark de Bruijn wrote:
> Would be good if you supply a example which does work anywhere, it's 
> hard to test for me, because I don't have the knowledge to get Open() 
> to work.
>
> On Wed, Apr 8, 2009 at 10:44 AM, Daniel <trampster at gmail.com 
> <mailto:trampster at gmail.com>> wrote:
>
>
>
>
>     ---------- Forwarded message ----------
>     From: Daniel <trampster at gmail.com <mailto:trampster at gmail.com>>
>     To: Mark de Bruijn <kramieb at gmail.com <mailto:kramieb at gmail.com>>
>     Date: Wed, 08 Apr 2009 20:41:18 +1200
>     Subject: Re: [Mono-list] Fwd: System.IO.SerialPort.BytesToRead
>     closes program
>     Thanks for trying but your code threw the exception on Open() not
>     on accessing BytesToRead. Most likely because you don't have a "Com4".
>
>     I do have a "Com4" and Open works it's calling BytesToRead that
>     causes my program to close.
>
>     Any more ideas?
>
>     Cheers,
>     Daniel
>
>
>     Mark de Bruijn wrote:
>
>         Compiled using gmcs on Ubuntu, getting an exception, no crash.
>         Mono C# compiler version 2.0.1.0
>         Mono JIT compiler version 2.0.1 (tarball)
>         Same results on:
>         Mono C# compiler version 2.4.0.0
>         Mono JIT compiler version 2.4 (/branches/mono-2-4/mono r130414
>         za mrt 28 17:21:49 CET 2009)
>
>         LANG=C mono --debug ./WindowsCrash.exe:
>
>         Unhandled Exception: System.IO.IOException: No such file or
>         directory
>          at System.IO.Ports.SerialPortStream.ThrowIOException ()
>         [0x00012] in
>         /build/buildd/mono-2.0.1/mcs/class/System/System.IO.Ports/SerialPortStream.cs:299
>
>          at System.IO.Ports.SerialPortStream..ctor (System.String
>         portName, Int32 baudRate, Int32 dataBits, Parity parity,
>         StopBits stopBits, Boolean dtrEnable, Boolean rtsEnable,
>         Handshake handshake, Int32 readTimeout, Int32 writeTimeout,
>         Int32 readBufferSize, Int32 writeBufferSize) [0x0001e] in
>         /build/buildd/mono-2.0.1/mcs/class/System/System.IO.Ports/SerialPortStream.cs:36
>
>          at (wrapper remoting-invoke-with-check)
>         System.IO.Ports.SerialPortStream:.ctor
>         (string,int,int,System.IO.Ports.Parity,System.IO.Ports.StopBits,bool,bool,System.IO.Ports.Handshake,int,int,int,int)
>          at System.IO.Ports.SerialPort.Open () [0x00078] in
>         /build/buildd/mono-2.0.1/mcs/class/System/System.IO.Ports/SerialPort.cs:563
>
>          at (wrapper remoting-invoke-with-check)
>         System.IO.Ports.SerialPort:Open ()
>          at WindowsCrash.Program.Main (System.String[] args) [0x00000]
>
>
>         On Tue, Apr 7, 2009 at 1:39 PM, trampster <trampster at gmail.com
>         <mailto:trampster at gmail.com> <mailto:trampster at gmail.com
>         <mailto:trampster at gmail.com>>> wrote:
>
>
>            it appears that calling System.IO.SerialPort.BytesToRead
>         closes my
>            application when runing on windows using mono 2.4. The
>         following code
>            reproduces the problem. No error message or exception seems
>         to be
>            generated
>            it just closes.
>
>
>            using System.IO.Ports;
>            using System;
>
>            namespace ConsoleApplication1
>            {
>              class Program
>              {
>                 static void Main(string[] args)
>                 {
>                    SerialPort serialPort = new SerialPort("Com4", 19200);
>                    serialPort.Open();
>                    Console.WriteLine("before");
>                    int bytesToRead = serialPort.BytesToRead;
>                    Console.WriteLine("after");
>                 }
>              }
>            }
>
>            My questions are as follows.
>            1. I'm I doing something wrong, (the code works when run on
>         dot net)
>            2. Does this work on the linux build?
>
>            I raised a bug
>         https://bugzilla.novell.com/show_bug.cgi?id=490910
>            but it is not getting any activity.
>            I am very interested in getting my coding running on mono,
>         and was
>            under the
>            impression that all this .net 2.0 stuff was implemented and
>            stable. Was I
>            wrong?
>            --
>            View this message in context:
>          
>          http://www.nabble.com/System.IO.SerialPort.BytesToRead-closes-program-tp22927258p22927258.html
>            Sent from the Mono - General mailing list archive at
>         Nabble.com.
>
>            _______________________________________________
>            Mono-list maillist  -  Mono-list at lists.ximian.com
>         <mailto:Mono-list at lists.ximian.com>
>            <mailto:Mono-list at lists.ximian.com
>         <mailto:Mono-list at lists.ximian.com>>
>            http://lists.ximian.com/mailman/listinfo/mono-list
>
>
>
>         -- 
>         Mark
>         ------------------------------------------------------------------------
>
>         _______________________________________________
>         Mono-list maillist  -  Mono-list at lists.ximian.com
>         <mailto:Mono-list at lists.ximian.com>
>         http://lists.ximian.com/mailman/listinfo/mono-list
>          
>
>
>
>
>     _______________________________________________
>     Mono-list maillist  -  Mono-list at lists.ximian.com
>     <mailto:Mono-list at lists.ximian.com>
>     http://lists.ximian.com/mailman/listinfo/mono-list
>
>
>
>
> -- 
> Mark



More information about the Mono-list mailing list