Main Site Documentation

Build applications that work continuously energized without entering debug mode


well this is an issue that I have been a little confused.

I have an application to comunicate to an xbee module and when i press the pre-configurated LDR button to work as an interruption port i send an api command to find all the xbee modules in the network.

Then all the data is stored in structures so i can choose by index an xbee to send it commands.

My problem comes when i try to test my application but not through the VS2010 (F5 debug mode). It is only powering the panda board.

I press the LDR button and nothing happens.
Here is the full code:

using System;
using System.Text;
using System.IO.Ports;
using System.Threading;
using XBee;                 //this is my xbee class
using Microsoft.SPOT;
using Microsoft.SPOT.Hardware;
using GHIElectronics.NETMF.FEZ;
namespace FEZ_Panda_Application1
    public class Program
        #region Variables del proyecto
        static OutputPort LED;
        static SerialPort PuertoCOM;
        static DigiMesh mixbee = new DigiMesh();
        static int seleccion = 0;
        static Thread Mithreadhandler = new Thread(MiThread);
        public static void Main()
            PuertoCOM = new SerialPort("COM2", 9600);
            PuertoCOM.DataReceived += new SerialDataReceivedEventHandler(PuertoCOM_DataReceived);
            LED = new OutputPort((Cpu.Pin)FEZ_Pin.Digital.LED, false);
            InterruptPort BotonEntrada =
                new InterruptPort((Cpu.Pin)FEZ_Pin.Interrupt.LDR, true,
            InterruptPort Xbeeindication =
                new InterruptPort((Cpu.Pin)FEZ_Pin.Interrupt.UEXT9, true,
            Xbeeindication.OnInterrupt += new NativeEventHandler(xbeeindication_Interrption);
            BotonEntrada.OnInterrupt += new NativeEventHandler(BotonEntrada_Interrption); 
        public static void MiThread()
            while (true)
                mixbee.Make_API_Parametro_remoto("m1", mixbee.Byte_ToHex(mixbee.ValoresIO[1].Canal_Analogo_0), 1);
                if (mixbee.ValoresIO[1].Canal_Analogo_0 > 512)
                    mixbee.Make_API_Parametro_remoto("p2", "5", 1);
                    mixbee.Make_API_Parametro_remoto("p2", "4", 1);
        public static void xbeeindication_Interrption(uint puerto, uint estado, DateTime hora)
            LED.Write(estado == 0);
        static void PuertoCOM_DataReceived(object sender, SerialDataReceivedEventArgs e)
            catch { }
        public static void BotonEntrada_Interrption(uint puerto, uint estado, DateTime hora)
            if (seleccion == 0)
                mixbee.Make_API_Parametro("nd", "");
            if (seleccion == 1)
                mixbee.Make_API_Parametro_remoto("ir", "3e8", 1);
            if (seleccion == 2)
                mixbee.Make_API_Parametro_remoto("fr", "", 1);
            if (seleccion >= 2)
                seleccion = 0;
                seleccion += 1;

in the “BotonEntrada_Interrption” function after i found all the xbee modules i send a “ir” command to get data from an specific xbee.
This is how i know all works fine because i have leds indicators.
This is in debug, but in the other hand (without debug) nothing happens, the leds don’t light.

i need a way to make sure my applications are made to considerate that point.
thanks in advance


Keep in mind that everything is slower under the debugger.


please i really need to find where’s my problem :o
some help ? :slight_smile:


You will have to add lots of Debug.Print statements.

You can see debug output via the MFDeploy tool if I remember correctly. That way you are not in debug mode, but you can see what is going on.


ok i’ll try it. it seems to be a great way to know what it’s happend.
one more question, do you have maybe a link to see how to use the MFDeploy? ;D


well i already check the MFDeploy.
i connect my device via (F5) and push the LDR button from my panda to run the code that makes the api command and i can see that the command was sent, but there’s no answer from the xbee module.


I know this is snot easy to know but for some reason you can’t open the port after you subscribe to the event. It has to be before.

This is from our GPS driver, see comments in it

static public void Initialize()
                _port = new SerialPort("COM2", 19200, Parity.None, 8, StopBits.One);
                _port.ReadTimeout = 0;
                _port.ErrorReceived += new SerialErrorReceivedEventHandler(_port_ErrorReceived);
                _port.Open();// If you open the port after you set the event you will endup with problems
                _port.DataReceived += new SerialDataReceivedEventHandler(_port_DataReceived);


oohhh my god, you are so great, a 3 weeks problems :’(

it was maybe a basic issue but if you don’t know things like set the event correctly, it can be a big problem.

Thank you so much for your help Gus ;D