Home/Support/Support Forum/xbee packet transmission using c#.Net
Welcome to Digi Forum, where you can ask questions and receive answers from other members of the community.

xbee packet transmission using c#.Net

0 votes
hi
I am not very familiar to the programming . I am using xbee series 1 pro and set 1 xbee as an transmitter and other as an receiver ..I have design and check the packets which toggle the op pin of receiver ..and they are working perfectly fine
was trying to put D4 pin high
Now i want to transmit these packets using c# coding ..
Code:
namespace xbee { class Program { static SerialPort port = new SerialPort("COM9", 9600, Parity.None, 8, StopBits.One); static void Main(string[] args) { // Instantiate the communications // port with some basic settings port.DataReceived += new SerialDataReceivedEventHandler(port_DataReceived); // Open the port for communications port.Open(); // Write a string port.Write("+++"); System.Threading.Thread.Sleep(1000); // port.ReadLine(); //port.WriteLine("AT" + Convert.ToChar(13)); //System.Threading.Thread.Sleep(1000); Byte[] b = new byte[]{0x7E, 0x00, 0x10, 0x17, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF , 0xFF , 0xFE , 0x02 , 0x44 , 0x34 , 0x05 , 0x6D}; port.Write(b,0,b.Length); System.Threading.Thread.Sleep(1000); port.Write("~�������ÿÿ&#xFF FE;D4&#x6D"+Convert.ToChar(13)); //port.Write("0x7E00101701000000000000FFFFFFFE024434056D"+Convert.ToChar(13)); System.Threading.Thread.Sleep(1000); //port.ReadLine(); //Console.WriteLine(port.ReadLine()); // port.Write(new byte[] {0x0A, 0xE2, 0xFF}, 0, 3); Console.WriteLine("Press any key to close this app.."); Console.ReadLine(); // Close the port port.Close(); } static void port_DataReceived(object sender, SerialDataReceivedEventArgs e) { Console.WriteLine(e.EventType.ToString()); Console.WriteLine(port.ReadExisting()); // Console.WriteLine((char)port.ReadByte()); } } }
I am getting CHARS
OK
Press any key to close this app..
IN RESPONCE
the packet is not transferring .. did everything i could :(
asked Dec 2, 2013 in USB by sumaira New to the Community (0 points)

Please log in or register to answer this question.

1 Answer

0 votes
When I first started with the xbees, I had trouble getting the DataReceived event to fire. You might try:

1. Giving your port a Handshake value other than none. (RequestToSend)

or

2. For now, just do a simple serial port read and write results to console within your Main after you Write.

I'd try #2 first, actually.
answered Dec 4, 2013 by gormenghast New to the Community (1 point)
...