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

📄 sio.h

📁 moxa串口服务器串口cts_rts_dsr_dtr应用程序源码
💻 H
字号:
/* Company      : MOXA Technologies Co., Ltd.                                */
/* Filename     : sio.c                                                      */
/* Description  :                                                            */
/* Product      : Serial Sample Code for UC7420                              */
/* Programmer   : Jared Wu		                                               */
/* Date         : 2005-06-20                                                 */
/*****************************************************************************/
#ifndef _SIO_H_
#define _SIO_H_
#endif


#define CONSOLE_PORT	100

/*	BAUD rate setting	*/
#define BAUD_50			0x00
#define BAUD_75			0x01
#define BAUD_110		0x02
#define BAUD_134		0x03
#define BAUD_150		0x04
#define BAUD_300		0x05
#define BAUD_600		0x06
#define BAUD_1200		0x07
#define BAUD_1800		0x08
#define BAUD_2400		0x09
#define BAUD_4800		0x0A
#define BAUD_7200		0x0B
#define BAUD_9600		0x0C
#define BAUD_19200		0x0D
#define BAUD_38400		0x0E
#define BAUD_57600		0x0F
#define BAUD_115200 	0x10
#define BAUD_230400 	0x11
#define BAUD_460800 	0x12
#define BAUD_921600 	0x13

/*	MODE setting		*/
#define BIT_5			0x00			/* Word length define	    */
#define BIT_6			0x01
#define BIT_7			0x02
#define BIT_8			0x03

#define STOP_1			0x00			/* Stop bits define	        */
#define STOP_2			0x04

#define P_EVEN			0x18			/* Parity define	        */
#define P_ODD			0x08
#define P_SPC			0x38
#define P_MRK			0x28
#define P_NONE			0x00

/* Flow control setting 	*/
#define F_NONE          0x00            /* No flow control          */
#define F_CTS			0x01			/* CTS flow control         */
#define F_RTS			0x02			/* RTS flow control         */
#define F_HW			0x03			/* Hardware flowcontrol     */
#define F_TXSW			0x04			/* Tx XON/XOFF flow control */
#define F_RXSW			0x08			/* Rx XON/XOFF flow control */
#define F_SW			0x0C			/* Sofeware flowcontrol     */

/* Flush */
#define FLUSH_RX		0x00
#define FLUSH_TX		0x01
#define	FLUSH_ALL		0x02

/*	MODEM CONTROL setting	*/
#define C_DTR			0x01
#define C_RTS			0x02

/*	MODEM LINE STATUS	*/
#define S_CTS			0x01
#define S_DSR			0x02
#define S_RI			0x04
#define S_CD			0x08

/* Interface */
#define RS232_MODE		0
#define RS485_2WIRE_MODE	1
#define RS422_MODE		2
#define RS485_4WIRE_MODE	3
#define OP_MODE_MASK		3


/* error code */
#define SIO_OK				0
#define SIO_BADPORT			-1		/* no such port or port not opened          */
#define SIO_OUTCONTROL		-2		/* can't control the board                  */
#define SIO_NODATA			-4		/* no data to read or no buffer to write    */
#define SIO_OPENFAIL		-5		/* no such port or port has be opened       */
#define SIO_RTS_BY_HW		-6      /* RTS can't set because H/W flowctrl       */
#define SIO_BADPARM			-7		/* bad parameter                            */
#define SIO_WIN32FAIL		-8		/* call win32 function fail, please call    */
									/* GetLastError to get the error code       */
#define SIO_BOARDNOTSUPPORT -9		/* Does not support this board              */
#define SIO_FAIL			-10		/* PComm function run result fail           */
#define SIO_ABORTWRITE		-11		/* write has blocked, and user abort write  */
#define SIO_WRITETIMEOUT    -12 	/* write timeoue has happened               */
#ifdef __cplusplus
extern "C" {
#endif

/* basic function phototype */
int sio_open(int port);
int sio_close(int fd);
int sio_ioctl(int fd, int baud, int mode);
int sio_DTR(int fd, int mode);
int sio_RTS(int fd, int mode);
int sio_lctrl(int fd, int mode);
int	sio_baud(int fd, long speed);
int sio_read(int fd, char *buf, int len);
int sio_write(int fd, char *buf, int len);
int sio_lstatus(int fd);
long sio_getbaud(int fd);
int sio_reset_count(int fd);
int sio_flowctrl(int fd, int mode);

#ifdef __cplusplus
}
#endif




⌨️ 快捷键说明

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