|
@@ -1,6 +1,6 @@
|
|
|
#include "StdAfx.h"
|
|
|
#include "Device.h"
|
|
|
-#include "Device.h"
|
|
|
+#include <regex>
|
|
|
|
|
|
std::map<int, CDevice*> g_dmap;
|
|
|
CDevice::CDevice()
|
|
@@ -36,8 +36,16 @@ std::string CDevice::SendCommond(std::string cmd)
|
|
|
if ( dwRet != cmd.size() )
|
|
|
return std::string("写串口失败");
|
|
|
|
|
|
+ // 如果是tim和ptn同时运行;
|
|
|
+ std::string pattern{ "run tim (\\d{1,3});run ptn (\\d{1,3});\r" }; // fixed telephone
|
|
|
+ std::regex re(pattern);
|
|
|
+ WORD timeout = 300;
|
|
|
+ if (std::regex_match(cmd, re))
|
|
|
+ timeout = 1000;
|
|
|
+
|
|
|
+
|
|
|
byte szData[1024 * 4] = {0};
|
|
|
- dwRet = m_obj.ReadComm(szData, 1024 * 4);
|
|
|
+ dwRet = m_obj.ReadComm(szData, 1024 * 4, timeout);
|
|
|
if (dwRet == 0 )
|
|
|
return std::string("读串口失败");
|
|
|
|