如何设置DCB的值? [英] How do I set the value of DCB?
本文介绍了如何设置DCB的值?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在我的VC ++串口通讯代码中,
我想知道如何设置串口配置的DCB值:
如果我选择3种类型的流量控制值:
1. Xon / Xoff
2.无
3. RTS / CTS
然后,
DCB.f .... = false或true ...
你明白我的意思吗?
提前谢谢。
我的尝试:
这个问题浪费了1天。
In my VC++ code of serial communications,
I want to know how to set the values of DCB of configuration of serial ports.:
If I select a flow control value of 3 types :
1. Xon/Xoff
2. None
3. RTS/CTS
and then,
DCB.f.... = false or true...
Could you understand what I mean?
Thank you in advance.
What I have tried:
More 1 days wasted for this problem.
推荐答案
参见DCB结构(Windows) [ ^ ]。
先清除DCB然后再设置必填字段:
Clear the DCB first and then set the required fields:
DCB dcb;
::ZeroMemory(&dcb, sizeof(dcb));
dcb.DCBlength = sizeof(dcb);
dcb.fBinary = TRUE; // must be always true
// Use your settings here (this is 9600 baud 8N1)
dcb.BaudRate = CBR_9600;
dcb.ByteSize = 8;
//dcb.Parity = NOPARITY; // (NOPARITY == 0)
dcb.StopBits = ONESTOPBIT;
// No flow control: Nothing to do
// RTS/CTS
dcb.fOutxCtsFlow = TRUE;
// EDIT: Must be off course RTS
//dcb.fDtrControl = DTR_CONTROL_HANDSHAKE;
dcb.fRtsControl = RTS_CONTROL_HANDSHAKE;
// XON/XOFF
dcb.fOutX = dcb.fInX = TRUE;
dcb.XonChar = '\x11';
dcb.XoffChar = '\x13';
dcb.fTXContinueOnXoff = TRUE; // optional / depends
// These depend on the input buffer size (passed to SetupComm()).
// Below are commonly used values (50 / 75 %).
dcb.XonLim = RxBufSize - (RxBufSize / 2);
dcb.XoffLim = RxBufSize - (RxBufSize / 4);
这篇关于如何设置DCB的值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文