#ifndef __CONSOLE_TPV_RS232_H_
#define __CONSOLE_TPV_RS232_H_

#include "types.h"
#include "al_basictypes.h"
#include "app_event.h"
#include "al_console.h"
#include "al_console_customer.h"

#define TPV_RS232_HEAD              0x6E
#define TPV_RW_READ                 0x01
#define TPV_RW_WRITE                0x03
#define TPV_PRE2                    0xFE
#define TPV_FCode01                 0xE1
#define TPV_FCode02                 0xE2
#define TPV_FCode03                 0xE3
#define TPV_FCode04                 0xE4
#define TPV_FCode05                 0xE5
#define TPV_FCode06                 0xE6
#define TPV_FCode07                 0xE7
#define TPV_FCode08                 0xE8
#define TPV_FCode09                 0xE9
#define TPV_FCode0A                 0xEA
#define TPV_FCode0B                 0xEB
#define TPV_FCode0C                 0xEC
#define TPV_FCode0D                 0xED
#define TPV_FCode0E                 0xEE
#define TPV_FCode0F                 0xEF
#define TPV_FCode10                 0xF0
#define TPV_FCode11                 0xF1


/*
Frame_Head(2 bytes)	Size            pre1	        pre2	CMD	    Ext	 data1  data2 ...	checksum
6E 51             0x80+size		    03(R/W)			FE		XX		YY	 zz	     ww	  ...  ??
Frame Head:6E 51 
eg: checksum:6E XOR 51 XOR 86 XOR 03 XOR FE XOR XX XOR YY XOR ZZ XOR WW X0R ... = ??
*/
typedef struct TpvExtCommandFrame_t_{
	UINT8 FrameHead1;
    UINT8 FrameHead2;
    UINT8 CmdSize;//0x80+size,not include checksum
    UINT8 Pre1;
	UINT8 Pre2;
	UINT8 Cmd;
	UINT8 ExtByte;
	UINT8 *Data;//len = CmdSize - 0x80 - 0x4
	UINT8 CheckSum;
}TpvExtCommandFrame_t;

typedef enum{
	TpvRsp_State_OK 		= 0x1,
	TpvRsp_State_ERR 	= 0x2,
	TpvRsp_Data  		= 0x3,
	TpvRsp_Data_Invalid 	= 0x4,
	TpvRsp_Need_App_Resp	= 0x5,
}eTpvRspType;

typedef enum{
	TPV_CMD_Factory_Mode 	= 0x0,
    TPV_CMD_Set_BurnInMode,
    TPV_CMD_Set_Smart_Picture_mode,
    TPV_CMD_Set_internal_Test_Pattern,
    TPV_CMD_Reset_Picture_mode_setting,
    TPV_CMD_set_picture_functon,
    
	TPV_CMD_Select_Input_Source,
    TPV_CMD_R_Get_WB_Default_Value,
    
	TPV_CMD_NUM_MAX,
}TpvRS232Type;


typedef int (*TpvRs232_autotest_Cbk_pf)(pCON_DEV pcon, UINT8 *msg);

typedef struct TpvRs232_autoest_Cbk_t_
{
	TpvRs232_autotest_Cbk_pf		pfCallBack;
} TpvRs232_autotest_Cbk_t;

void al_tpvrs232_autotest_init(TpvRs232_autotest_Cbk_t *pConsole_autotest_Cfg);

bool con_TpvRs232_AutoTest_parser(pCON_DEV pcon, UINT8* msg, UINT8 frameLen);


#endif
