Friday, May 28, 2010

SERIAL PORT COMMUNICATION(USB)

#define STRICT
#include

#include

#include "Serial.h"


int WINAPI _tWinMain
(
HINSTANCE /*hInst*/,
HINSTANCE /*hInstPrev*/,
LPTSTR /*lptszCmdLine*/,
int /*nCmdShow*/
)
{
CSerial serial;

// Attempt to open the serial port (COM1)

serial.Open(_T("COM1"));

// Setup the serial port (9600,N81) using hardware handshaking

serial.Setup(CSerial::EBaud9600,CSerial::EData8,CSerial::EParNone,CSerial::EStop1);
serial.SetupHandshaking(CSerial::EHandshakeHardware);

// The serial port is now ready and we can send/receive data. If

// the following call blocks, then the other side doesn't support

// hardware handshaking.

serial.Write("Hello world");

// Close the port again

serial.Close();
return 0;
}

No comments:

Post a Comment

do u hav any doubts just mail us.our team will find the solution for it and we will clarify it as soon.



regards;
S-TECHNOLOGIES team