WEB开发网
开发学院软件开发VC 深入浅出VC++串口编程之基于Win32 API 阅读

深入浅出VC++串口编程之基于Win32 API

 2008-10-09 19:26:55 来源:WEB开发网   
核心提示: 配置串口配置串口是通过改变设备控制块DCB(Device Control Block) 的成员变量值来实现的,接收缓冲区和发送缓冲区的大小可通过SetupComm函数来设置,深入浅出VC++串口编程之基于Win32 API(2),DCB结构体定义为:typedef struct _DCB

配置串口

配置串口是通过改变设备控制块DCB(Device Control Block) 的成员变量值来实现的,接收缓冲区和发送缓冲区的大小可通过SetupComm函数来设置。

DCB结构体定义为:

typedef struct _DCB { // dcb
 DWORD DCBlength; // sizeof(DCB)
 DWORD BaudRate; // current baud rate
 DWORD fBinary: 1; // binary mode, no EOF check
 DWORD fParity: 1; // enable parity checking
 DWORD fOutxCtsFlow:1; // CTS output flow control
 DWORD fOutxDsrFlow:1; // DSR output flow control
 DWORD fDtrControl:2; // DTR flow control type
 DWORD fDsrSensitivity:1; // DSR sensitivity
 DWORD fTXContinueOnXoff:1; // XOFF continues Tx
 DWORD fOutX: 1; // XON/XOFF out flow control
 DWORD fInX: 1; // XON/XOFF in flow control
 DWORD fErrorChar: 1; // enable error replacement
 DWORD fNull: 1; // enable null stripping
 DWORD fRtsControl:2; // RTS flow control
 DWORD fAbortOnError:1; // abort reads/writes on error
 DWORD fDummy2:17; // reserved
 WORD wReserved; // not currently used
 WORD XonLim; // transmit XON threshold
 WORD XoffLim; // transmit XOFF threshold
 BYTE ByteSize; // number of bits/byte, 4-8
 BYTE Parity; // 0-4=no,odd,even,mark,space
 BYTE StopBits; // 0,1,2 = 1, 1.5, 2
 char XonChar; // Tx and Rx XON character
 char XoffChar; // Tx and Rx XOFF character
 char ErrorChar; // error replacement character
 char EofChar; // end of input character
 char EvtChar; // received event character
 WORD wReserved1; // reserved; do not use
} DCB;
而SetupComm函数的原型则为:
BOOL SetupComm(
 HANDLE hFile, // handle to communications device
 DWORD dwInQueue, // size of input buffer
 DWORD dwOutQueue // size of output buffer
);

上一页  1 2 3 4  下一页

Tags:深入浅出 VC 串口

编辑录入:爽爽 [复制链接] [打 印]
赞助商链接