comm.h

来自「 ?  plc 与上位机通信接口 帮助有需要的人」· C头文件 代码 · 共 49 行

H
49
字号
// Comm.h: interface for the CComm class.
//
//////////////////////////////////////////////////////////////////////

#if !defined(AFX_COMM_H__73119259_90C0_4E90_9BC8_8F37B3E54055__INCLUDED_)
#define AFX_COMM_H__73119259_90C0_4E90_9BC8_8F37B3E54055__INCLUDED_

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000

#include <afx.h>
#define INVALID_HANDLE_VALUE    (HANDLE)-1

#define    FAIL     0
#define    SUCCESS  1

class AFX_EXT_CLASS CComm  
{
public:
	int m_iPortID;
	int m_iBaudRate;
	int m_iBytesize;
	int m_iParity;
	int m_iStopBits;
	int m_iStations;
	HANDLE m_hComm;

public:
	CComm();
	virtual ~CComm();


protected:
	CRITICAL_SECTION	csComBuffer;

public:
	int vSetCommParam(int portid, int baudrate, int parity, int stopbits, int bytesize);
	int InitComm();
	int GetCommInfo(DCB  &dcb, int &iPortId);
	int CloseComm();
	int WritePort(BYTE *pBuf, UINT uLength, int msTimeOut);
	int ReadPort( BYTE *pBuf, int &iLength, int msTimeOut);

protected:
	BOOL SetRWTimeout(int msRITO, int msRTTOM, int msRTTOC, int msWTTOM, int msWTTOC);
};
#endif // !defined(AFX_COMM_H__73119259_90C0_4E90_9BC8_8F37B3E54055__INCLUDED_)

⌨️ 快捷键说明

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