// stdafx.h : 标准系统包含文件的包含文件, // 或是经常使用但不常更改的 // 特定于项目的包含文件 // #pragma once #include "targetver.h" #include #include #define _ATL_CSTRING_EXPLICIT_CONSTRUCTORS // 某些 CString 构造函数将是显式的 #ifndef VC_EXTRALEAN #define VC_EXTRALEAN // 从 Windows 头中排除极少使用的资料 #endif #include #include // MFC 核心组件和标准组件 #include // MFC 扩展 #ifndef _AFX_NO_OLE_SUPPORT #include // MFC 对 Internet Explorer 4 公共控件的支持 #endif #ifndef _AFX_NO_AFXCMN_SUPPORT #include // MFC 对 Windows 公共控件的支持 #endif // _AFX_NO_AFXCMN_SUPPORT #include #include #include #include "Serial.h" enum CMDOPT { CMDOPT_None = 0, CMDOPT_Get = 1, CMDOPT_Set = 2 }; typedef struct __CMDPARAM__ { std::string name; // 命令描述; std::string head; // 命令头; std::string code; // 命令码; std::string param; // 命令码参数; // 命令属性类型: // 0=None,只返回一段数据包; // 1=Get,返回一段或两段数据包(成功时返回2段,失败时返回1段); // 2=Set,返回一段或两段数据包(成功时返回1段,失败时返回1段); int nOption; bool bMulticode ; // 命令码是否多参数; int cmd_wait_time ; // 两条串口指令间隔时间; int read_wait_time ; // 写完串口后,等待多久读; byte _rtnCode; byte _rtnStatus; std::string _rtnData; void UpdateRtnCode() { 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; } } __CMDPARAM__() { _rtnCode = 0; _rtnStatus = 0; nOption = 0; bMulticode = false; cmd_wait_time = 100; read_wait_time = 100; } } CommandParam, *pCommandParam; VOID _dprintf(CHAR* pszStr, ...); int pares_time_value(std::string strTime); bool parse_key(std::string &value, std::string strLine, TCHAR *lpszText); int parse_cmd_param_from_file(TCHAR*file_name, std::vector &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); std::string BytesToHexString(const unsigned char *pbuffer, int nLen, char chSpace); // TODO: 在此处引用程序需要的其他头文件