⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 comm.h

📁 一个串口通信的实例(含源码)ComToCom,我自己写的
💻 H
字号:
// comm.h : interface of the CTerminalDoc class
//
/////////////////////////////////////////////////////////////////////////////

#if !defined(AFX_COMM_H__C1B7F88B_015E_11D4_8CF5_B1CA1B5BB3E3__INCLUDED_)
#define AFX_COMM_H__C1B7F88B_015E_11D4_8CF5_B1CA1B5BB3E3__INCLUDED_

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

#define MAXBLOCK 2048
#define XON 0x11
#define XOFF 0x13

UINT CommProc(LPVOID pParam);

class CComm
{
// Attributes
public:
CWinThread* m_pThread; // 代表辅助线程
volatile BOOL m_bConnected,m_bRinging;
volatile HWND m_hTermWnd;
volatile HANDLE m_hPostMsgEvent; // 用于WM_COMMNOTIFY消息的事件对象
OVERLAPPED m_osRead, m_osWrite; // 用于重叠读/写
volatile HANDLE m_hCom; // 串行口句柄
int m_nBaud;
int m_nDataBits;
BOOL m_bEcho;
int m_nFlowCtrl;
BOOL m_bNewLine;
int m_nParity;
CString m_sPort;
int m_nStopBits;

// Operations
public:
BOOL ConfigConnection();
BOOL OpenConnection();
void CloseConnection();
DWORD ReadComm(char *buf,DWORD dwLength);
DWORD WriteComm(char *buf,DWORD dwLength);
LRESULT OnCommNotify(WPARAM wParam, LPARAM lParam);

// Implementation
public:
CString m_strTel;
CComm();
virtual ~CComm();

protected:
};

/////////////////////////////////////////////////////////////////////////////

//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.

#endif // !defined(AFX_COMM_H__C1B7F88B_015E_11D4_8CF5_B1CA1B5BB3E3__INCLUDED_)

⌨️ 快捷键说明

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