Hello Everybody,
Please help me to solve the following trouble.
I want to write an application to send and receive data through com port.
I am using VC++ .Net 2003 for creating this MFC application.
I write a Function to write data on com port as follows.
Code:
void CSerialCommTesterDlg ::WriteData ()
{	
	BOOL ans;
	int length=0 ;
	
         UpdateData ();
	length = m_enter_text.GetAllocLength ();
	ans=WriteFile(hComm , &m_enter_text, length, &dwWritten, &ovlw);
	error_no = GetLastError ();
	if(GetOverlappedResult(hComm ,&ovlw,&dwWritten ,TRUE)==S_OK )
	{
		m_idc_status.Format("No of Bytes send: %d", dwWritten );
		UpdateData (FALSE);
	}
	error_no = GetLastError ();
}
I have successfully initialized com port and set the DCB.
WriteFile() function returns 0, that means it has failed.
and GetLastError returns 997, i.e. I/O pending, but in this situation dwWritten in GetOverLappedResult() is still giving me the exact no. of bytes written.
Thus I am not able to send data. Plz help

Last edited by shabbir; 11Oct2007 at 17:57.. Reason: Code block