OTA.h 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198
  1. #ifndef __OTA_20190702__
  2. #define __OTA_20190702__
  3. #include "SynSerial.h"
  4. #include <list>
  5. #define CMD_SIZE 55
  6. #define BUFFER_LEN 10240
  7. #pragma once
  8. typedef struct __SIACP__
  9. {
  10. std::string name; // 命令描述;
  11. std::string head; // 命令头;
  12. std::string code; // 命令码;
  13. std::string mark; // 特殊标记;
  14. bool bMulticode ; // 命令码是否多参数;
  15. int cmd_wait_time ; // 两条串口指令间隔时间;
  16. int read_wait_time ; // 写完串口后,等待多久读;
  17. } _SIACP_, *_pSIACP_;
  18. // 包头码(包引导码)
  19. enum PHeader {
  20. TV_Debug = 0xAA,
  21. TV_Return = 0xAB,
  22. TV_Panel_Debug = 0xAC,
  23. TV_Panel_Return = 0xAD,
  24. TV_Debug_Other = 0xAE,
  25. TV_Other_Return = 0xAF,
  26. };
  27. // 命令结果码;
  28. enum RCode {
  29. RC_OK = 0x0A, // 命令执行通过;
  30. RC_ERR = 0x0E, // 命令错误或无法执行;
  31. RC_LOSE = 0x0F, // 命令丢失(链路层出错);
  32. };
  33. //////////////////////////////////////////////////////////////////////////
  34. enum LOG_ENUM
  35. {
  36. NORMAL_LOG = 0,
  37. ERROR_LOG,
  38. OK_LOG,
  39. INFO_LOG
  40. };
  41. extern std::string HexString2Bytes(std::string strHex, const int& len /* = 3 */);
  42. extern std::string Bytes2HexString(const unsigned char* pbuffer, int nLen);
  43. extern std::string Bytes2HexString(const unsigned char* pbuffer, int nLen, char chSpace);
  44. class CSIACP
  45. {
  46. public:
  47. CSIACP(void);
  48. ~CSIACP(void);
  49. void SetMainDlg(void* p);
  50. void ShowMessage(LPCTSTR lpMsg, LOG_ENUM logtype = NORMAL_LOG);
  51. protected:
  52. CSynSerial* m_pSerial;
  53. void* m_pMainDlg;
  54. typedef struct __RTN__
  55. {
  56. int len; // 返回的数据长度;
  57. std::string data; // 返回的数据内容;
  58. __RTN__()
  59. {
  60. len = 0;
  61. }
  62. }RTN, * pRTN;
  63. std::vector<RTN> m_vtdata;
  64. std::vector<_SIACP_> m_vtcommand;
  65. BOOL ExecSerialCommand(const _SIACP_& siacp, std::string command);
  66. BOOL ParserSerialData(std::vector<RTN>& vtdata, const _SIACP_& siacp, byte* pbuffer, DWORD dwlen);
  67. const _SIACP_* GetSiacp(std::string name);
  68. std::string GetSiacpCommand(const _SIACP_& siacp, std::string others, int othersLen);
  69. std::string GetSiacpCommand(std::string name, std::string others, int othersLen);
  70. public:
  71. void LoadCommand();
  72. void SaveCommand(std::vector<_SIACP_> &vtSiacp, std::string path);
  73. void SaveCommand(_SIACP_ (&Siacp)[CMD_SIZE], std::string path);
  74. BOOL OpenComm(int nSerialPort, DWORD dwBaudrate);
  75. void CloseComm();
  76. BOOL IsOpen() {
  77. return m_pSerial && m_pSerial->IsOpen();
  78. }
  79. BOOL SendCommand(std::string cmd_name, const byte* pszOthers = NULL, DWORD dwOthersLen = 0);
  80. BOOL SendCommand2(std::string cmd_name, std::string data = "", size_t nlen = 0);
  81. public:
  82. // 等待tv启动成功;
  83. BOOL SCBC_WaitTVBoot();
  84. BOOL SCBC_MTKInit();
  85. // 进入工厂模式;
  86. BOOL SCBC_EnterFactory();
  87. // 离开工厂模式;
  88. BOOL SCBC_LeaveFactory();
  89. // 初始化Wb;
  90. BOOL SCBC_WBInit();
  91. // 获取pid;
  92. BOOL SCBC_GetProjectId(int& pid);
  93. // 软件版本号;
  94. BOOL SCBC_GetSoftVersion(std::string& strVer);
  95. // 设备ID
  96. BOOL SCBC_GetDeviceId(std::string& strDid);
  97. // ClientType;
  98. BOOL SCBC_GetClientType(std::string& strClt);
  99. // MAC地址;
  100. BOOL SCBC_GetMAC(std::string& strMac);
  101. // HDCP Key;
  102. BOOL SCBC_GetHDCPKey(std::string& strHDCP);
  103. // HDCP Key2.2;
  104. BOOL SCBC_GetHDCPKey22(std::string& strHDCP22);
  105. // Widi;
  106. BOOL SCBC_GetWidi(std::string& strWidi);
  107. // Netflix ESN;
  108. BOOL SCBC_GetNetflixESN(std::string& strESN);
  109. // Widevine;
  110. BOOL SCBC_GetWidevine(std::string& strWidevine);
  111. // ci plus key;
  112. BOOL SCBC_GetCiKey(std::string& strCikey);
  113. // OSD Language;
  114. BOOL SCBC_GetOSDLanguage(std::string& strOSDLan);
  115. // Shop Language;
  116. BOOL SCBC_GetShopLanguage(std::string& strShopLan);
  117. BOOL SCBC_GetChannel(std::string& channel);
  118. BOOL SCBC_SetProjectId(const int& pid);
  119. BOOL SCBC_SetProjectId(std::string pid);
  120. BOOL SCBC_SetProjectId(const byte* pBuffer, const int& nLen);
  121. BOOL SCBC_SetDeviceId(std::string strDeviceId);
  122. BOOL SCBC_SetDeviceId(const byte* pBuffer, const int &nLen);
  123. BOOL SCBC_SetMAC(std::string strMac);
  124. BOOL SCBC_SetMAC(const byte* pBuffer, const int& nLen);
  125. BOOL SCBC_SetHDCPKey(std::string strHDCP, BOOL bHasSpace = FALSE);
  126. BOOL SCBC_SetHDCPKey(const byte* pBuffer, const int& nLen);
  127. BOOL SCBC_SetHDCPKey22(std::string strHDCP22, BOOL bHasSpace = FALSE);
  128. BOOL SCBC_SetHDCPKey22(const byte* pBuffer, const int& nLen);
  129. BOOL SCBC_SetNetflixESN(std::string strESN, BOOL bHasSpace = FALSE);
  130. BOOL SCBC_SetNetflixESN(const byte* pBuffer, const int& nLen);
  131. BOOL SCBC_SetWidi(std::string strWidi, BOOL bHasSpace = FALSE);
  132. BOOL SCBC_SetWidi(const byte* pBuffer, const int& nLen);
  133. BOOL SCBC_SetWidevine(std::string strWidevine, BOOL bHasSpace = FALSE);
  134. BOOL SCBC_SetWidevine(const byte* pBuffer, const int& nLen);
  135. BOOL SCBC_SetCiKey(std::string strCiKey, BOOL bHasSpace = FALSE);
  136. BOOL SCBC_SetCiKey(const byte* pBuffer, const int& nLen);
  137. BOOL SCBC_SetOSDLanguage(std::string lan, BOOL bHasSpace = TRUE);
  138. BOOL SCBC_SetOSDLanguage(const byte* pBuffer, const int& nLen);
  139. BOOL SCBC_SetShopLanguage(std::string lan, BOOL bHasSpace = TRUE);
  140. BOOL SCBC_SetShopLanguage(const byte* pBuffer, const int& nLen);
  141. BOOL SCBC_SetChannel(std::string channel, BOOL bHasSpace = TRUE);
  142. BOOL SCBC_SetChannel(const byte* pBuffer, const int& nLen);
  143. BOOL SCBC_SetChannel(int channel);
  144. BOOL SCBC_SetWBNormal(std::string data);
  145. BOOL SCBC_SetWBNormal(const byte* pBuffer, const int& nLen);
  146. BOOL SCBC_SetWBCool(std::string data);
  147. BOOL SCBC_SetWBCool(const byte* pBuffer, const int& nLen);
  148. BOOL SCBC_SetWBWarm(std::string data);
  149. BOOL SCBC_SetWBWarm(const byte* pBuffer, const int& nLen);
  150. BOOL SCBC_CheckDeviceId();
  151. BOOL SCBC_CheckMAC();
  152. BOOL SCBC_CheckHDCP();
  153. BOOL SCBC_CheckHDCP22();
  154. BOOL SCBC_CheckNetflixESN();
  155. BOOL SCBC_CheckWidi();
  156. BOOL SCBC_CheckWidevine();
  157. BOOL SCBC_CheckCikey();
  158. BOOL SCBC_StarWarmUpMode();
  159. BOOL SCBC_StopWarmUpMode();
  160. // 工厂菜单显示与隐藏;
  161. BOOL SCBC_ShowFactoryMenu();
  162. BOOL SCBC_HideFactoryMenu();
  163. // 工厂信息内容显示与隐藏;
  164. BOOL SCBC_ShowFactoryInformation();
  165. BOOL SCBC_HideFactoryInformation();
  166. // 老化模式的开与关、老化时间读取;
  167. BOOL SCBC_EnterAgingModel();
  168. BOOL SCBC_LeaveAgingModel();
  169. BOOL SCBC_ReadAgingTime(int &min);
  170. // 红绿蓝增益;
  171. BOOL SCBC_SetRedGainRegister(int value);
  172. BOOL SCBC_SetGreenGainRegister(int value);
  173. BOOL SCBC_SetBlueGainRegister(int value);
  174. // 红绿蓝偏移;
  175. BOOL SCBC_SetRedOffsetRegister(int value);
  176. BOOL SCBC_SetGreenOffsetRegister(int value);
  177. BOOL SCBC_SetBlueOffsetRegister(int value);
  178. };
  179. extern std::string HexString2Bytes(std::string strHex, const int& len = 3);
  180. #endif