How to call c++ code in forms 6i [message #541063] |
Fri, 27 January 2012 06:40 ![Go to next message Go to next message](/forum/theme/orafaq/images/down.png) |
![](//www.gravatar.com/avatar/1229663c86eb1a441385fe710cd9116e?s=64&d=mm&r=g) |
mughals_king
Messages: 392 Registered: January 2012 Location: pakistan
|
Senior Member |
|
|
can anyone tell how to call this c++ code by using forms 6i
To open and configure the COM port:
HANDLE hCom;
COMMTIMEOUTS lpTo;
COMMCONFIG lpCC;
char str_com[10];
unsigned short no_com = 0;
sprintf( str_com, "\\\\.\\COM%d\0", no_com+1);
hCom = CreateFile(str_com,GENERIC_READ|GENERIC_WRITE,0,NULL,
OPEN_EXISTING,FILE_FLAG_OVERLAPPED,NULL);
GetCommState( hCom, &lpCC.dcb);
/* Initialisation des parametres par defaut */
lpCC.dcb.BaudRate = CBR_9600;
lpCC.dcb.ByteSize = 8;
lpCC.dcb.StopBits = ONESTOPBIT;
lpCC.dcb.Parity = NOPARITY;
lpCC.dcb.fDtrControl = DTR_CONTROL_DISABLE;
lpCC.dcb.fRtsControl = RTS_CONTROL_DISABLE;
SetCommState( hCom, &lpCC.dcb );
GetCommTimeouts(hCom,&lpTo);
lpTo.ReadIntervalTimeout = 0;
lpTo.ReadTotalTimeoutMultiplier = 10;
lpTo.ReadTotalTimeoutConstant = 10;
lpTo.WriteTotalTimeoutMultiplier = 10;
lpTo.WriteTotalTimeoutConstant = 100;
SetCommTimeouts(hCom,&lpTo);
SetupComm(hCom,2048,2048);
To close the port :
CloseHandle(hCom);
To monitor communications events :
SetCommMask(hCom, dwEvtMask );
dwEvtMask is logical or with :
EV_BREAK, EV_CTS, EV_DSR, EV_ERR, EV_RING, EV_RLSD , EV_RXCHAR, EV_RXFLAG, EV_TXEMPTY values
and used WaitCommEvent function
BOOL WaitCommEvent(
HANDLE hFile,
LPDWORD lpEvtMask,
LPOVERLAPPED lpOverlapped
);
kindly explain step by step
thanks
[Updated on: Fri, 27 January 2012 06:44] Report message to a moderator
|
|
|
|