示例#1
0
static void sysPrintfLog(char *text, uint32 textlen, char *buf, uint32 *cur, uint32 *pos)
{
	uint32	maxlen = 0;
	uint32	restlen = 0;
	uint32	cpylen = 0;
	BOOL	bNewLine = FALSE;

	cpylen = textlen;
	maxlen = SYS_MAX_VSPRINTF_BUF_CHARS - 1; // always space for null character
	restlen = maxlen;
	restlen -= *pos;
	
	if (cpylen > restlen) cpylen = restlen;

	if (*pos == 0)
	{
		memset(buf, 0, SYS_MAX_VSPRINTF_BUF_CHARS);
#ifdef _SYSTIMESTAMP
		if (sysTimeStampEnabled)
		{
			char timestr[32];
			uint32 timeStrLen;

			sysGetCurTimeStr(timestr);
			timeStrLen = strlen(timestr);
			restlen -= timeStrLen;
			if (cpylen > restlen) cpylen = restlen;

			strncpy(buf, timestr, timeStrLen);
			strncat(buf, text, cpylen);
			cpylen += timeStrLen;
		}
#else //_SYSTIMESTAMP
		strncpy(buf, text, cpylen);
#endif //_SYSTIMESTAMP
	}
	else
	{
		strncat(buf, text, cpylen);
	}

	*pos += cpylen;
	if (*pos == maxlen)
	{
		buf[maxlen] = 0;
		bNewLine = TRUE;

	}
	else if ((*pos >= 2) &&
			 (buf[*pos - 2] == '\n') &&
			 (buf[*pos - 1] == '\r')) // only expecting \n\r at very end of buffer
	{
		bNewLine = TRUE;
	}
	if (bNewLine == TRUE)
	{
		*pos = 0;
		*cur = (*cur + 1) % SYS_MAX_VSPRINTF_ITEMS; //wrap-around
	}
}
示例#2
0
static HRESULT __lhlStatusQueueDisplay(void)
{
	HRESULT			hResult = NO_ERROR;
	STATUS_INFO		*si = NULL;
	uint16			i;
	char			timestr[16];

	sysGetCurTimeStr(timestr);
	sysDebugPrintf("lhlStatusQueueDisplay: time: %s\n\r", timestr);

	for (i = 0; i < STATUS_INFO_ITEMS; i++)
	{
		if (statusInfoQueue.allocated[i] == TRUE)
		{
			si = &statusInfoQueue.statusInfo[i];
			sysDebugPrintf("%i: nodeAddr 0x%04x, tLabel 0x%04x, pckType:0x%04x, genType:0x%04x\n\r", i, si->nodeAddr, si->tLabel, si->packetType, si->genType);
		}
	}

	return hResult;
}