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);
#endregion
public static void Main()
{
PuertoCOM = new SerialPort("COM2", 9600);
PuertoCOM.DataReceived += new SerialDataReceivedEventHandler(PuertoCOM_DataReceived);
PuertoCOM.Open();
LED = new OutputPort((Cpu.Pin)FEZ_Pin.Digital.LED, false);
InterruptPort BotonEntrada =
new InterruptPort((Cpu.Pin)FEZ_Pin.Interrupt.LDR, true,
Port.ResistorMode.PullUp,
Port.InterruptMode.InterruptEdgeHigh);
InterruptPort Xbeeindication =
new InterruptPort((Cpu.Pin)FEZ_Pin.Interrupt.UEXT9, true,
Port.ResistorMode.PullUp,
Port.InterruptMode.InterruptEdgeBoth);
Xbeeindication.OnInterrupt += new NativeEventHandler(xbeeindication_Interrption);
BotonEntrada.OnInterrupt += new NativeEventHandler(BotonEntrada_Interrption);
Thread.Sleep(Timeout.Infinite);
}
public static void MiThread()
{
while (true)
{
mixbee.Make_API_Parametro_remoto("m1", mixbee.Byte_ToHex(mixbee.ValoresIO[1].Canal_Analogo_0), 1);
mixbee.Escribir_Puerto(PuertoCOM);
if (mixbee.ValoresIO[1].Canal_Analogo_0 > 512)
{
mixbee.Make_API_Parametro_remoto("p2", "5", 1);
mixbee.Escribir_Puerto(PuertoCOM);
}
else
{
mixbee.Make_API_Parametro_remoto("p2", "4", 1);
mixbee.Escribir_Puerto(PuertoCOM);
}
Thread.Sleep(1500);
}
}
public static void xbeeindication_Interrption(uint puerto, uint estado, DateTime hora)
{
LED.Write(estado == 0);
}
static void PuertoCOM_DataReceived(object sender, SerialDataReceivedEventArgs e)
{
try
{
mixbee.Lee_Puerto(PuertoCOM);
}
catch { }
}
public static void BotonEntrada_Interrption(uint puerto, uint estado, DateTime hora)
{
if (seleccion == 0)
{
mixbee.Make_API_Parametro("nd", "");
mixbee.Escribir_Puerto(PuertoCOM);
}
if (seleccion == 1)
{
mixbee.Make_API_Parametro_remoto("ir", "3e8", 1);
mixbee.Escribir_Puerto(PuertoCOM);
Mithreadhandler.Start();
}
if (seleccion == 2)
{
mixbee.Make_API_Parametro_remoto("fr", "", 1);
mixbee.Escribir_Puerto(PuertoCOM);
Mithreadhandler.Abort();
}
if (seleccion >= 2)
seleccion = 0;
else
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
;D