|
@@ -27,7 +27,7 @@ bool CDevice::IsOpen()
|
|
return m_obj.IsOpen();
|
|
return m_obj.IsOpen();
|
|
}
|
|
}
|
|
|
|
|
|
-std::string CDevice::SendCommond(std::string cmd)
|
|
|
|
|
|
+std::string CDevice::SendCommond(std::string cmd, int device_timeout)
|
|
{
|
|
{
|
|
if ( !m_obj.IsOpen() )
|
|
if ( !m_obj.IsOpen() )
|
|
return std::string("串口未打开成功");
|
|
return std::string("串口未打开成功");
|
|
@@ -36,16 +36,17 @@ std::string CDevice::SendCommond(std::string cmd)
|
|
if ( dwRet != cmd.size() )
|
|
if ( dwRet != cmd.size() )
|
|
return std::string("写串口失败");
|
|
return std::string("写串口失败");
|
|
|
|
|
|
|
|
+ /*
|
|
// 如果是tim和ptn同时运行;
|
|
// 如果是tim和ptn同时运行;
|
|
std::string pattern{ "run tim (\\d{1,3});run ptn (\\d{1,3});\r" }; // fixed telephone
|
|
std::string pattern{ "run tim (\\d{1,3});run ptn (\\d{1,3});\r" }; // fixed telephone
|
|
std::regex re(pattern);
|
|
std::regex re(pattern);
|
|
WORD timeout = 300;
|
|
WORD timeout = 300;
|
|
if (std::regex_match(cmd, re))
|
|
if (std::regex_match(cmd, re))
|
|
- timeout = 1000;
|
|
|
|
-
|
|
|
|
|
|
+ timeout = 2000;
|
|
|
|
+ */
|
|
|
|
|
|
byte szData[1024 * 4] = {0};
|
|
byte szData[1024 * 4] = {0};
|
|
- dwRet = m_obj.ReadComm(szData, 1024 * 4, timeout);
|
|
|
|
|
|
+ dwRet = m_obj.ReadComm(szData, 1024 * 4, device_timeout);
|
|
if (dwRet == 0 )
|
|
if (dwRet == 0 )
|
|
return std::string("读串口失败");
|
|
return std::string("读串口失败");
|
|
|
|
|