UART DCB 流控

来源:互联网 发布:java undefined 判断 编辑:程序博客网 时间:2024/05/17 08:09

DCB (Windows Embedded CE 6.0

This structure defines the control setting for a serial communications device.


typedef struct _DCB {  DWORD DCBlength;  DWORD BaudRate;   DWORD fBinary :1;  DWORD fParity :1;  DWORD fOutxCtsFlow :1;  DWORD fOutxDsrFlow :1;  DWORD fDtrControl :2;  DWORD fDsrSensitivity :1;  DWORD fTXContinueOnXoff :1;  DWORD fOutX :1;  DWORD fInX :1;  DWORD fErrorChar :1;  DWORD fNull :1;  DWORD fRtsControl :2;  DWORD fAbortOnError :1;  DWORD fDummy2 :17;  WORD wReserved;  WORD XonLim;  WORD XoffLim;  BYTE ByteSize;  BYTE Parity;  BYTE StopBits;  char XonChar;  char XoffChar;  char ErrorChar;  char EofChar;  char EvtChar;  WORD wReserved1;} DCB, *LPDCB;
Members

DCBlength

Specifies the DCB structure length, in bytes.

BaudRate

Specifies the baud rate at which the communication device operates. It is an actual baud rate value, or one of the following baud rate indexes:

  • CBR_110
  • CBR_300
  • CBR_600
  • CBR_1200
  • CBR_2400
  • CBR_4800
  • CBR_9600
  • CBR_14400
  • CBR_19200
  • CBR_38400
  • CBR_56000
  • CBR_57600
  • CBR_115200
  • CBR_128000
  • CBR_256000
fBinary

Specifies whether binary mode is enabled. The function does not support nonbinary mode transfers, so this member must be set to TRUE.

fParity

Specifies whether parity checking is enabled. If this member is set to TRUE, parity checking is performed, and errors are reported.

fOutxCtsFlow

Specifies if the clear-to-send (CTS) signal is monitored for output flow control. If this member is set to TRUE and CTS is turned off, output is suspended until CTS is sent again.

fOutxDsrFlow

Specifies if the data-set-ready (DSR) signal is monitored for output flow control. If this member is set to TRUE and DSR is turned off, output is suspended until DSR is sent again.

fDtrControl

Specifies the data-terminal-ready (DTR) flow control. The following table shows possible values.

ValueDescription

DTR_CONTROL_DISABLE

Disables the DTR line when the device is opened and leaves it disabled.

DTR_CONTROL_ENABLE

Enables the DTR line when the device is opened and leaves it on.

DTR_CONTROL_HANDSHAKE

Enables DTR handshaking.

If handshaking is enabled, it is an error for the application to adjust the line by using theEscapeCommFunction function.

fDsrSensitivity

Specifies whether the communications driver is sensitive to the state of the data-send-ready (DSR) signal. If this member is set to TRUE, the driver ignores bytes received, unless the DSR modem input line is high.

fTXContinueOnXoff

Specifies whether transmission stops when the input buffer is full and the driver has transmitted theXoffChar character. If this member is set to TRUE, transmission continues after the input buffer has come withinXoffLim bytes of being full and the driver has transmitted the XoffChar character to stop receiving bytes.

If this member is set to FALSE, transmission does not continue until the input buffer is withinXonLim bytes of being empty and the driver has transmitted theXonChar character to resume reception.

fOutX

Specifies whether XON/XOFF flow control is used during transmission. If this member is set to TRUE, transmission stops when theXoffChar character is received and starts again when theXonChar character is received.

fInX

Specifies whether XON/XOFF flow control is used during reception. If this member is set to TRUE, theXoffChar character is sent when the input buffer comes withinXoffLim bytes of being full, and the XonChar character is sent when the input buffer comes withinXonLim bytes of being empty.

fErrorChar

Specifies whether bytes received with parity errors are replaced with the character specified by theErrorChar member. If this member is set to TRUE and thefParity member is set to TRUE, replacement occurs.

fNull

Specifies whether null bytes are discarded. If this member is set to TRUE, null bytes are discarded when received.

fRtsControl

Specifies the request-to-send (RTS) flow control. If this value is set to zero, the default is RTS_CONTROL_HANDSHAKE. The following table shows possible values.

ValueDescription

RTS_CONTROL_DISABLE

Disables the RTS line when the device is opened and leaves it disabled.

RTS_CONTROL_ENABLE

Enables the RTS line when the device is opened and leaves it on.

RTS_CONTROL_HANDSHAKE

Enables RTS handshaking.

The driver raises the RTS line when the type-ahead (input) buffer is less than half full and lowers the RTS line when the buffer is more than three-quarters full.

If handshaking is enabled, it is an error for the application to adjust the line by using theEscapeCommFunction function.

RTS_CONTROL_TOGGLE

Specifies that the RTS line is high if bytes are available for transmission.

After all buffered bytes are sent, the RTS line is low.

fAbortOnError

Specifies whether read and write operations are terminated if an error occurs. If this member is set to TRUE, the driver terminates all read and write operations with an error status if an error occurs. The driver does not accept further communications operations until the application acknowledges the error by calling the ClearCommError function.

fDummy2

Reserved; do not use.

wReserved

Not used; set to zero.

XonLim

Specifies the minimum number of bytes accepted in the input buffer before the XON character is sent.

XoffLim

Specifies the maximum number of bytes accepted in the input buffer before the XOFF character is sent. The maximum number of bytes accepted is calculated by subtracting this value from the size, in bytes, of the input buffer.

ByteSize

Specifies the number of bits in the bytes transmitted and received.

Parity

Specifies the parity scheme to be used. The following table shows possible values.

ValueDescription

EVENPARITY

Even

MARKPARITY

Mark

NOPARITY

No parity

ODDPARITY

Odd

SPACEPARITY

Space

StopBits

Specifies the number of stop bits to be used. The following table shows possible values.

ValueDescription

ONESTOPBIT

1 stop bit

ONE5STOPBITS

1.5 stop bits

TWOSTOPBITS

2 stop bits

XonChar

Specifies the value of the XON character for both transmission and reception.

XoffChar

Specifies the value of the XOFF character for both transmission and reception.

ErrorChar

Specifies the value of the character used to replace bytes received with a parity error.

EofChar

Specifies the value of the character used to signal the end of data.

EvtChar

Specifies the value of the character used to signal an event.

wReserved1

Reserved; do not use.

Remarks

The sample serial port PDD driver is in the %_WINCEROOT%\Public\Common\Oak\Drivers\Serial directory.

All directories under the Serial folder contain sample serial PDD drivers except for the COM_MDD and COM_MDD2 folders.

 

以上on/off对应rs232电平
信号有效(接通,ON状态,正电压)=+3V~+15V
信号无效(断开,OFF状态,负电压)=-3V~-15V
 
数据发送准备好(Data set ready-DSR)——有效时(ON)状态,表明MODEM处于可以使用的状态。
数据终端准备好(Data terminal ready-DTR)——有效时(ON)状态,表明数据终端可以使用。
这两个信号有时连到电源上,一上电就立即有效。这两个设备状态信号有效,只表示设备本身可用,并不说明通信链路可以开始进行通信了,能否开始进行通信要由下面的控制信号决定。
请求发送(Request to send-RTS)——用来表示DTE请求DCE发送数据,即当终端准备要接收MODEM传来的数据时,使该信号有效(ON状态),请求MODEM发送数据。它用来控制MODEM是否要进入发送状态。
允许发送(Clear to send-CTS)——用来表示DCE准备好接收DTE发来的数据,是与请求发送信号RTS相应的信号。当MODEM准备好接收终端传来的数据,并向前发送时,使该信号有效,通知终端开始沿发送数据线TxD发送数据。
这对RTS/CTS请求应答联络信号是用于半双工MODEM系统中发送方式和接收方式之间的切换。在全双工系统中,因配置双向通道,故不需要RTS/CTS联络信号,使其变高。
接收线信号检出(Received Line detection-RLSD)——用来表示DCE已接通通信链路,告知DTE准备接收数据。当本地的MODEM收到由通信链路另一端(远地)的MODEM送来的载波信号时,使RLSD信号有效,通知终端准备接收,并且由MODEM将接收下来的载波信号解调成数字两数据后,沿接收数据线RxD送到终端。此线也叫做数据载波检出(Data Carrier dectection-DCD)线。
振铃指示(Ringing-RI)——当MODEM收到交换台送来的振铃呼叫信号时,使该信号有效(ON状态),通知终端,已被呼叫。
 
发送数据(Transmitted data-TxD)——通过TxD终端将串行数据发送到MODEM,(DTE→DCE)。
接收数据(Received data-RxD)——通过RxD线终端接收从MODEM发来的串行数据,(DCE→DTE)。
 
 GND、Sig.GND——保护地和信号地,无方向。
上述控制信号线何时有效,何时无效的顺序表示了接口信号的传送过程。例如,只有当DSR和DTR都处于有效(ON)状态时,才能在DTE和DCE之间进行传送操作。若DTE要发送数据,则预先将DTR线置成有效(ON)状态,等CTS线上收到有效(ON)状态的回答后,才能在TxD线上发送串行数据。这种顺序的规定对半双工通信线路特别有用,因为半双工的通信才能确定DCE已由接收方向改为发送方向,这时线路才能开始发送。
 
UART包含TTL电平的串口和RS232电平的串口。 TTL电平是3.3V的,而RS232是负逻辑电平,它定义+5~+12V为低电平,而-12~-5V为高电平
 
RS-232  传送距离最大为约15米,最高速率为20kb/s
 
http://baike.baidu.com/view/112004.htm?fromId=196461
http://msdn.microsoft.com/zh-cn/library/ee488022(v=winembedded.60)
http://baike.baidu.com/view/161117.htm?fromId=69108