Создайте одну строку перед использованием макроса TRACE
.
byMsgLen = pMsg[DEV_LEN_OFFSET] + sizeof(devPktHead_t) + sizeof(devPktTail_t);
cmd = pMsg[DEV_CMD_MSB_OFFSET];
cmd <<= 8;
cmd |= pMsg[DEV_CMD_LSB_OFFSET];
pCmdIdStr = GetCmdIdStr( cmd );
iPreOffset = ::wcsnlen_s(fnName, 128) // function name
+ 2 // ": "
+ ::wcsnlen_s(pCmdIdStr, 128) // command ID string
+ 3; // " 0x"
iPostOffset = iPreOffset + byMsgLen * 3; // "%.2X " (formatted: 2 hex-nibble bytes and space)
iStrLen = iPostOffset + 3; // "\r\n\0"
pBuf = (wchar_t *)malloc( iStrLen * sizeof(wchar_t) );
::swprintf_s( pBuf, iStrLen, _T("%s: %s 0x"), fnName, pCmdIdStr);
for ( i = iPreOffset; i < iPostOffset; i += 3 )
{
::swprintf_s( &(pBuf[i]), 4, _T("%.2X "), pMsg[j++] );
}
::swprintf_s( &(pBuf[i]), 3, _T("\r\n") );
TRACE( pBuf );
::free( pBuf );