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

📄 c104p.h

📁 MOXA卡的操作.用语DOS系统下操作多串口卡。经过测试.效果良好
💻 H
字号:
 // declare comm fuction according to moxa card
#if !defined(__MODEMC_H)
#include <modemc.h>
#endif

#if !defined(__FILEC_H)
#include <filec.h>
#endif
//type C104P C168P C102
//#ifdef (MultiPortCardMOXA)
/*
#if defined(MultiPortCardMOXA)
	#if defined(__TINY__)||defined(__SMALL__)
	#elif defined(__MEDIUM__)
		#error MultiPortCard Type Not Yet defined!
	#elif defined(__LARGE__)
	#elif defined(__HUGE__)||(__COMPACT__)
	#endif
#else
//	#error MultiPortCard Not Yet defined!
#endif
*/
#define B50			0x00
#define B75			0x01
#define B110		0x02
#define B134		0x03
#define B150		0x04
#define B300		0x05
#define B600		0x06
#define B1200		0x07
#define B1800		0x08
#define B2400		0x09
#define B4800		0x0A
#define B7200		0x0B
#define B9600		0x0C
#define B19200		0x0D
#define B38400		0x0E
#define B57600		0x0F
#define B115200 	0x10
#define B230400 	0x11
#define B460800 	0x12
#define B921600 	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

/*	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

union VR{
	unsigned char *str;
	unsigned int ui;
};

#if defined C104P_C

	unsigned char no_data = 0;
	const  SENDDATAOK = 0;
	const  OK = 1;
	const  NOT = 0;

	const  HAVEDATA = 1;
	const  NODATA = 0;

	const  SC_SENDANSWER = 's';
	const  SC_RECANSWER = 'r';
	const  SC_NOTREADY = 'n';
	const  SC_RECOK = 'o';
	const  SC_RECNOT = 'k';

	const  MC_REQDATA ='R';
	const  MC_SENDDATA =	'S';
	const  MC_RECNOT	='K';
	const  MC_RECOK	='O';
	const  DATAHEAD	='!';

	const  CLEARDATA	=' ';
	const  DelayBSend=1 ;
	const  RPortTryTime=1000;		//must be!!
	const  WaitCommandAnswerTime=80;       //old 50
//const  WaitLastAnswerTime	50
	const  WaitLastAnswerTime=100;
	const  WaitDataHeadTime=50;
	int    Recs_Error;
	int	   Resc_Error;
	union 	VR vr;
	#ifdef __cplusplus
		extern "C" {
	#endif
//fuction copy from headc.h"
		int	cdecl	sio_reset(void);
		int	cdecl	sio_getports(int *port_no_array, int array_size);
		int	cdecl	sio_loopback(int port, char *buf, int len);
		int	cdecl	sio_ioctl(int port, int baud, int mode);
		int	cdecl	sio_getch(int port);
		int	cdecl	sio_linput(int port, char *buf, int len, int term);
		int	cdecl	sio_read(int port, char *buf, int len);
		int	cdecl	sio_putch(int port, int term);
		int	cdecl	sio_putb(int port, char *buf, int len);
		int	cdecl	sio_write(int port, char *buf, int len);
		int	cdecl	sio_flush(int port, int func);
		long	cdecl	sio_iqueue(int port);
		long	cdecl	sio_ifree(int port);
		long	cdecl	sio_oqueue(int port);
		long	cdecl	sio_ofree(int port);
		int	cdecl	sio_lstatus(int port);
		int	cdecl	sio_lctrl(int port, int mode);
		int	cdecl	sio_term_irq(int port, void (interrupt far *func)(), char code);
		int	cdecl	sio_cnt_irq(int port, void (interrupt far *func)(), int count);
		int	cdecl	sio_modem_irq(int port, void (interrupt far *func)());
		int	cdecl	sio_break_irq(int port, void (interrupt far *func)());
		int	cdecl	sio_break(int port, int time);
		int	cdecl	sio_brk_cnt(int port);
		int	cdecl	sio_flowctrl(int port, int mode);
		int	cdecl	sio_Tx_hold(int port);
		int	cdecl	sio_disableTx(int port);
		int	cdecl	sio_enableTx(int port);
		int	cdecl	sio_close(int port);
		int	cdecl	sio_open(int port);
		long	cdecl	sio_getbaud(int port);
		int	cdecl	sio_getmode(int port);
		int	cdecl	sio_getflow(int port);
		int	cdecl	sio_timeout(int time_tic);
		int	cdecl	sio_linput_t(int port, char *buf, int len, int term);
		int	cdecl	sio_putb_t(int port, char *buf, int len);
		int	cdecl	sio_overflow(int port);
		int	cdecl	sio_overlap(int port, int mode);
		int	cdecl	sio_cardno(int drvname);
		int	cdecl	sio_id(int drvname, int card);
		int	cdecl	sio_bank(int drvname, int card);
		int	cdecl	sio_linked(int drvname, int card);
		int	cdecl	sio_view(int port, char *ibuf, int len);
		int	cdecl	sio_disableIRQ(int port, int intrr_type);
		int	cdecl	sio_enableIRQ(int port, int intrr_type);
		int	cdecl	sio_DTR(int port, int mode);
		int	cdecl	sio_RTS(int port, int mode);
		int	cdecl	sio_baud(int port, long speed);
		int	cdecl	sio_ignore_errdata(int port, int mode);
		int	cdecl	sio_data_status(int port);
		int	cdecl	sio_putb_x(int port, char *buf, int len, int delay);
		int	cdecl	sio_disableRx(int port);
		int	cdecl	sio_enableRx(int port);
		int	cdecl	sio_getACs(int drvname, int card, int *serial_no_array,
			   int array_size);
		int	cdecl	sio_ACstate(int drvname, int serial);
		long	cdecl	sio_ACdiag(int drvname, int serial);
//end of copy.		//by xf in shenzhen 98/09/15.
		void cdecl port_init(const int port);				//initital port
		void cdecl lattice_init(const int port);
		void cdecl waijian_init(void);
		void cdecl port_init_low(const int port,const int baud, char parity,char databit, char stopbit);
		void cdecl port_init_tp(const int port);
		void cdecl port_init_tp_panyu(int port);
		void cdecl port_init_nanhaidd(int port);
		void cdecl port_init_cgtp(int port);

		unsigned char cdecl r_status(const int port);

		void cdecl sport(const int,const char);
		void cdecl sport2(const int port, const unsigned char ch);
		void cdecl send_string(const int,char*);
		void cdecl SendString(const int port,char *str, const int num);
		void cdecl send_string2(const int port, char *str, const int num);
		void cdecl SendStringEcho(const int port,char *str,const int num);
		void cdecl SendStringEcho3(const int port,char *str, const int num);

		unsigned char cdecl rport(const int);
		unsigned char cdecl rports(const int port);
		unsigned char cdecl rport2(const int port,unsigned char *chget);
		int cdecl rportWy(const int port, char *charin);

		char * cdecl rec_string(const int,const int);
		char * cdecl RecStringEcho(const int port,const int bytes);	/* Error time.Resc_Error =1 */
		char * cdecl RecStringEcho3(const int port,const int bytes);	/* Error time.Resc_Error =1 */

		char cdecl McRecString2(const int port,unsigned char *str, const int bytes);	/* Error time.Resc_Error =1 */
		char cdecl McRecString3(const int port,unsigned char *str, const int bytes);	/* Error time.Resc_Error =1 */

		void cdecl MakeVerify(unsigned char *str, const int bytes);
		int  cdecl Verify(unsigned char *str, const int bytes);
		int  cdecl Verify1(unsigned char *str, const int bytes);
		void cdecl MakeVerify1(unsigned char *str, const int bytes);

		void cdecl rport3(const int port,unsigned char *chget);
		void cdecl port_init_pywj(const int WjPortS,const int WjPortX);
		void cdecl Fqport_init(const int port);
	#ifdef __cplusplus
		}
	#endif
	#undef C104P_C
#else
	extern unsigned char no_data;

	extern const  SENDDATAOK;
	extern const  OK;
	extern const  NOT;

	extern const  HAVEDATA;
	extern const  NODATA;

	extern const  SC_SENDANSWER ;
	extern const  SC_RECANSWER;
	extern const  SC_NOTREADY ;
	extern const  SC_RECOK;
	extern const  SC_RECNOT;

	extern const  MC_REQDATA;
	extern const  MC_SENDDATA;
	extern const  MC_RECNOT;
	extern const  MC_RECOK;
	extern const  DATAHEAD;

	extern const  CLEARDATA;
	extern const  DelayBSend;
	extern const  RPortTryTime;		//must be!!
	extern const  WaitCommandAnswerTime;       //old 50
//const  WaitLastAnswerTime	50
	extern const  WaitLastAnswerTime;
	extern const  WaitDataHeadTime;
	extern int 	  Recs_Error;
	extern int	  Resc_Error;
	extern union VR vr;
	#ifdef __cplusplus
		extern "C" {
	#endif
		extern void cdecl port_init(const int port);				//initital port
		extern void cdecl lattice_init(const int port);
		extern void cdecl waijian_init(void);
		extern void cdecl port_init_low(const int port,const int baud, char parity,char databit, char stopbit);
		extern void cdecl port_init_tp(const int port);
		extern void cdecl port_init_tp_panyu(int port);
		extern void cdecl port_init_nanhaidd(int port);
		extern void cdecl port_init_cgtp(int port);

		extern unsigned char cdecl r_status(const int port);

		extern void cdecl sport(const int,const char);
		extern void cdecl sport2(const int port, const unsigned char ch);
		extern void cdecl send_string(const int,char*);
		extern void cdecl SendString(const int port,char *str, const int num);
		extern void cdecl send_string2(const int port, char *str, const int num);
		extern void cdecl SendStringEcho(const int port,char *str,const int num);
		extern void cdecl SendStringEcho3(const int port,char *str, const int num);

		extern unsigned char cdecl rport(const int);
		extern unsigned char cdecl rports(const int port);
		extern unsigned char cdecl rport2(const int port,unsigned char *chget);
		extern int cdecl rportWy(const int port, char *charin);

		extern char * cdecl rec_string(const int,const int);
		extern char * cdecl RecStringEcho(const int port,const int bytes);	/* Error time.Resc_Error =1 */
		extern char * cdecl RecStringEcho3(const int port,const int bytes);	/* Error time.Resc_Error =1 */

		extern char cdecl McRecString2(const int port,unsigned char *str, const int bytes);	/* Error time.Resc_Error =1 */
		extern char cdecl McRecString3(const int port,unsigned char *str, const int bytes);	/* Error time.Resc_Error =1 */

		extern void cdecl MakeVerify(unsigned char *str, const int bytes);
		extern int  cdecl Verify(unsigned char *str, const int bytes);
		extern int  cdecl Verify1(unsigned char *str, const int bytes);
		extern void cdecl MakeVerify1(unsigned char *str, const int bytes);

		extern void cdecl rport3(const int port,unsigned char *chget);
		extern void cdecl port_init_pywj(const int WjPortS,const int WjPortX);
		extern void cdecl Fqport_init(const int port);

		extern int	cdecl	sio_reset(void);
		extern int	cdecl	sio_getports(int *port_no_array, int array_size);
		extern int	cdecl	sio_loopback(int port, char *buf, int len);
		extern int	cdecl	sio_ioctl(int port, int baud, int mode);
		extern int	cdecl	sio_getch(int port);
		extern int	cdecl	sio_linput(int port, char *buf, int len, int term);
		extern int	cdecl	sio_read(int port, char *buf, int len);
		extern int	cdecl	sio_putch(int port, int term);
		extern int	cdecl	sio_putb(int port, char *buf, int len);
		extern int	cdecl	sio_write(int port, char *buf, int len);
		extern int	cdecl	sio_flush(int port, int func);
		extern long	cdecl	sio_iqueue(int port);
		extern long	cdecl	sio_ifree(int port);
		extern long	cdecl	sio_oqueue(int port);
		extern long	cdecl	sio_ofree(int port);
		extern int	cdecl	sio_lstatus(int port);
		extern int	cdecl	sio_lctrl(int port, int mode);
		extern int	cdecl	sio_term_irq(int port, void (interrupt far *func)(), char code);
		extern int	cdecl	sio_cnt_irq(int port, void (interrupt far *func)(), int count);
		extern int	cdecl	sio_modem_irq(int port, void (interrupt far *func)());
		extern int	cdecl	sio_break_irq(int port, void (interrupt far *func)());
		extern int	cdecl	sio_break(int port, int time);
		extern int	cdecl	sio_brk_cnt(int port);
		extern int	cdecl	sio_flowctrl(int port, int mode);
		extern int	cdecl	sio_Tx_hold(int port);
		extern int	cdecl	sio_disableTx(int port);
		extern int	cdecl	sio_enableTx(int port);
		extern int	cdecl	sio_close(int port);
		extern int	cdecl	sio_open(int port);
		extern long	cdecl	sio_getbaud(int port);
		extern int	cdecl	sio_getmode(int port);
		extern int	cdecl	sio_getflow(int port);
		extern int	cdecl	sio_timeout(int time_tic);
		extern int	cdecl	sio_linput_t(int port, char *buf, int len, int term);
		extern int	cdecl	sio_putb_t(int port, char *buf, int len);
		extern int	cdecl	sio_overflow(int port);
		extern int	cdecl	sio_overlap(int port, int mode);
		extern int	cdecl	sio_cardno(int drvname);
		extern int	cdecl	sio_id(int drvname, int card);
		extern int	cdecl	sio_bank(int drvname, int card);
		extern int	cdecl	sio_linked(int drvname, int card);
		extern int	cdecl	sio_view(int port, char *ibuf, int len);
		extern int	cdecl	sio_disableIRQ(int port, int intrr_type);
		extern int	cdecl	sio_enableIRQ(int port, int intrr_type);
		extern int	cdecl	sio_DTR(int port, int mode);
		extern int	cdecl	sio_RTS(int port, int mode);
		extern int	cdecl	sio_baud(int port, long speed);
		extern int	cdecl	sio_ignore_errdata(int port, int mode);
		extern int	cdecl	sio_data_status(int port);
		extern int	cdecl	sio_putb_x(int port, char *buf, int len, int delay);
		extern int	cdecl	sio_disableRx(int port);
		extern int	cdecl	sio_enableRx(int port);
		extern int	cdecl	sio_getACs(int drvname, int card, int *serial_no_array,
			   int array_size);
		extern int	cdecl	sio_ACstate(int drvname, int serial);
		extern long	cdecl	sio_ACdiag(int drvname, int serial);
	#ifdef __cplusplus
		}
	#endif
#endif


⌨️ 快捷键说明

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