?? asyn_com2.cpp
字號:
#include <iostream>
#include <exception>
using namespace std;
#include <windows.h>
#include "com_class.h"
int main(int argc, char *argv[])
{
try
{
char str[100];
_asyn_com com2; //異步
com2.open(2); // 相當于 com2.open(2, 9600); com2.open(2, "9600,8,n,1");
if(!com2.is_open())
cout << "COM2 not open , error : " << GetLastError() << endl;
/*
if(!com2.open(2))
cout << "COM2 not open , error : " << GetLastError() << endl;
*/
for(int i=0; i<100; i++)
{
Sleep(500);
if(com2.read(str, 100) > 0)//異步讀,返回讀取字符數
cout << str;
}
com2.close();
}
catch(exception &e)
{
cout << e.what() << endl;
}
return 0;
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -