Cerbuino Xbee and Uart Problem

Dear community!

I’m new in .NETMF and Gadgeteer, but the few hours I spent, were very interesting and funny. I love this Plug&Play system :smiley:

I’m planning to build a Robot. I used some parts of the code from this project: http://www.tinyclr.com/forum/topic?id=9761

I have the Xbee Module connected on the XBee socket on my Cerbuino Bee. And now I want to use the UART on the Arduino headers.

The problem is that I get the following error when trying to run the programm:

[quote]A first chance exception of type ‘System.InvalidOperationException’ occurred in Microsoft.SPOT.Hardware.dll
A first chance exception of type ‘System.InvalidOperationException’ occurred in Microsoft.SPOT.Hardware.SerialPort.dll
An unhandled exception of type ‘System.InvalidOperationException’ occurred in Microsoft.SPOT.Hardware.SerialPort.dll[/quote]

After hours of troubleshooting, I found out that the error only occurs when I use the Xbee Module AND the UART.

Here’s a snippet of my code:

 
private WiFlyGSX wifiBoard;
SerialPort servoUart;

 void ProgramStarted()
        {
            Debug.Print("Program Started");

            servoUart = new SerialPort("COM1", 9600);
            servoUart.Open();

            wifiBoard = new WiFlyGSX();
            ServoTest();
         }

The error occurs in the Line ‘wifiBoard = new WiFlyGSX()’
If I initialize the wifi board before the Uart , than the error occurs on ‘servoUart = new SerialPort(“COM1”, 9600);’

I tried the Uart seperately in another project and it worked.

Any suggestions =/ ?

Regards, Dominik

Hi Dominik, Welcome :slight_smile:

Are both your devices connected to the same Com port?

Can you show a diagram on how you are connecting them?

Thank you for your reply!

I attached a simple image to visualize the problem.

Hope this helps!

What code are you using for the WiFlyGSX ?

The Assembly is Toolbox.NETMF.Hardware.WiFlyGSX.dll, v4.0.30319

And the code I posted above is the only Code that runs till that error occurs.

The default com port for that is com1…
You need to specify a different Com port.

Oh I see!

Thank you very very much for your help Justin! :smiley:

Cool - have fun :slight_smile:

It’s not as easy as I thought =/
I cant assign COM2 to the wifi board, because it ends in an endless loop.
The code would be:

private WiFlyGSX wifiBoard;
SerialPort servoUart;
 
 void ProgramStarted()
        {
            Debug.Print("Program Started");
 
            servoUart = new SerialPort("COM1", 9600);
            servoUart.Open();
 
            wifiBoard = new WiFlyGSX("COM2");
            ServoTest();
         }

So the wifi module has to be assigned to COM1.
The only option is to use the second UART on COM2, but I wont do that because I need the Gadgeteer socket.

I only need to send data (to a SSC-32 servo controller), is there a way to use a Soft UART or something else?
Or maybe a better solution?

think it’s Com3 on the headers

When I use it with COM3, i get following errors:

A first chance exception of type ‘System.InvalidOperationException’ occurred in Microsoft.SPOT.Hardware.dll
A first chance exception of type ‘System.InvalidOperationException’ occurred in Microsoft.SPOT.Hardware.SerialPort.dll
An unhandled exception of type ‘System.InvalidOperationException’ occurred in Microsoft.SPOT.Hardware.SerialPort.dll

the code is:

private WiFlyGSX wifiBoard;
SerialPort servoUart;
 
 void ProgramStarted()
        {
            Debug.Print("Program Started");
 
            servoUart = new SerialPort("COM3", 9600);
            servoUart.Open();
 
            wifiBoard = new WiFlyGSX();
            ServoTest();
         }

dominik38 - what kind of “gadget” you got connected to your avatar? Come on, dude.

Kids will be kids…

Doesn’t look like there will be kids.

:smiley: If there were a caption, I think the guy is saying “where is it??? I know it’s here somewhere!”

Sorry for the circumstances, I changed my avatar.

Hallo :smiley:
Ich komm aus dem 22. :wink:
Schön, dass jemand aus der Umgebung hier ist :smiley: