com.h

来自「串口通信」· C头文件 代码 · 共 63 行

H
63
字号
///////////////////////////////////////////////////////////////////////////////
// Com.h
//

#ifndef _COM_H
#define _COM_H

#ifdef LIBAPI

#else

#define LIBAPI extern "C" __declspec(dllimport)

#endif


/*****************************************************
 SERIAL COMMUNICATION(SC)
 *****************************************************/

// 返回值
const UINT SC_SUCCESS					= 0x00000000;
const UINT SC_FAILED					= 0x00000001;
const UINT SC_COM_ERROR_NUM				= 0x00000002;
const UINT SC_COM_ERROR_GETSTATE		= 0x00000003;
const UINT SC_MOVE_ERROR				= 0x00000004;

// 参数设置函数之type变量的index
const UINT SC_MOVE_FORWARD				= 0x00000100;
const UINT SC_MOVE_SFORWARD				= 0x00000101;
const UINT SC_MOVE_BACK					= 0x00000102;
const UINT SC_MOVE_SBACK				= 0x00000103;
const UINT SC_MOVE_RIGHT				= 0x00000104;
const UINT SC_MOVE_LEFT					= 0x00000105;
const UINT SC_MOVE_NIP					= 0x00000106;
const UINT SC_MOVE_LOOSE				= 0x00000107;

//int OpenOrClose=0;

// 结构体参数
typedef struct tagMOVEPARAM
{
	UINT		 nCommID;		//串口号
	unsigned int n;				//步数或旋转度数
}MOVEPARAM, *LPMOVEPARAM;

///////////////////////////////////////////////////////////////////////////////
// 函数

// 打开串口, 参数为串口号 1 or 2
LIBAPI HRESULT SC_CreatCom(int n);

// 关闭串口, LPVOID lpParam=NULL
LIBAPI HRESULT SC_CloseCom(UINT nCommID, LPVOID lpParam);

// 移动
LIBAPI HRESULT SC_Move(const UINT type, LPVOID lpParam);

// 读串口, LPVOID lpParam=NULL
LIBAPI HRESULT SC_ReadBuffer(UINT nCommID, char *InBuffer, LPVOID lpParam);

#endif // _COM_H

⌨️ 快捷键说明

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