|
@@ -2,14 +2,21 @@
|
|
|
#include "TCLCommand.h"
|
|
|
|
|
|
#define NoneOptLen 5
|
|
|
+#define MINSIZE 128
|
|
|
+#define MIDSIZE 4096
|
|
|
+#define MAXSIZE 10240
|
|
|
|
|
|
+byte* TCLCommand::m_pData = NULL;
|
|
|
TCLCommand::TCLCommand(bool bSync):CBaseSerial(bSync ? 0 : FILE_FLAG_OVERLAPPED)
|
|
|
{
|
|
|
-
|
|
|
+ m_pData = new byte[MAXSIZE];
|
|
|
}
|
|
|
|
|
|
TCLCommand::~TCLCommand(void)
|
|
|
{
|
|
|
+ if (m_pData)
|
|
|
+ delete []m_pData;
|
|
|
+ m_pData = NULL;
|
|
|
m_vtExternalCMDParams.clear();
|
|
|
m_vtInternalCMDParams.clear();
|
|
|
}
|
|
@@ -86,7 +93,7 @@ bool TCLCommand::parse_pair_key(std::string& RetValue, std::string strLine, TCHA
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
-int TCLCommand::parse_cmds_from_file(TCHAR* file_name, std::vector<CommandParam>& vtCommandParams)
|
|
|
+int TCLCommand::parse_cmds_from_file(const TCHAR* file_name, std::vector<CommandParam>& vtCommandParams)
|
|
|
{
|
|
|
TCHAR buf[MAX_PATH] = { 0 };
|
|
|
TCHAR name[MAX_PATH] = { 0 };
|
|
@@ -256,6 +263,7 @@ bool TCLCommand::GetCommandParams(std::string name, CommandParam& cmdPara)
|
|
|
if ( !_tcsicmp(name.c_str(), it->name.c_str()) ) {
|
|
|
bget = true;
|
|
|
cmdPara = *it;
|
|
|
+ break;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -374,7 +382,7 @@ bool TCLCommand::TheSecondPart(CommandParam& cmdPara, std::string data)
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
-std::string TCLCommand::PackingCommand(CommandParam& cmdPara, std::string data, const int& dataLen)
|
|
|
+void TCLCommand::PackingCommand(CommandParam& cmdPara, std::string data, const int& dataLen)
|
|
|
{
|
|
|
// Tag:[命令头][全命令长度][命令码]<命令码参数><附加数据>[crc1][crc2]
|
|
|
std::string command;
|
|
@@ -426,10 +434,8 @@ std::string TCLCommand::PackingCommand(CommandParam& cmdPara, std::string data,
|
|
|
szcrc[1] = usCRCValue & 0xFF;
|
|
|
command.append((char*)szcrc, 2);
|
|
|
|
|
|
- cmdPara._cmdContext = utils::BytesToHexString((byte*)command.c_str(), command.size(), ' ');
|
|
|
- utils::_dprintf(_T("指令:%s = %s"), cmdPara.name.c_str(), cmdPara._cmdContext.c_str());
|
|
|
-
|
|
|
- return command;
|
|
|
+ cmdPara._cmdContext = command;
|
|
|
+ utils::_dprintf(_T("指令:%s = %s"), cmdPara.name.c_str(), utils::BytesToHexString((byte*)command.c_str(), command.size(), ' ').c_str());
|
|
|
}
|
|
|
|
|
|
void TCLCommand::ParseResultString(CommandParam& cmdPara, std::string data, const int& dataLen)
|
|
@@ -455,3 +461,468 @@ void TCLCommand::ParseResultString(CommandParam& cmdPara, std::string data, cons
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+bool TCLCommand::SendCommand(CommandParam& cmdPara)
|
|
|
+{
|
|
|
+ memset(m_pData, 0, MAXSIZE);
|
|
|
+ if (_dwIOMode == FILE_FLAG_OVERLAPPED)
|
|
|
+ {
|
|
|
+ if (!Write((void*)cmdPara._cmdContext.c_str(), cmdPara._cmdContext.size()))
|
|
|
+ return false;
|
|
|
+
|
|
|
+ Sleep(cmdPara.read_wait_time);
|
|
|
+ int nReadCount = Read(m_pData, MAXSIZE);
|
|
|
+ cmdPara._rtnContext.append((char*)m_pData, nReadCount);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ if (!WriteSync((void*)cmdPara._cmdContext.c_str(), cmdPara._cmdContext.size()))
|
|
|
+ return false;
|
|
|
+
|
|
|
+ Sleep(cmdPara.read_wait_time);
|
|
|
+ int nReadCount = ReadSync(m_pData, MAXSIZE);
|
|
|
+ cmdPara._rtnContext.append((char*)m_pData, nReadCount);
|
|
|
+ }
|
|
|
+
|
|
|
+ utils::_dprintf("结果:%s = %s", cmdPara.name.c_str(), utils::BytesToHexString((byte*)cmdPara._rtnContext.c_str(), cmdPara._rtnContext.size(), ' ').c_str());
|
|
|
+ ParseResultString(cmdPara, cmdPara._rtnContext, cmdPara._rtnContext.size());
|
|
|
+ Sleep(cmdPara.cmd_wait_time);
|
|
|
+
|
|
|
+ return cmdPara._rtnStatus == 0x0A ? true : false;
|
|
|
+}
|
|
|
+
|
|
|
+void TCLCommand::SetInternalCMDParams(DWORD dwResouceID)
|
|
|
+{
|
|
|
+ std::string data;
|
|
|
+ if ( utils::GetResourceData(dwResouceID, _T("BIN"), data) )
|
|
|
+ {
|
|
|
+ parse_cmds_from_string(data, m_vtInternalCMDParams);
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+void TCLCommand::SetExternalCMDParams(LPCTSTR lpFileName)
|
|
|
+{
|
|
|
+ parse_cmds_from_file(lpFileName, m_vtExternalCMDParams);
|
|
|
+}
|
|
|
+
|
|
|
+bool TCLCommand::EnterFactory()
|
|
|
+{
|
|
|
+ CommandParam cmdpara;
|
|
|
+ GetCommandParams("EnterFactory", cmdpara);
|
|
|
+ PackingCommand(cmdpara);
|
|
|
+ return SendCommand(cmdpara);
|
|
|
+}
|
|
|
+
|
|
|
+bool TCLCommand::LeaveFactory()
|
|
|
+{
|
|
|
+ CommandParam cmdpara;
|
|
|
+ GetCommandParams("LeaveFactory", cmdpara);
|
|
|
+ PackingCommand(cmdpara);
|
|
|
+ return SendCommand(cmdpara);
|
|
|
+}
|
|
|
+
|
|
|
+bool TCLCommand::GetProjectId(int& pid)
|
|
|
+{
|
|
|
+ CommandParam cmdpara;
|
|
|
+ GetCommandParams("GetProjectId", cmdpara);
|
|
|
+ PackingCommand(cmdpara);
|
|
|
+ if (SendCommand(cmdpara))
|
|
|
+ {
|
|
|
+ if (cmdpara._rtnData.size() == 2)
|
|
|
+ pid = (byte)cmdpara._rtnData[0] << 8 | (byte)cmdpara._rtnData[1];
|
|
|
+ else
|
|
|
+ pid = (byte)cmdpara._rtnData[0];
|
|
|
+
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+
|
|
|
+ return false;
|
|
|
+}
|
|
|
+
|
|
|
+bool TCLCommand::GetSoftVersion(std::string& strValue)
|
|
|
+{
|
|
|
+ CommandParam cmdpara;
|
|
|
+ GetCommandParams("GetSoftVersion", cmdpara);
|
|
|
+ PackingCommand(cmdpara);
|
|
|
+ if (SendCommand(cmdpara))
|
|
|
+ {
|
|
|
+ strValue = cmdpara._rtnData;
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+
|
|
|
+ return false;
|
|
|
+}
|
|
|
+
|
|
|
+bool TCLCommand::GetDeviceId(std::string& strValue)
|
|
|
+{
|
|
|
+ CommandParam cmdpara;
|
|
|
+ GetCommandParams("GetDeviceId", cmdpara);
|
|
|
+ PackingCommand(cmdpara);
|
|
|
+ if (SendCommand(cmdpara))
|
|
|
+ {
|
|
|
+ strValue = cmdpara._rtnData;
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+
|
|
|
+ return false;
|
|
|
+}
|
|
|
+
|
|
|
+bool TCLCommand::GetClientType(std::string& strValue)
|
|
|
+{
|
|
|
+ CommandParam cmdpara;
|
|
|
+ GetCommandParams("GetClientType", cmdpara);
|
|
|
+ PackingCommand(cmdpara);
|
|
|
+ if (SendCommand(cmdpara))
|
|
|
+ {
|
|
|
+ strValue = cmdpara._rtnData;
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+
|
|
|
+ return false;
|
|
|
+}
|
|
|
+
|
|
|
+bool TCLCommand::GetMAC(std::string& strValue)
|
|
|
+{
|
|
|
+ CommandParam cmdpara;
|
|
|
+ GetCommandParams("GetMAC", cmdpara);
|
|
|
+ PackingCommand(cmdpara);
|
|
|
+ if (SendCommand(cmdpara))
|
|
|
+ {
|
|
|
+ strValue = cmdpara._rtnData;
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+
|
|
|
+ return false;
|
|
|
+}
|
|
|
+
|
|
|
+bool TCLCommand::GetHDCPKey(std::string& strValue)
|
|
|
+{
|
|
|
+ CommandParam cmdpara;
|
|
|
+ GetCommandParams("GetHDCPKey", cmdpara);
|
|
|
+ PackingCommand(cmdpara);
|
|
|
+ if (SendCommand(cmdpara))
|
|
|
+ {
|
|
|
+ strValue = cmdpara._rtnData;
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+
|
|
|
+ return false;
|
|
|
+}
|
|
|
+
|
|
|
+bool TCLCommand::GetHDCPKey22(std::string& strValue)
|
|
|
+{
|
|
|
+ CommandParam cmdpara;
|
|
|
+ GetCommandParams("GetHDCPKey22", cmdpara);
|
|
|
+ PackingCommand(cmdpara);
|
|
|
+ if (SendCommand(cmdpara))
|
|
|
+ {
|
|
|
+ strValue = cmdpara._rtnData;
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+
|
|
|
+ return false;
|
|
|
+}
|
|
|
+
|
|
|
+bool TCLCommand::GetWidi(std::string& strValue)
|
|
|
+{
|
|
|
+ CommandParam cmdpara;
|
|
|
+ GetCommandParams("GetWidi", cmdpara);
|
|
|
+ PackingCommand(cmdpara);
|
|
|
+ if (SendCommand(cmdpara))
|
|
|
+ {
|
|
|
+ strValue = cmdpara._rtnData;
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+
|
|
|
+ return false;
|
|
|
+}
|
|
|
+
|
|
|
+bool TCLCommand::GetNetflixESN(std::string& strValue)
|
|
|
+{
|
|
|
+ CommandParam cmdpara;
|
|
|
+ GetCommandParams("GetNetflixESN", cmdpara);
|
|
|
+ PackingCommand(cmdpara);
|
|
|
+ if (SendCommand(cmdpara))
|
|
|
+ {
|
|
|
+ strValue = cmdpara._rtnData;
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+
|
|
|
+ return false;
|
|
|
+}
|
|
|
+
|
|
|
+bool TCLCommand::GetWidevine(std::string& strValue)
|
|
|
+{
|
|
|
+ CommandParam cmdpara;
|
|
|
+ GetCommandParams("GetWidevine", cmdpara);
|
|
|
+ PackingCommand(cmdpara);
|
|
|
+ if (SendCommand(cmdpara))
|
|
|
+ {
|
|
|
+ strValue = cmdpara._rtnData;
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+
|
|
|
+ return false;
|
|
|
+}
|
|
|
+
|
|
|
+bool TCLCommand::GetCiKey(std::string& strValue)
|
|
|
+{
|
|
|
+ CommandParam cmdpara;
|
|
|
+ GetCommandParams("GetCiKey", cmdpara);
|
|
|
+ PackingCommand(cmdpara);
|
|
|
+ if (SendCommand(cmdpara))
|
|
|
+ {
|
|
|
+ strValue = cmdpara._rtnData;
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+
|
|
|
+ return false;
|
|
|
+}
|
|
|
+
|
|
|
+bool TCLCommand::GetOSDLanguage(std::string& strValue)
|
|
|
+{
|
|
|
+ CommandParam cmdpara;
|
|
|
+ GetCommandParams("GetOSDLanguage", cmdpara);
|
|
|
+ PackingCommand(cmdpara);
|
|
|
+ if (SendCommand(cmdpara))
|
|
|
+ {
|
|
|
+ strValue = cmdpara._rtnData;
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+
|
|
|
+ return false;
|
|
|
+}
|
|
|
+
|
|
|
+bool TCLCommand::GetShopLanguage(std::string& strValue)
|
|
|
+{
|
|
|
+ CommandParam cmdpara;
|
|
|
+ GetCommandParams("GetShopLanguage", cmdpara);
|
|
|
+ PackingCommand(cmdpara);
|
|
|
+ if (SendCommand(cmdpara))
|
|
|
+ {
|
|
|
+ strValue = cmdpara._rtnData;
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+
|
|
|
+ return false;
|
|
|
+}
|
|
|
+
|
|
|
+bool TCLCommand::GetChannel(std::string& strValue)
|
|
|
+{
|
|
|
+ CommandParam cmdpara;
|
|
|
+ GetCommandParams("GetChannel", cmdpara);
|
|
|
+ PackingCommand(cmdpara);
|
|
|
+ if (SendCommand(cmdpara))
|
|
|
+ {
|
|
|
+ strValue = cmdpara._rtnData;
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+
|
|
|
+ return false;
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+bool TCLCommand::SetProjectId(const byte* pBuffer, const int& nLen)
|
|
|
+{
|
|
|
+ return false;
|
|
|
+}
|
|
|
+
|
|
|
+bool TCLCommand::SetDeviceId(LPCTSTR lpDeviceId)
|
|
|
+{
|
|
|
+ return false;
|
|
|
+}
|
|
|
+
|
|
|
+bool TCLCommand::SetDeviceId(const byte* pBuffer, const int& nLen)
|
|
|
+{
|
|
|
+ return false;
|
|
|
+}
|
|
|
+
|
|
|
+bool TCLCommand::SetMAC(LPCTSTR lpMac)
|
|
|
+{
|
|
|
+ return false;
|
|
|
+}
|
|
|
+
|
|
|
+bool TCLCommand::SetMAC(const byte* pBuffer, const int& nLen)
|
|
|
+{
|
|
|
+ return false;
|
|
|
+}
|
|
|
+
|
|
|
+bool TCLCommand::SetHDCPKey(LPCTSTR lpHDCP, bool bHasSpace)
|
|
|
+{
|
|
|
+ return false;
|
|
|
+}
|
|
|
+
|
|
|
+bool TCLCommand::SetHDCPKey(const byte* pBuffer, const int& nLen)
|
|
|
+{
|
|
|
+ return false;
|
|
|
+}
|
|
|
+
|
|
|
+bool TCLCommand::SetHDCPKey22(LPCTSTR lpHDCP22, bool bHasSpace)
|
|
|
+{
|
|
|
+ return false;
|
|
|
+}
|
|
|
+
|
|
|
+bool TCLCommand::SetHDCPKey22(const byte* pBuffer, const int& nLen)
|
|
|
+{
|
|
|
+ return false;
|
|
|
+}
|
|
|
+
|
|
|
+bool TCLCommand::SetNetflixESN(LPCTSTR lpESN, bool bHasSpace)
|
|
|
+{
|
|
|
+ return false;
|
|
|
+}
|
|
|
+
|
|
|
+bool TCLCommand::SetNetflixESN(const byte* pBuffer, const int& nLen)
|
|
|
+{
|
|
|
+ return false;
|
|
|
+}
|
|
|
+
|
|
|
+bool TCLCommand::SetWidi(LPCTSTR lpWidi, bool bHasSpace)
|
|
|
+{
|
|
|
+ return false;
|
|
|
+}
|
|
|
+
|
|
|
+bool TCLCommand::SetWidi(const byte* pBuffer, const int& nLen)
|
|
|
+{
|
|
|
+ return false;
|
|
|
+}
|
|
|
+
|
|
|
+bool TCLCommand::SetWidevine(LPCTSTR lpWidevine, bool bHasSpace)
|
|
|
+{
|
|
|
+ return false;
|
|
|
+}
|
|
|
+
|
|
|
+bool TCLCommand::SetWidevine(const byte* pBuffer, const int& nLen)
|
|
|
+{
|
|
|
+ return false;
|
|
|
+}
|
|
|
+
|
|
|
+bool TCLCommand::SetCiKey(LPCTSTR lpCiKey, bool bHasSpace)
|
|
|
+{
|
|
|
+ return false;
|
|
|
+}
|
|
|
+
|
|
|
+bool TCLCommand::SetCiKey(const byte* pBuffer, const int& nLen)
|
|
|
+{
|
|
|
+ return false;
|
|
|
+}
|
|
|
+
|
|
|
+bool TCLCommand::SetOSDLanguage(LPCTSTR lan, bool bHasSpace)
|
|
|
+{
|
|
|
+ return false;
|
|
|
+}
|
|
|
+
|
|
|
+bool TCLCommand::SetOSDLanguage(const byte* pBuffer, const int& nLen)
|
|
|
+{
|
|
|
+ return false;
|
|
|
+}
|
|
|
+
|
|
|
+bool TCLCommand::SetShopLanguage(LPCTSTR lan, bool bHasSpace)
|
|
|
+{
|
|
|
+ return false;
|
|
|
+}
|
|
|
+
|
|
|
+bool TCLCommand::SetShopLanguage(const byte* pBuffer, const int& nLen)
|
|
|
+{
|
|
|
+ return false;
|
|
|
+}
|
|
|
+
|
|
|
+bool TCLCommand::SetChannel(LPCTSTR channel, bool bHasSpace)
|
|
|
+{
|
|
|
+ return false;
|
|
|
+}
|
|
|
+
|
|
|
+bool TCLCommand::SetChannel(const byte* pBuffer, const int& nLen)
|
|
|
+{
|
|
|
+ return false;
|
|
|
+}
|
|
|
+
|
|
|
+bool TCLCommand::SetWBNormal(LPCTSTR data)
|
|
|
+{
|
|
|
+ return false;
|
|
|
+}
|
|
|
+
|
|
|
+bool TCLCommand::SetWBNormal(const byte* pBuffer, const int& nLen)
|
|
|
+{
|
|
|
+ return false;
|
|
|
+}
|
|
|
+
|
|
|
+bool TCLCommand::SetWBCool(LPCTSTR data)
|
|
|
+{
|
|
|
+ return false;
|
|
|
+}
|
|
|
+
|
|
|
+bool TCLCommand::SetWBCool(const byte* pBuffer, const int& nLen)
|
|
|
+{
|
|
|
+ return false;
|
|
|
+}
|
|
|
+
|
|
|
+bool TCLCommand::SetWBWarm(LPCTSTR data)
|
|
|
+{
|
|
|
+ return false;
|
|
|
+}
|
|
|
+
|
|
|
+bool TCLCommand::SetWBWarm(const byte* pBuffer, const int& nLen)
|
|
|
+{
|
|
|
+ return false;
|
|
|
+}
|
|
|
+
|
|
|
+bool TCLCommand::CheckDeviceId()
|
|
|
+{
|
|
|
+ return false;
|
|
|
+}
|
|
|
+
|
|
|
+bool TCLCommand::CheckMAC()
|
|
|
+{
|
|
|
+ return false;
|
|
|
+}
|
|
|
+
|
|
|
+bool TCLCommand::CheckHDCP()
|
|
|
+{
|
|
|
+ return false;
|
|
|
+}
|
|
|
+
|
|
|
+bool TCLCommand::CheckHDCP22()
|
|
|
+{
|
|
|
+ return false;
|
|
|
+}
|
|
|
+
|
|
|
+bool TCLCommand::CheckNetflixESN()
|
|
|
+{
|
|
|
+ return false;
|
|
|
+}
|
|
|
+
|
|
|
+bool TCLCommand::CheckWidi()
|
|
|
+{
|
|
|
+ return false;
|
|
|
+}
|
|
|
+
|
|
|
+bool TCLCommand::CheckWidevine()
|
|
|
+{
|
|
|
+ return false;
|
|
|
+}
|
|
|
+
|
|
|
+bool TCLCommand::CheckCikey()
|
|
|
+{
|
|
|
+ return false;
|
|
|
+}
|
|
|
+
|
|
|
+bool TCLCommand::StarWarmUpMode()
|
|
|
+{
|
|
|
+ return false;
|
|
|
+}
|
|
|
+
|
|
|
+bool TCLCommand::StopWarmUpMode()
|
|
|
+{
|
|
|
+ return false;
|
|
|
+}
|
|
|
+
|
|
|
+bool TCLCommand::SetProjectId(int pid)
|
|
|
+{
|
|
|
+ return false;
|
|
|
+}
|
|
|
+
|
|
|
+bool TCLCommand::SetProjectId(LPCTSTR lpPid)
|
|
|
+{
|
|
|
+ return false;
|
|
|
+}
|