serial.h

来自「开发环境为EVC++,这个是一个我的一个简单的拨号程序,是通过串口接的GPRS模」· C头文件 代码 · 共 51 行

H
51
字号
//Mobile control class by SkyVense
//If you modified this file, please send a copy to skyvense@online.sh.cn
//Thank you!


//Last modifed 2002-02-29 by SkyVense

// Serial.h
#ifndef _SERIAL_H
#define _SERIAL_H

#include "stdafx.h"

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

#define FC_DTRDSR       0x01
#define FC_RTSCTS       0x02
#define FC_XONXOFF      0x04
#define ASCII_BEL       0x07
#define ASCII_BS        0x08
#define ASCII_LF        0x0A
#define ASCII_CR        0x0D
#define ASCII_XON       0x11
#define ASCII_XOFF      0x13

DWORD WINAPI ReadPortThread(LPVOID lpvoid); //读数据线程

class CSerial  
{
public:
	CSerial();
	virtual ~CSerial();

protected:
	HANDLE hReadThread;
	BOOL m_bConnected;
	CString m_strChar;
public:
	BOOL InitCommTimeouts(); //设置超时参数  
	BOOL InitDCB(UINT uiBaudRate); //配置串口

	BOOL ClosePort(HANDLE hCommPort); //关闭串口
	BOOL OpenPort(LPTSTR lpszPortName,UINT uiBaudRate); //打开串口
	DWORD WritePort(TCHAR *buf,DWORD dwBytesToWrite); //写数据
	CString GetPortData();
	void ClosePort();//关闭串口 API
};

#endif

⌨️ 快捷键说明

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