www.pudn.com > MOXA--DOS.rar > C104P.C


#include  
#include  
#include  
#include  
 
#include "C104P.H" 
void cdecl port_init(const int port) 
{ 
	if (sio_ioctl(port,B9600,BIT_8| P_NONE| STOP_1) != 0){ 
		printf("Port #%d IOCTL error !\n", port + 1); 
		delay(500); 
		exit(0); 
	} 
	sio_lctrl(port, 3);        /* set DTR RTS on      */ 
	sio_flowctrl(port,0);      /* set NO flow control */ 
	sio_open(port); 
} 
 
 
void cdecl lattice_init(const int port) 
{ 
	if (sio_ioctl(port,B9600,BIT_8| P_NONE| STOP_1) != 0){ 
		printf("Port #%d IOCTL error !\n", port + 1); 
		delay(500); 
		exit(0); 
	} 
	sio_lctrl(port, 3);        /* set DTR RTS on      */ 
	sio_flowctrl(port,0);      /* set NO flow control */ 
	sio_open(port); 
} 
 
 
unsigned char cdecl r_status(const int port) 
{ 
	return (sio_lstatus(port)); 
} 
 
void cdecl sport(const int port,const char send) 
{ 
	int	i; 
	while(!( r_status(port)&C_RTS)); 
	sio_putch(port,send); 
} 
 
void cdecl sport2(const int port, const unsigned char send) 
{ 
	//for(i=0;i