12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758 |
- #include "stdafx.h"
- #include "Demo.h"
- #ifdef _DEBUG
- #define new DEBUG_NEW
- #endif
- CWinApp theApp;
- using namespace std;
- int _tmain(int argc, TCHAR* argv[], TCHAR* envp[])
- {
- int nRetCode = 0;
-
- if (!AfxWinInit(::GetModuleHandle(NULL), NULL, ::GetCommandLine(), 0))
- {
-
- _tprintf(_T("错误: MFC 初始化失败\n"));
- nRetCode = 1;
- }
- else
- {
-
- CBaseSerial sb;
- if ( sb.Open(23, _T("baud=115200 parity=N data=8 stop=1") ) )
- {
- sb.SetTimeouts();
- std::vector<CommandParam> vtCommandParams;
- parse_cmd_param_from_file("F:\\source\\scbc_repos\\Serail-Demo\\Demo\\command.data", vtCommandParams);
- for ( std::vector<CommandParam>::iterator it = vtCommandParams.begin(); it != vtCommandParams.end(); it++ )
- {
- byte szData[1024] = {0};
- std::string cmd = PackingCommand(*it, _T(""), 0);
-
- if ( sb.Write((void*)cmd.c_str(), cmd.size()) )
- {
- Sleep(it->read_wait_time);
- int c = sb.Read(szData, 1024);
- int a = 0;
- }
- }
- }
- system("pause");
- }
- return nRetCode;
- }
|