浏览代码

枚举。

sat23 4 年之前
父节点
当前提交
e51bb7a6e9
共有 3 个文件被更改,包括 33 次插入5 次删除
  1. 1 1
      Serail-Demo/Demo/Serial.cpp
  2. 25 3
      Serail-Demo/Demo/stdafx.cpp
  3. 7 1
      Serail-Demo/Demo/stdafx.h

+ 1 - 1
Serail-Demo/Demo/Serial.cpp

@@ -8,7 +8,7 @@ VOID _dprintf(CHAR* pszStr, ...)
 #if _MSC_VER >= 1200 && _MSC_VER < 1500
 	sprintf(szData, _T("[%s %s]\n\t"), _T("Db"), CTime::GetCurrentTime().Format(_T("%H:%M:%S")));
 #elif _MSC_VER >= 1500
-	_stprintf_s(szData, _T("[%s %s]\n\t"), _T("Db"), CTime::GetCurrentTime().Format(_T("%H:%M:%S")));
+	_stprintf_s(szData, _T("[%s %s]\n\t"), _T("Db"), CTime::GetCurrentTime().Format(_T("%H:%M:%S")).GetString());
 #endif
 	int len = strlen(szData);
 	va_list args;

+ 25 - 3
Serail-Demo/Demo/stdafx.cpp

@@ -136,11 +136,11 @@ int parse_cmd_param_from_file(TCHAR *file_name, std::vector<CommandParam> &vtCom
 			std::string value;
 			parse_key(value, option, _T("Option"));
 			if ( !_tcsicmp(value.c_str(), _T("None")) )
-				cp.nOption = 0;
+				cp.nOption = CMDOPT_None;
 			else if (!_tcsicmp(value.c_str(), _T("Get")))
-				cp.nOption = 1;
+				cp.nOption = CMDOPT_Get;
 			else if (!_tcsicmp(value.c_str(), _T("Set")))
-				cp.nOption = 2;
+				cp.nOption = CMDOPT_Set;
 
 			parse_key(value, multicode, _T("MultiParams"));
 			cp.bMulticode = !_tcsicmp(value.c_str(), _T("true")) ? true : false;
@@ -340,4 +340,26 @@ std::string PackingCommand(CommandParam &cmdPara, std::string data, const int &d
 	command.append((char *)szcrc, 2);
 
 	return command;
+}
+
+void ParseResultString(CommandParam& cmdPara, std::string data, const int& dataLen)
+{
+	if ( data.size() < 5) {
+		return;
+	}
+
+	byte rtnCode = 0xAB;
+	std::string head = cmdPara.head.substr(0, 2);
+	if ( !_tcsicmp(_T("AA"), head.c_str()) ) { // 调试用命令代码引导码;
+		rtnCode = 0xAB;
+	}
+	else if (!_tcsicmp(_T("AC"), head.c_str())) {// 软件配屏参数调整命令代码引导码;
+		rtnCode = 0xAD;
+	}
+	else if (!_tcsicmp(_T("AE"), head.c_str())) {// 保留命令发送类型引导码;
+		rtnCode = 0xAF;
+	}
+
+	int nTakenLen = 0;				// 已取出的长度;
+	unsigned short usCRCValue;		// CRC验证值;
 }

+ 7 - 1
Serail-Demo/Demo/stdafx.h

@@ -30,6 +30,12 @@
 #include <vector>
 #include "Serial.h"
 
+enum CMDOPT
+{
+	CMDOPT_None = 0,
+	CMDOPT_Get = 1,
+	CMDOPT_Set = 2
+};
 
 typedef struct __CMDPARAM__ {
 	std::string name;		// ÃüÁîÃèÊö;
@@ -44,7 +50,7 @@ typedef struct __CMDPARAM__ {
 
 int pares_time_value(std::string strTime);
 bool parse_key(std::string &value, std::string strLine, TCHAR *lpszText);
-int parse_cmd_param_from_file(char *file_name, std::vector<CommandParam> &vtCommandParams);
+int parse_cmd_param_from_file(TCHAR*file_name, std::vector<CommandParam> &vtCommandParams);
 unsigned char TwoHexCharToInteger(char high, char low);
 std::string PackingCommand(CommandParam &cmdPara, std::string data, const int &dataLen);
 std::string BytesToHexString(const unsigned char *pbuffer, int nLen);