[Mono-dev] SerialPort.Open() problem: MonoDevelop indicate it is not member of SerialPort Class

Hoe-Phuan Ng avtinc2000 at gmail.com
Sun Apr 8 17:17:02 UTC 2012


I have just installed Ubuntu 11.10 and is using the MonoDevelop IDE.
Mono version on the PC is 2.10.

Here is my serial port on Ubuntu 11.10.

user at test-820:~$ dmesg | grep tty
[    0.000000] console [tty0] enabled
[    0.409804] serial8250: ttyS0 at I/O 0x3f8 (irq = 4) is a 16550A
[    0.806287] 00:0c: ttyS0 at I/O 0x3f8 (irq = 4) is a 16550A

My serial port is not connected to anything.
I am just going to run some sample code to check out serial port support on
Mono.

The equivalent framework on mono Develop IDE is set for .NET 3.5, under
MonoDevelop's project options-> Build->General-> Runtime version selected
as : "mono / .NET 3.5"

Then I tried THIS EXAMPLE:
http://www.mono-project.com/HowToSystemIOPorts

Here is the code with near zero changes:

using System;
using System.IO.Ports;

namespace TestSerialPort
{
    class SerialPortTest
    {
        public static void Main (string[] args)
        {
            Console.WriteLine ("Hello World!");
            SerialPortTest myTest = new SerialPortTest();
            myTest.Test();
        }
    private SerialPort mySerial;

    // Constructor
    public SerialPortTest()
    {
    }

    public void Test()
    {
        if (mySerial != null)
            if (mySerial.IsOpen)
                mySerial.Close();

        mySerial = new SerialPort("/dev/ttyS0", 38400);
        mySerial.Open();
        mySerial.ReadTimeout = 400;
        SendData("ATI3\r");

                // Should output some information about your modem firmware
        Console.WriteLine(ReadData());
    }

    public string ReadData()
    {
        byte tmpByte;
        string rxString = "";

        tmpByte = (byte) mySerial.ReadByte();

        while (tmpByte != 255) {
            rxString += ((char) tmpByte);
            tmpByte = (byte) mySerial.ReadByte();
        }

        return rxString;
    }

    public bool SendData(string Data)
    {
        mySerial.Write(Data);
        return true;
    }

    }
}


Here is what I got when I ran the Debugger as well as the Soft Debugger:
( not sure why we have two debugger.... anyone know why?).

I ran the code tho this line with a breakpoint:
mySerial.Open();

When I hover the mouse button I see this pop-up display:
mySerial.Open();  Unknown member : Open

Why is is telling me Open() is not a member of SerialPort class?

This is not making sense.

Please advise.

Cheers.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.ximian.com/pipermail/mono-devel-list/attachments/20120408/0360fcd2/attachment.html>


More information about the Mono-devel-list mailing list