connectivity/com.nokia.tcf/native/TCFNative/TCFCommSerial/RealSerialComm.cpp
changeset 1473 6c45b7c9cdac
parent 477 cedd5978e2bc
child 1481 c7f22cc57d44
--- a/connectivity/com.nokia.tcf/native/TCFNative/TCFCommSerial/RealSerialComm.cpp	Tue Jun 15 10:21:51 2010 -0500
+++ b/connectivity/com.nokia.tcf/native/TCFNative/TCFCommSerial/RealSerialComm.cpp	Tue Jun 15 16:19:30 2010 -0500
@@ -366,7 +366,7 @@
 long CRealSerialComm::ClosePort()
 {
 	COMMLOGOPEN();
-	COMMLOGS("CRealSerialComm::ClosePort\n");
+	COMMLOGA1("CRealSerialComm::ClosePort connected=%d\n", IsConnected());
 
 	long err = TCAPI_ERR_NONE;
 
@@ -443,8 +443,9 @@
 		//   and there was some kind of error
 		if (lclNumBytes != inSize)
 		{
+			m_lastCommError = 0;
 			COMMLOGOPEN();
-			COMMLOGA3("CRealSerialComm::SendDataToPort WriteFile not all bytes sent: lclNumBytes=%d inSize=%d err=%d\n", lclNumBytes, inSize, GetLastError());
+			COMMLOGA3("CRealSerialComm::SendDataToPort WriteFile not all bytes sent: lclNumBytes=%d inSize=%d err=%d\n", lclNumBytes, inSize, m_lastCommError);
 			COMMLOGCLOSE();
 
 			COMSTAT lclComStat;
@@ -468,7 +469,7 @@
 					m_lastCommError = lclErrorFlags;
 					err = TCAPI_ERR_COMM_ERROR;
 					COMMLOGOPEN();
-					COMMLOGA1("CRealSerialComm::SendDataToPort ClearCommError succeeded lclErrorFlags=%d\n", m_lastCommError);
+					COMMLOGA1("CRealSerialComm::SendDataToPort ClearCommError succeeded lclErrorFlags=%d\n", lclErrorFlags);
 					COMMLOGCLOSE();
 				}
 				else
@@ -477,7 +478,7 @@
 					//  therefore, since we are not doing overlapped I/O, this is an error.
 					err = TCAPI_ERR_COMM_ERROR;
 					COMMLOGOPEN();
-					COMMLOGS("CRealSerialComm::SendDataToPort ClearCommError succeeded lclErrorFlags=0\n");
+					COMMLOGA1("CRealSerialComm::SendDataToPort ClearCommError succeeded lclErrorFlags=0 err=%d\n", m_lastCommError);
 					COMMLOGCLOSE();
 //					DUMPCOMSTAT(&lclComStat);
 				}
@@ -530,6 +531,9 @@
 //	Sleep(1);
 	if (!ClearCommError( m_hSerial, &lclErrorFlags, &lclComStat ))
 	{
+		if (!IsConnected())
+			return TCAPI_ERR_MEDIA_NOT_OPEN;
+
 		m_lastCommError = GetLastError();
 		err = TCAPI_ERR_COMM_ERROR;