⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 dvb_msg.c

📁 DVB软件,基于CT216软件的开发源程序.
💻 C
字号:
/**************************************************************************

        (C)Copyright Cheertek Inc. 2002-2004,
           D700, all right reserved.

        Product : STB Firmware

****************************************************************************/
#include <stdio.h>
#include <stdarg.h>
#include <string.h>
#include "dvb_msg.h"
#include "ct_type.h"

#if 1
#define DVBMSG_MSG(p)
#else
#define DVBMSG_MSG(p)			printf p
#endif

#if 1
#define DVBMSG_DBG(p)
#else
#define DVBMSG_DBG(p) 		printf p
#endif


u32	_u32MsgMsk = MSG_4_ALL; //This variable will be changed by DVB_MsgSetMask() in sysdebug.c
bool8 _b8MsgEnable = TRUE; //This variable will be changed by DVB_MsgSetDisplayMessage() in sysdebug.c

void print_parse(va_list arg_pt ,char *pcFormat);//Distinguith from %d, %x, %s ,%p and printf

/****************************************************************************
 ** Function:           DVB_Msg
 ** Description:        print message depend on _u32MsgMsk.
 ** Parameters:         u32 u32Mask, using this variable to decide printing message or not.
 ** 					Other parameters, the same as printf
 ** Global:				u32 _u32MsgMsk, mask base.
 ** Return:             none.
 ** Note:               Using DVB_MsgSetMask() and DVB_MsgClrMask() to change _u32MsgMsk.
 **						MsgSetMask() and DVB_MsgClrMask() are in usrdebug.c
 ** History:			Virgil created. 2003/12/01
*****************************************************************************/
void DVB_Msg(u32 u32Mask, char *format, ...)
{
	va_list list;
	if (TRUE == _b8MsgEnable) {
		if(_u32MsgMsk & u32Mask) {
			va_start(list, format);                                 
			print_parse(list, format);
			va_end(list);
    	}
    }
}

/****************************************************************************
 ** Function:           DVB_MsgSetMask
 ** Description:        set print mask
 ** Parameters:         u32 u32Mask(input), set mask
 ** Global:				extern u32 _u32MsgMsk, mask base.
 ** Note:               _u32MsgMsk is declared in dvb_msg.c
 ** History:			Virgil created. 2003/12/01
*****************************************************************************/
void DVB_MsgSetMask(u32 u32Mask)
{
    _u32MsgMsk = u32Mask;
//    DVB_Msg(MSG_4_GENERAL, "%s, %d>set, MsgMask = 0x%lx\n", __FILE__, (int)__LINE__, (u32)_u32MsgMsk);
}

/****************************************************************************
 ** Function:           DVB_MsgClrMask
 ** Description:        clear print mask
 ** Parameters:         u32 u32Mask(input), set mask
 ** Global:				extern u32 _u32MsgMsk, mask base.
 ** Note:               _u32MsgMsk is declared in dvb_msg.c
 ** History:			Virgil created. 2003/12/01
*****************************************************************************/
void DVB_MsgClrMask(u32 u32Mask)
{
    _u32MsgMsk &= (~u32Mask);
    //DVB_Msg(MSG_4_GENERAL, "%s, %d>clear, MsgMask = 0x%lx\n", __FILE__, (int)__LINE__, (u32)_u32MsgMsk);
}

/****************************************************************************
 ** Function:           DVB_MsgSetDisplayMessage
 ** Description:        Enable or disable message displaying in UART
 ** Parameters:         bool8 b8Enable(input), TRUE: enable message, FALSE: disable message
 ** Global:				extern bool8 _b8MsgEnable, displaying flag.
 ** Note:               _b8MsgEnable is declared in dvb_msg.c
 ** History:			Virgil created. 2005/01/19
*****************************************************************************/
void DVB_MsgSetDisplayMessage(bool8 b8Enable)
{
	_b8MsgEnable = b8Enable;
}

/****************************************************************************
 ** Function:           DVB_MsgGetDisplayMessageState
 ** Description:        Get the state of message displaying
 ** Return:				TRUE: enable message, FALSE: disable message
 ** Global:				extern bool8 _b8MsgEnable, displaying flag.
 ** Note:               _b8MsgEnable is declared in dvb_msg.c
 ** History:			Virgil created. 2005/01/19
*****************************************************************************/
bool8 DVB_MsgGetDisplayMessageState(void)
{
	return _b8MsgEnable;
}

/****************************************************************************
 ** Function:           print_parse
 ** Description:        Distinguith from %d, %x, %s ,%p and printf
 ** Return:				None
 ** Global:				extern NU_SERIAL_PORT  port.
 ** Note:               This is locate function
 ** History:			venti created. 2005/11/25
*****************************************************************************/
void print_parse(va_list arg_pt ,char *pcFormat)
#if 1
{
	u8   i;
    u8   buff[10];
    int  u32Value;
    char *pcCurr;    //get the current character from "strString" in order
    char *pcSValue;  //the return value of the %s  pass through the macro va_arg
    u8 out = 0;
                
    for(pcCurr = pcFormat; *pcCurr; pcCurr++) {           
        if(*pcCurr != '%') 
		{       
			DVBMSG_DBG(("%c",*pcCurr));
            continue;
        }
        
        *++pcCurr;
        
        if ((*pcCurr == 'c') || (*pcCurr == 's')) 
        {
			for(pcSValue = va_arg(arg_pt, char *); *pcSValue; pcSValue++)
			{
				DVBMSG_DBG(("%c",*pcSValue));
			}	
		}
		else
		{
			memset (buff, 0, sizeof (buff));
			out = 0;
			
			buff[0] = '%';		
			i = 1;
			
			for (; *pcCurr; pcCurr++)  
			{
				if (i == 1 && *pcCurr == '%')
				{
					DVBMSG_DBG(("%c", buff[0]));
					out = 1;
					break;
				}	
				if (*pcCurr != 'd' &&  *pcCurr != 'x' && *pcCurr != 'X' 
					&& *pcCurr != 'u' && *pcCurr != 'i' 
					&& *pcCurr != 'o' && *pcCurr != 'b'
					&& *pcCurr != 'e' && *pcCurr != 'E' 
					&& *pcCurr != 'f')
				{
					buff[i] = *pcCurr;
					i ++;
				}
				else
				{
					buff[i] = *pcCurr;
					u32Value = va_arg(arg_pt, u32);
                	DVBMSG_DBG((buff, u32Value));
                	out = 1;
					break;
				}	
							 
			}	
			
			if (out == 0)
			{
				DVBMSG_DBG(("%s", buff));
			}	
		}			
	}	
}		
#else
{               
    u8   i;
    const u8 buff[10];
    int  u32Value;
    char *pcCurr, *pcCurr1;    //get the current character from "strString" in order
    char *pcSValue;  //the return value of the %s  pass through the macro va_arg
                
    for(pcCurr = pcFormat; *pcCurr; pcCurr++) {           
        if(*pcCurr != '%')
		{       
			DVBMSG_DBG(("%c",*pcCurr));
            continue;
        }
	
		switch(*++pcCurr)
        {
            case 'd' :
                u32Value = va_arg(arg_pt, u32);
                DVBMSG_DBG(("%d", u32Value));
                break;
                
            case 'p' :
                u32Value = va_arg(arg_pt, u32);
                DVBMSG_DBG(("%p", &u32Value));
                break;
                
            case 'x' :
            case 'X' :
                u32Value = va_arg(arg_pt, u32);
                DVBMSG_DBG(("%x", u32Value));
                break;  
                  
            case 'c' :
            case 's' :
                for(pcSValue = va_arg(arg_pt, char *); *pcSValue; pcSValue++)
                {
					DVBMSG_DBG(("%c",*pcSValue));
                }	
				break;

            default :
        
        		pcCurr1 = pcCurr;
        
        		if ((*pcCurr) == '0')
				{
					memset (buff, 0, sizeof (buff));
					
					buff[0] = '%'; 
					buff[1] = *pcCurr;    
					pcCurr++; 
			
					if ((*pcCurr >= '2') && (*pcCurr <= '9'))
					{
						buff[2] = *pcCurr;
						pcCurr++; 
						if ((*pcCurr == 'd') || (*pcCurr == 'x'))
						{
							u32Value = va_arg(arg_pt, u32);
							buff[3] = *pcCurr;
							DVBMSG_DBG((buff, u32Value)); 
                			continue;
						}
						else
						{
							pcCurr = pcCurr1;            	
							DVBMSG_DBG(("%c",*pcCurr));
						}
						break;
					}	
				}
				else
				{
					memset (buff, 0, sizeof (buff));
					
					buff[0] = '%'; 
					if ((*pcCurr >= '2') && (*pcCurr <= '9'))
					{
						buff[1] = *pcCurr;  
						pcCurr++; 
						if ((*pcCurr == 'd') || (*pcCurr == 'x'))
						{
							u32Value = va_arg(arg_pt, u32);
							buff[2] = *pcCurr;
							DVBMSG_DBG((buff, u32Value)); 
                			break;
						} 
					}	
				}	
				pcCurr = pcCurr1;  
				DVBMSG_DBG(("%c",*pcCurr));
                break;
        }
    }
}
#endif
/*****************************************************************************/
#ifdef MSG_RO_EXAMPLE
bool8 DVB_MsgCodeUnzip(u8* pu8SrcPtr, u8* pu8DstPtr)
{   
#if defined(CT216U)||defined(CT956)
    u8* pu8WorkPtr  = NULL;
    
    if (CT_SYS_GetMem((12*1024), (void **)&pu8WorkPtr)!=EN_CTOS_SUCCESS)
    {
        return FALSE;
    }        
    if (UNZIP2006_UNZIP(pu8SrcPtr, pu8DstPtr, pu8WorkPtr)==-1)
    {
        CT_SYS_FreeMem(pu8WorkPtr);
        return FALSE;
    }
    CT_SYS_FreeMem(pu8WorkPtr);
    return TRUE;
#else //#if defined(CT216U)||defined(CT956)
    if (CT_SYS_Unzip(pu8DstPtr, pu8SrcPtr, 0)!=TRUE)
    {
        return FALSE;
    }
    return TRUE;
#endif //#if defined(CT216U)||defined(CT956)
}
#endif //#ifdef MSG_RO_EXAMPLE
/*****************************************************************************/

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -