comm.h

来自「磁卡读写测试程序」· C头文件 代码 · 共 47 行

H
47
字号
#ifndef _COMM_H__
#define _COMM_H__
#define MAXBUFLEN	250
#define BUFFLEN		4096
#define MAXBLOCKLEN	256

typedef struct _COMM_INFO
{
	HANDLE hComm;		//comm handle
	DCB dcb;
	BOOL bConnection;	//mark the comm is open or not

	COMMTIMEOUTS cto;	//set timeouts

	HANDLE hCommWatch;	//thread handle
	DWORD dwTID;		//thread identifier

	HANDLE hEvent;
	OVERLAPPED osWait;
	OVERLAPPED osRead;
	OVERLAPPED osWrite;
}COMMINFO , *LPCOMMINFO;

BOOL WriteBlock(LPCOMMINFO,LPVOID lpData, DWORD dwlen);
DWORD ReadBlock(LPCOMMINFO,LPVOID lpData, DWORD dwMaxLen);
DWORD Read(LPCOMMINFO,BYTE* pBuffer);
BOOL InitComm( LPCOMMINFO m_info,const char* strCom);
BOOL  DestroyComm(LPCOMMINFO m_info);
LPCOMMINFO BuildComm(LPCOMMINFO info,
    long DCBlength,				     // sizeof(DCB) .
    long BaudRate,					// current baud rate .
    BOOL fBinary,							// binary mode, no EOF check 
    BOOL fParity,							// enable parity checking 
    int fOutxCtsFlow,						// CTS output flow control 
    int fOutxDsrFlow,						// DSR output flow control 
    int fDtrControl,		// DTR flow control type 
    int fOutX,								// XON/XOFF out flow control 
    int fInX,								// XON/XOFF in flow control 
    int fRtsControl,		// RTS flow control 
    int fAbortOnError,						// abort reads/writes on error 
    int XonLim,							// transmit XON threshold 
    int XoffLim,							// transmit XOFF threshold 
    int ByteSize,							// number of bits/byte, 4-8 .
    int Parity=NOPARITY,						// 0-4=no,odd,even,mark,space .
    int StopBits=ONESTOPBIT					// 0,1,2 = 1, 1.5, 2 
		 );
#endif

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?