Inputting commands to XBEE using VC++

K

Thread Starter

kaposama

Currently I have a XBEE (Zigbee) circuit setup, and it is connected to the computer through the com port. Basically I require some help on the VC++ coding so that using VC++ I am able to input commands to the XBEE device. My aim is to communicate with the help of 2 Zigbee devices connected to 2 different computers. I've already done the open port part, which I will list below.
<pre>
#include <windows.h>
#include <stdio.h>

int main(int argc, char *argv[])
{
DCB dcb;
HANDLE hCom;
BOOL fSuccess;
char *pcCommPort = "COM2";

hCom = CreateFile( pcCommPort,
GENERIC_READ | GENERIC_WRITE,
0, // must be opened with exclusive-access
NULL, // no security attributes
OPEN_EXISTING, // must use OPEN_EXISTING
0, // not overlapped I/O
NULL // hTemplate must be NULL for comm devices
);

if (hCom == INVALID_HANDLE_VALUE)
{
// Handle the error.
printf ("CreateFile failed with error %d.\n", GetLastError());
return (1);
}

// Build on the current configuration, and skip setting the size
// of the input and output buffers with SetupComm.

fSuccess = GetCommState(hCom, &dcb);

if (!fSuccess)
{
// Handle the error.
printf ("GetCommState failed with error %d.\n", GetLastError());
return (2);
}


dcb.BaudRate = 9600; // set the baud rate
dcb.ByteSize = 8; // data size, xmit, and rcv
dcb.Parity = NOPARITY; // no parity bit
dcb.StopBits = ONESTOPBIT; // one stop bit

fSuccess = SetCommState(hCom, &dcb);

if (!fSuccess)
{
// Handle the error.
printf ("SetCommState failed with error %d.\n", GetLastError());
return (3);
}

printf ("Serial port %s successfully reconfigured.\n", pcCommPort);
return (0);
</pre>
I am stuck with the inputting commands portion of the source codes. I hope I am able to get some help on VC++ here. You may contact me through my e-mail: black86_116 at hotmail. com
 
Top