add different logging to send & recieve messages so we can see the messages better in debug version
authorChad Peckham <chad.peckham@nokia.com>
Mon, 21 Sep 2009 17:06:15 -0500
changeset 506 44dbbc3220b8
parent 505 6de8d9cfdda1
child 507 f815991516d2
add different logging to send & recieve messages so we can see the messages better in debug version
connectivity/com.nokia.tcf/native/TCFNative/TCFCommTCP/TcpComm.cpp
connectivity/com.nokia.tcf/native/TCFNative/TCFCommTCP/TcpComm.h
--- a/connectivity/com.nokia.tcf/native/TCFNative/TCFCommTCP/TcpComm.cpp	Mon Sep 21 17:03:45 2009 -0500
+++ b/connectivity/com.nokia.tcf/native/TCFNative/TCFCommTCP/TcpComm.cpp	Mon Sep 21 17:06:15 2009 -0500
@@ -521,7 +521,8 @@
 					}
 #ifdef _DEBUG
 					int reallen = fullMessageLength;
-					if (reallen > 80) reallen = 80;
+					if (reallen > 100) reallen = 100;
+					bool wasAlnum = false;
 					char msg[6];
 					msg[0] = '\0';
 
@@ -531,13 +532,25 @@
 						sTcpLogMsg[0] = '\0';
 						for (int i = 0; i < reallen; i++)
 						{
-							if (isalnum(ptr[i]))
+							if (isgraph/*isalnum*/(ptr[i]) && i > protocolHeaderLength)
 							{
+								// string printables next to each other
 								sprintf(msg, "%c", ptr[i]);
+								wasAlnum = true;
 							}
 							else
 							{
-								sprintf(msg, "%02.2x ", ptr[i]);
+								if (wasAlnum)
+								{
+									// break from last alnum char
+									sprintf(msg, " %02.2x ", ptr[i]);
+								}
+								else
+								{
+									// no break
+									sprintf(msg, "%02.2x ", ptr[i]);
+								}
+								wasAlnum = false;
 							}
 							strcat(sTcpLogMsg, msg);
 						}
@@ -679,16 +692,53 @@
 		} // end while
 		COMMLOGS("CTcpComm::SendDataToPort send done\n");
 #ifdef _DEBUG
+		DWORD protocolHeaderLength = m_Protocol->GetHeaderLength();
 		BYTE* ptr = (BYTE*)inData;
-		long numBytes = (inSize > 20) ? 20 : inSize;
-		char msg[200];
-		sprintf(msg, "CTcpComm::SendDataToPort data = ");
-		for (int i = 0; i < numBytes; i++)
+		int reallen = inSize;
+		if (reallen > 100) reallen = 100;
+		bool wasAlnum = false;
+		char msg[6];
+		msg[0] = '\0';
+
+		sTcpLogMsgSend[0] = '\0';
+		if (reallen > 0)
 		{
-			sprintf(msg, "%s %02.2x", msg, ptr[i]);
+			sTcpLogMsgSend[0] = '\0';
+			for (int i = 0; i < reallen; i++)
+			{
+				if (isgraph/*isalnum*/(ptr[i]) && i > protocolHeaderLength)
+				{
+					// string printables next to each other
+					sprintf(msg, "%c", ptr[i]);
+					wasAlnum = true;
+				}
+				else
+				{
+					if (wasAlnum)
+					{
+						// break from last alnum char
+						sprintf(msg, " %02.2x ", ptr[i]);
+					}
+					else
+					{
+						// no break
+						sprintf(msg, "%02.2x ", ptr[i]);
+					}
+					wasAlnum = false;
+				}
+				strcat(sTcpLogMsgSend, msg);
+			}
 		}
-		sprintf(msg, "%s\n", msg);
-		COMMLOGS(msg);
+//		BYTE* ptr = (BYTE*)inData;
+//		long numBytes = (inSize > 20) ? 20 : inSize;
+//		char msg[200];
+//		sprintf(msg, "CTcpComm::SendDataToPort data = ");
+//		for (int i = 0; i < numBytes; i++)
+//		{
+//			sprintf(msg, "%s %02.2x", msg, ptr[i]);
+//		}
+//		sprintf(msg, "%s\n", msg);
+		COMMLOGA2("CTcpComm::SendDataToPort len=%d msg=%s\n", inSize, sTcpLogMsgSend);
 #endif
 	}
 
--- a/connectivity/com.nokia.tcf/native/TCFNative/TCFCommTCP/TcpComm.h	Mon Sep 21 17:03:45 2009 -0500
+++ b/connectivity/com.nokia.tcf/native/TCFNative/TCFCommTCP/TcpComm.h	Mon Sep 21 17:06:15 2009 -0500
@@ -67,6 +67,7 @@
 	WSAEVENT m_hSocketEvent; 
 	DWORD m_pPeekBuffer;
 	char sTcpLogMsg[3000];
+	char sTcpLogMsgSend[3000];
 };
 
 #endif // !defined(AFX_TCPCOMM_H__69657421_6D37_497A_A377_12E71365EDAB__INCLUDED_)