Please help me,
I follow the tutorials,but it does not work.
The panda can’t receive anything.
#1 for receiving use panda
using System;
using System.Threading;
using System.Text;
using System.IO.Ports;
using Microsoft.SPOT;
using GHIElectronics.NETMF.FEZ;
using Microsoft.SPOT.Hardware;
using GHIElectronics.NETMF.Hardware;
namespace DominoXbee
{
public class Program
{
public static int read_count = 0;
public static byte[] rx_data = new byte[10];
public static byte[] tx_data;
public static SerialPort UART = null;
public static void Main()
{
UART = new SerialPort("COM1", 115200);
UART.Open();
UART.DataReceived += new SerialDataReceivedEventHandler(UART_DataReceived);
Thread.Sleep(Timeout.Infinite);
}
private static void UART_DataReceived(object sender, SerialDataReceivedEventArgs e)
{
// read the data
read_count = UART.Read(rx_data, 0, rx_data.Length);
if (read_count != 6)
{
// we sent 6 so we should have 6 back
Debug.Print("Wrong size: " + read_count.ToString());
}
else
{
Debug.Print("Perfect data!");
String receivedDataAsString = new String(Encoding.UTF8.GetChars(rx_data));
Debug.Print(receivedDataAsString);
}
Thread.Sleep(100);
}
}
}
#2 for sending use chipworkx
using System;
using System.Threading;
using System.Text;
using System.IO.Ports;
using Microsoft.SPOT;
using Microsoft.SPOT.Hardware;
using GHIElectronics.NETMF.Hardware;
namespace CobraXbee
{
public class Program
{
public static SerialPort UART = null;
public static byte[] tx_data;
public static void Main()
{
UART = new SerialPort("COM2", 115200);
UART.Open();
tx_data = Encoding.UTF8.GetBytes("Foekie");
while (true)
{
// flush all data
UART.Flush();
Debug.Print("Writing data");
// send some data
UART.Write(tx_data, 0, tx_data.Length);
// wait to make sure data is transmitted
Thread.Sleep(1000);
}
}
}
}