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

📄 defines.h

📁 简单的 RS232 串口通信测试程序,可以做到资料的传送与接收
💻 H
字号:
#include <Windows.h>
#include <Winbase.h>
#include <stdio.h>
#if	!defined(DEFINES_H)
#define DEFINES_H

/*****************************************************************************/
//Typisierungen
typedef HANDLE EVENT;

typedef void (CALLBACK * COMM_SIGNAL)
(
	HANDLE	hHandle,
	DWORD	dwErrorCode,	//Fehlercode sollte immer "0" sein
	DWORD	InQueCount,
	DWORD	Event
);

typedef void (CALLBACK * COMM_ERROR)
(
	HANDLE	hHandle,
	DWORD	dwErrorCode,	//Fehlercode sollte immer "0" sein
	char*	ErrorMessage
);

/*****************************************************************************/
//Konstanten
#define		OPENERRORSTRING			"Error accessing specified device"
#define		INVALIDHANDLESTRING		"Invalid device handle, access denied"
#define		ALREADYOPENEDSTRING		"Port already assigned (open)"
#define		CANTOPENSTRING			"Port not open, unable to complete operation"
#define		SETUPCOMMERRORSTRING	"initializing Read/Write Buffers failed"
#define		DCBERRORSTRING			"Error updating DataControlBlock"
#define		TIMEOUTERRORSTRING		"Error updating CommTimeouts"
#define		READERRORSTRING			"Read error"
#define		WRITEERRORSTRING		"Write error"
#define		INVALIDNAME				"the specified device-name is invalid"
#define		INVALIDCHOISE			"the choosed value is invalid"
#define		FUNCTIONFAILED			"there was an error in the last call (try again)"
#define		THREADDONE				"programm is not waiting for comm-events"
#define		THREADTIMEOUT			"there was no event in between the specified timevalue"

#define		OFF					0x00
#define		ON					0x01

#define		NONE				0
#define		CTS					1
#define		DTR					2
#define		SWR					3

#define		CTS_ON				1
#define		DSR_ON				2
#define		RING_ON				3
#define		RLSD_ON				4
		
#define		DEFAULTCOMNAME		"Com2"

#define		MAX_BUFFERSIZE		0x1000
#define		MAX_READTIMEOUT		0x1000

#define		PURGEREAD			PURGE_RXABORT+PURGE_RXCLEAR
#define		PURGEWRITE			PURGE_TXABORT+PURGE_TXCLEAR
#define		PURGEALL			PURGEREAD+PURGEWRITE

#define		INBUF				1
#define		OUTBUF				2
#define		ALL					3

#endif

⌨️ 快捷键说明

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