NETMF - Exception : invalid serial port name

Hi,

Awaiting my Spider and Reaper boards.

Meanwhile, tried a small serial port read / write program with NETMF.
Referred to this doc. https://www.ghielectronics.com/docs/15/uart-serial

VS 2013, .NETMF 4.3 (QFE2), Gadgeteer core, GHI NETMF SDK 2015 R1 Pre-release 4 - all installed.
A simple debug write is running ok.

Now tried this code :


public static void Main()
{
Debug.Print(“HELLO THERE, MONKEY BOY!”);

        //int txCount;
        SerialPort liftPort = new SerialPort("COM3,115200");
        string txData = "HELLO THERE, MONKEY BOY!\r\n";
        byte[] txBuf = Encoding.UTF8.GetBytes(txData);
        int rxCount;
        int rxReadBytes;

        liftPort.Open();
        liftPort.Write(txBuf, 0, txData.Length);
        Thread.Sleep(100);

        rxCount = liftPort.BytesToRead;
        if (rxCount > 0)
        {
            byte[] rxBuf = new byte[rxCount];
            rxReadBytes = liftPort.Read(rxBuf, 0, rxCount);
            Debug.Print(rxBuf.ToString());
        }

    }

Debug transport : Emulator, Device = Microsoft Emulator.

An exception : Invalid serial port name, is thrown,
at this line : SerialPort liftPort = new SerialPort(“COM3,115200”);
Note : I have a working COM3 in my PC.

Can NETMF UART program be run with Emulator like this ?

Please correct.

I believe you want
SerialPort liftPort = new SerialPort(“COM3”,115200);

not SerialPort liftPort = new SerialPort(“COM3,115200”);

@ willgeorge - Is it really me ? or the hooch i had yesterday !
Thanks willgeorge.

In follow up to the above, now i get this exception :

Step into: Stepping over non-user code ‘System.IO.Ports.SerialPort.SerialPort’
#### Exception System.ArgumentException - 0xfd000000 (1) ####
#### Message:
#### Microsoft.SPOT.Hardware.NativeEventDispatcher::.ctor [IP: 0000] ####
#### System.IO.Ports.SerialPort::.ctor [IP: 0030] ####
#### System.IO.Ports.SerialPort::.ctor [IP: 000d] ####
#### NETMFBook.Program::Main [IP: 000e] ####
A first chance exception of type ‘System.ArgumentException’ occurred in Microsoft.SPOT.Hardware.dll
An unhandled exception of type ‘System.ArgumentException’ occurred in Microsoft.SPOT.Hardware.dll

Thanks.

Remember that the COM port here is not the same port as the COM port on the pc side. Try COM1 in your code and you can check the menus in the emulator to see the mapping