Settings | Sign in | Sign up

The author has 12 posts.

【程式】串口操作程式

Floor 12 巨大八爪鱼 7/17/16 22:48
if (!SetCommState(hComm, &cfg.dcb))
    cout << TEXT("設置失敗") << endl;
然後在調用SetCommState函數時傳入設備管理器裏面的dcb就要安全很多。
Floor 14 巨大八爪鱼 7/18/16 16:53

【直接填寫結構體法】

DCB dcb;
ZeroMemory(&dcb, sizeof(dcb));
dcb.DCBlength = sizeof(DCB);
dcb.BaudRate = CBR_9600;
dcb.ByteSize = 8;
dcb.fBinary = TRUE; // 必須是二進制方式傳輸
if (!SetCommState(hComm, &dcb))
   cout << TEXT("設置失敗") << endl;

Content converter:

Reply the post
Content:
User: You are currently anonymous.
Captcha:
Unclear? Try another one.