Main Site Documentation

FEZ HYDRA UARTS trouble


#1

Hi Guys,

I recently got HYDRA and I want to use two serial ports, one for XBEE socket, one for GSM module. I don’t want to use Gadgeteer, but pure NETMF. I found out that in my case only COM1 works well, but others throws ArgumentException when I try to create new instance of SerialPort.


        public static void Main()
        {
            string[] ports = new string[] { "com1", "com2", "com3", "com4" };

            foreach (var port in ports)
            {
                SerialPort serial = null;
                try
                {
                    serial = new SerialPort(port, 9600);
                    serial.Open();
                    if (serial.IsOpen)
                    {
                        Debug.Print("Port " + port + " is open!");
                    }
                    else
                    {
                        Debug.Print("Failed to open port " + port + "!");
                    }

                }
                catch (Exception ex)
                {
                    Debug.Print("Failed to open port " + port + " due exception " + ex.GetType().Name);
                    continue;
                }
                finally
                {
                    if (serial != null) serial.Dispose();
                }
            }
        }

Here is an output of this code:


Port com1 is open!
    #### 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: 0009] ####
    #### UARTTest.Program::Main [IP: 0043] ####
A first chance exception of type 'System.ArgumentException' occurred in Microsoft.SPOT.Hardware.dll
Failed to open port com2 due exception ArgumentException
    #### 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: 0009] ####
    #### UARTTest.Program::Main [IP: 0043] ####
A first chance exception of type 'System.ArgumentException' occurred in Microsoft.SPOT.Hardware.dll
Failed to open port com3 due exception ArgumentException
    #### 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: 0009] ####
    #### UARTTest.Program::Main [IP: 0043] ####
A first chance exception of type 'System.ArgumentException' occurred in Microsoft.SPOT.Hardware.dll
Failed to open port com4 due exception ArgumentException

Device info from MFDEPLOY is:


DeviceInfo:
  HAL build info: 4.1.2821.0, Microsoft Copyright (C) Microsoft Corporation.  All rig
  OEM Product codes (vendor, model, SKU): 255, 0, 65535
  Serial Numbers (module, system):
    FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
    FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
  Solution Build Info: 4.1.2821.0, Microsoft Copyright (C) Microsoft Corporation.  All rig
  AppDomains:
    default, id=1
  Assemblies:
    mscorlib,4.1.2821.0
    Microsoft.SPOT.Native,4.1.2821.0
    Microsoft.SPOT.Hardware,4.1.2821.0
    Microsoft.SPOT.Graphics,4.1.2821.0
    Microsoft.SPOT.TinyCore,4.1.2821.0
    Microsoft.SPOT.IO,4.1.2821.0
    System.IO,4.1.2821.0
    Microsoft.SPOT.Hardware.Usb,4.1.2821.0
    Microsoft.SPOT.Hardware.SerialPort,4.1.2821.0
    Microsoft.SPOT.Net,4.1.2821.0
    System,4.1.2821.0
    Microsoft.SPOT.Touch,4.1.2821.0
    Microsoft.SPOT.Ink,4.1.2821.0
    UARTTest,1.0.0.0

Thanks for any help.

Jan


#2

Jan,

I wasn’t able to reproduce your problem. This is what I got back when running your code. Are you using the latest firmware? What hardware do you have attached?

[quote]The thread ‘’ (0x2) has exited with code 0 (0x0).
Port com1 is open!
Port com2 is open!
Port com3 is open!
Port com4 is open!
The thread ‘’ (0x1) has exited with code 0 (0x0).
The program ‘[2] Micro Framework application: Managed’ has exited with code 0 (0x0).
Waiting for debug commands…
[/quote]


#3

I do not think you have the latest firmware.


#4

There was indeed a bug in an earlier firmware that enabled only com1. Bug fixed, as usual :wink:

Quite boring, though… you show a bug and GHI fix it ::slight_smile: You can’t blame them for too long. Frustrating :-[


#5

@ shanekirkbride

Please post a new topic. You are asking about Cerbuino be and this a Hydra post from a year ago. We will gladly help with a new post. :slight_smile: