connectivity/com.nokia.tcf/native/TCFNative/TCFCommTCP/TcpComm.cpp
changeset 506 44dbbc3220b8
parent 478 2d6f57ea6ce2
equal deleted inserted replaced
505:6de8d9cfdda1 506:44dbbc3220b8
   519 						pConn->NotifyClientsCommError(err, false, 0);
   519 						pConn->NotifyClientsCommError(err, false, 0);
   520 						err = TCAPI_ERR_NONE;
   520 						err = TCAPI_ERR_NONE;
   521 					}
   521 					}
   522 #ifdef _DEBUG
   522 #ifdef _DEBUG
   523 					int reallen = fullMessageLength;
   523 					int reallen = fullMessageLength;
   524 					if (reallen > 80) reallen = 80;
   524 					if (reallen > 100) reallen = 100;
       
   525 					bool wasAlnum = false;
   525 					char msg[6];
   526 					char msg[6];
   526 					msg[0] = '\0';
   527 					msg[0] = '\0';
   527 
   528 
   528 					sTcpLogMsg[0] = '\0';
   529 					sTcpLogMsg[0] = '\0';
   529 					if (reallen > 0)
   530 					if (reallen > 0)
   530 					{
   531 					{
   531 						sTcpLogMsg[0] = '\0';
   532 						sTcpLogMsg[0] = '\0';
   532 						for (int i = 0; i < reallen; i++)
   533 						for (int i = 0; i < reallen; i++)
   533 						{
   534 						{
   534 							if (isalnum(ptr[i]))
   535 							if (isgraph/*isalnum*/(ptr[i]) && i > protocolHeaderLength)
   535 							{
   536 							{
       
   537 								// string printables next to each other
   536 								sprintf(msg, "%c", ptr[i]);
   538 								sprintf(msg, "%c", ptr[i]);
       
   539 								wasAlnum = true;
   537 							}
   540 							}
   538 							else
   541 							else
   539 							{
   542 							{
   540 								sprintf(msg, "%02.2x ", ptr[i]);
   543 								if (wasAlnum)
       
   544 								{
       
   545 									// break from last alnum char
       
   546 									sprintf(msg, " %02.2x ", ptr[i]);
       
   547 								}
       
   548 								else
       
   549 								{
       
   550 									// no break
       
   551 									sprintf(msg, "%02.2x ", ptr[i]);
       
   552 								}
       
   553 								wasAlnum = false;
   541 							}
   554 							}
   542 							strcat(sTcpLogMsg, msg);
   555 							strcat(sTcpLogMsg, msg);
   543 						}
   556 						}
   544 					}
   557 					}
   545 #endif
   558 #endif
   677 				bytesRemaining -= nSent;
   690 				bytesRemaining -= nSent;
   678 			}
   691 			}
   679 		} // end while
   692 		} // end while
   680 		COMMLOGS("CTcpComm::SendDataToPort send done\n");
   693 		COMMLOGS("CTcpComm::SendDataToPort send done\n");
   681 #ifdef _DEBUG
   694 #ifdef _DEBUG
       
   695 		DWORD protocolHeaderLength = m_Protocol->GetHeaderLength();
   682 		BYTE* ptr = (BYTE*)inData;
   696 		BYTE* ptr = (BYTE*)inData;
   683 		long numBytes = (inSize > 20) ? 20 : inSize;
   697 		int reallen = inSize;
   684 		char msg[200];
   698 		if (reallen > 100) reallen = 100;
   685 		sprintf(msg, "CTcpComm::SendDataToPort data = ");
   699 		bool wasAlnum = false;
   686 		for (int i = 0; i < numBytes; i++)
   700 		char msg[6];
   687 		{
   701 		msg[0] = '\0';
   688 			sprintf(msg, "%s %02.2x", msg, ptr[i]);
   702 
   689 		}
   703 		sTcpLogMsgSend[0] = '\0';
   690 		sprintf(msg, "%s\n", msg);
   704 		if (reallen > 0)
   691 		COMMLOGS(msg);
   705 		{
       
   706 			sTcpLogMsgSend[0] = '\0';
       
   707 			for (int i = 0; i < reallen; i++)
       
   708 			{
       
   709 				if (isgraph/*isalnum*/(ptr[i]) && i > protocolHeaderLength)
       
   710 				{
       
   711 					// string printables next to each other
       
   712 					sprintf(msg, "%c", ptr[i]);
       
   713 					wasAlnum = true;
       
   714 				}
       
   715 				else
       
   716 				{
       
   717 					if (wasAlnum)
       
   718 					{
       
   719 						// break from last alnum char
       
   720 						sprintf(msg, " %02.2x ", ptr[i]);
       
   721 					}
       
   722 					else
       
   723 					{
       
   724 						// no break
       
   725 						sprintf(msg, "%02.2x ", ptr[i]);
       
   726 					}
       
   727 					wasAlnum = false;
       
   728 				}
       
   729 				strcat(sTcpLogMsgSend, msg);
       
   730 			}
       
   731 		}
       
   732 //		BYTE* ptr = (BYTE*)inData;
       
   733 //		long numBytes = (inSize > 20) ? 20 : inSize;
       
   734 //		char msg[200];
       
   735 //		sprintf(msg, "CTcpComm::SendDataToPort data = ");
       
   736 //		for (int i = 0; i < numBytes; i++)
       
   737 //		{
       
   738 //			sprintf(msg, "%s %02.2x", msg, ptr[i]);
       
   739 //		}
       
   740 //		sprintf(msg, "%s\n", msg);
       
   741 		COMMLOGA2("CTcpComm::SendDataToPort len=%d msg=%s\n", inSize, sTcpLogMsgSend);
   692 #endif
   742 #endif
   693 	}
   743 	}
   694 
   744 
   695 	COMMLOGCLOSE();
   745 	COMMLOGCLOSE();
   696 	return err;
   746 	return err;