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

📄 remoapi.h

📁 串口传输数据库函数
💻 H
字号:
/*************************************************************************************/
/*                 UART.DLL                                                          */
/* The UART.DLL si the dynamic linking library(DLL)designed for Windows 95/98        */
/* NT 3.51/4.0/2000/XP applications. The users can apply it to develop their own     */
/* serial COM port program through many programming languages such as VC++,BC++      */
/* Builder,VB and Delphi.                                                            */
/*									                                                 */
/*  Please refer to the DCON_DLL.pdf located                                         */
/*  for more detail regarding the Uart.dll functions                                 */
/*													                                 */
/* Modification History:					                                         */
/* v2.04[Sep/19/2003] by sean			                                             */
/*				Modify the source code for Miscosoft OS and WinCE OS                 */
/* v2.03[Jun/01/2003] by sean]														 */
/*				New: DataSizeInCom,SetLineStatus, GetLineStatus, DataSizeOutCom      */
/*				Modify: Receive_Binary,vxc_write									 */
/*				Fix:  Fix the input limitation to exceed 1024 bytes					 */
/* V2.02[2003] by Sean																	 */
/*				New: Send_Receive_Cmd_WithChar,Send_Cmd_WithChar,Receive_Cmd_WithChar*/
/*     				 and Receive_Binary_MOS() 										 */
/* V2.00[Mar/17/2002] by Kevin														 */
/*				Refer to version.txt for more details                                */	
/*************************************************************************************/

#ifdef _WIN32_WCE   //Provided for WinCon
	#define EXPORTS UARTCE_API
//	#define CALLBACK ""
	#include <UARTCE.h>
//	#ifndef __UART_H__
//	#define __UART_H__	

#else
//#ifdef WIN32 //Provided for PC (Microsoft OS)
	#ifndef EXPORTS
		#ifdef __cplusplus
			#define EXPORTS extern "C" __declspec(dllimport)
		#else
			#define EXPORTS __declspec(dllimport)
		#endif
	#endif
#endif

//#define EXPORTS

#define    Data5Bit                     5
#define    Data6Bit                     6
#define    Data7Bit                     7
#define    Data8Bit                     8

#define    NonParity                    0
#define    OddParity                    1
#define    EvenParity                   2

#define    OneStopBit                   0
#define    One5StopBit                  1
#define    TwoStopBit                   2

// return code
#define    NoError                      0
#define    FunctionError                1
#define    PortError                    2
#define    BaudRateError                3
#define    DataError                    4
#define    StopError                    5
#define    ParityError                  6
#define    CheckSumError                7
#define    ComPortNotOpen               8
#define    SendThreadCreateError        9
#define    SendCmdError                 10
#define    ReadComStatusError           11
#define    ResultStrCheckError          12
#define    CmdError                     13
#define    TimeOut                      15
#define    ModuleIdError                17
#define    AdChannelError               18
#define    UnderInputRange              19
#define    ExceedInputRange             20
#define    InvalidateCounterNo          21
#define    InvalidateCounterValue       22
#define    InvalidateGateMode           23
#define    InvalidateChannelNo          24
#define    ComPortInUse                 25

EXPORTS WORD CALLBACK Get_RemCom_Version(void);
/*********************Get_Uart_Version****************************/
/* The function is used to obtain the version information        */
/* Return: Version number ==> For example version 2.0.4          */
/*****************************************************************/	

EXPORTS BOOL  CALLBACK Open_ComRtu(unsigned char cPort,int timeout, DWORD dwBaudrate, char cData, char cParity, char cStop);
/*********************** Open_Com ********************************/
/* This function is used to configure and open the COM port      */
/* cPort:		1~255                                            */
/* dwBaudrate:	150,300,600,1200,2400,4800,9600,19200,38400,     */
/*				57600,115200,230400,460800,921600                */
/* cData:		5,6,7,8                                          */
/* cParity:		0 ==> Non Parity	(NonParity)                  */
/*				1 ==> Odd Parity	(OddParity)                  */
/*				2 ==> Even Parity	(EvenParity)                 */
/* cStop		0 ==> 1 Stop Bit	(OneStopBit)                 */
/*				1 ==> 1.5 Stop Bit	(One5StopBit)                */
/*				2 ==> 2 Stop Bit	(TwoStopBit)                 */
/* Return       NoError : 	 	OK                               */
/*				Others : 		Error code                       */
/*****************************************************************/	
unsigned GetCRC16(unsigned char *puchMsg, int DataLen);
EXPORTS WORD CALLBACK Change_Baudrate(unsigned char cPort, DWORD dwBaudrate);
/*********************** Change_Baudrate***************************/
/* change the baudrate 										      */
/* cPort:		1~255                                             */
/* dwBaudrate:	150,300,600,1200,2400,4800,9600,19200,38400,      */
/*              57600,115200,230400,460800,921600                 */
/* Return: 		NoError : 		OK                                */
/*				Others : 		Error code                        */
/******************************************************************/
EXPORTS WORD CALLBACK Change_Config(unsigned char cPort, DWORD dwBaudrate, char cData, char cParity, char cStop);
/********************************* Change_Config *****************************/
/*This function only can be used to change the configuration of the COM port */
/* cPort:		1~255                                             			 */
/* dwBaudrate:	150,300,600,1200,2400,4800,9600,19200,38400,      			 */
/*              57600,115200,230400,460800,921600                 			 */
/* cData:		5,6,7,8                                                      */
/* cParity:		0 ==> Non Parity	(NonParity)                              */
/*				1 ==> Odd Parity	(OddParity)                              */
/*				2 ==> Even Parity	(EvenParity)                 			 */
/* cStop		0 ==> 1 Stop Bit	(OneStopBit)                 			 */
/*				1 ==> 1.5 Stop Bit	(One5StopBit)                			 */
/*				2 ==> 2 Stop Bit	(TwoStopBit)                 			 */
/* Return: 		NoError : 		OK                                			 */
/*				Others : 		Error code                        			 */
/*****************************************************************************/
EXPORTS WORD CALLBACK Get_Com_Status(unsigned char cPort);
/********************************Get_Com_Status ***************************/
/* cPort:		1~255                                                     */
/* Return: 0 ==> COM port not in use									  */
/*         1 ==> COM port in use										  */
/**************************************************************************/
EXPORTS BOOL  CALLBACK Close_ComRtu(unsigned char cPort);
/********************************* Change_Baudrate****************************/
/*This function closes and releases the resources of the COM port			 */
/* cPort:		1~255														 */
/*****************************************************************************/
EXPORTS BOOL  CALLBACK Send_Receive_Rtu(unsigned char cPort, char szCmd[], int writelen,char
        szResult[], WORD wTimeOut, WORD wChksum, WORD *wT);
/********************************Send_Receive_Cmd ****************************************/
/* cPort:		1~255																	 */
/* szCmd[]:		1024 Bytes maximum, without zero (0x0D) character.						 */
/* szResult[]:	1024 Bytes maximum, with one zero or 0x0D terminal character.			 */
/* wTimeOut:	Timeout for receiving result string. 									 */
/*				Unit: ms (1/1000 second)												 */
/* wChksum:		0   ==> add one 0x0D byte to the end of the szCmd						 */
/*				<>0 ==> add two check sum bytes and one 0x0D byte to the end of the szCmd*/
/* *wT			return a reference number for identify the performance. 				 */
/*				*wT --> 0 :good 														 */
/*****************************************************************************************/
EXPORTS BOOL  CALLBACK Send_Rtu(unsigned char cPort,unsigned  char szCmd[],int writelen,WORD wChksum);
/********************** Send_Cmd *************************************/
/*This function only sends a command string to DCON series modules   */
/*********************************************************************/
EXPORTS BOOL CALLBACK Receive_Rtu(unsigned char cPort, char szResult[], WORD wTimeOut, WORD wChksum, WORD *wT);
/********************* Receive_Cmd ***********************************/
/*This function only sends a command string to DCON series modules   */
/*********************************************************************/
EXPORTS WORD CALLBACK Send_Binary(unsigned char cPort, char szCmd[],int iLen);
/********************** Send_Binary***********************************/
/* Send out the command string by fix length                         */
/* To use protocol that not with 0x0d(CR) end.                       */
/* The function will check 0x0 or 0x20(Space) end.                   */
/* The input buffer will be cleared before sending out string.       */
/*********************************************************************/
EXPORTS WORD CALLBACK Receive_Binary(unsigned char cPort, char szResult[], WORD wTimeOut, WORD wLen, WORD *wT);
/********************** Receive_Binary *******************************/
/* This function is applied to receive the fix length response       */ 
/* To get response that not with 0x0d(CR) end.                       */
/* The function will recive wLen bytes.                              */
/*********************************************************************/
EXPORTS DWORD CALLBACK DataSizeInCom(int port);
/******************** DataSizeOutCom *********************************/
/* Get the how many data existed on the input buffer of COM port     */
/*********************************************************************/
EXPORTS DWORD CALLBACK DataSizeOutCom(int port);
/******************** DataSizeOutCom *********************************/
/* Get the how many data existed on the output buffer of COM port    */
/*********************************************************************/
EXPORTS WORD CALLBACK SetLineStatus(int port,int pin,int mode);
/*************** SetLineStatus ***************/
/* Set the Line status(DTR,RTS)              */ 
/*     pin 0:								 */
/*		   1: DTR							 */
/*		   2: RTS							 */
/*		   3: DTR+RTS					     */
/*	   mode 0:Disable						 */
/*		    1:Enable				         */
/*			2:HandShake			             */
/* return:									 */
/*		  0,ok                               */
/*        < 0,error							 */
/*********************************************/
EXPORTS WORD CALLBACK GetLineStatus(int port,int pin);
/*************** GetLineStatus ***************/
/*                                           */
/* Get the Line status (CTS,DSR,RI,CD)       */ 
/*     pin 0: CTS							 */
/*		   1: DSR							 */
/*		   2: RI							 */
/*		   3: CD     					     */
/* return:									 */
/*		  1,ON                               */
/*        0,OFF 							 */
/*********************************************/
EXPORTS WORD CALLBACK Send_Receive_Cmd_WithChar(unsigned char cPort, char szCmd[], char szResult[], WORD wTimeOut, WORD wChksum, WORD *wT,unsigned char cEndChar);
/*********** Send_Receive_Cmd_WithChar ***************************/
/* Send command and then receive datas                           */
/* with the last character						                 */
/* It is similar to the Send_Receive_Cmd except cEndChar paramter*/
/*****************************************************************/
EXPORTS WORD CALLBACK Send_Cmd_WithChar(unsigned char cPort, char szCmd[],WORD wChksum,unsigned char cEndChar);
/******************************* Send_Cmd_WithChar *******************/
/* Send command with a character	                                 */
/* in the end of string                                              */
/* It is similar to the Send_Cmd_WithChar except cEndChar paramter   */
/*********************************************************************/
EXPORTS WORD CALLBACK Receive_Cmd_WithChar(unsigned char cPort,char szResult[], WORD wTimeOut, WORD wChksum, WORD *wT,unsigned char cEndChar);
/************************** Receive_Cmd_WithChar **********************/
/* Receive command with the last character                            */
/* It is similar to the Receive_Cmd_WithChar except cEndChar paramter */
/**********************************************************************/
EXPORTS WORD CALLBACK Receive_Binary_MOS(unsigned char cPort, LPVOID szResult,WORD wLen);
/************* Receive_Binary_MOS ************/
/* This function is called by MiniOS7 only.  */
/* Ensure to receive the wLen length of		 */
/* the szResult.							 */
/*********************************************/


/*#ifdef _WIN32_WCE
	#endif  //__UART_H__
#endif*/


EXPORTS BOOL CALLBACK GetRtuStrCRC(unsigned  char * source, int length,unsigned char * dest);
char HexChar(char c);
int Str2Hex(CString str, char* data);

⌨️ 快捷键说明

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