www.pudn.com > MOXA--DOS.rar > C104P.C
#include#include #include #include #include #if !defined C104P_C #define C104P_C #endif #include "\hxn\lib\moxa\C104P.H" // void cdecl port_init(const int port) { if(!sio_open (port)) { if (sio_ioctl(port,B9600,BIT_8| P_EVEN| STOP_1)){ printf("Port #%d IOCTL error !\n", port + 1); delay(500); exit(0); } sio_lctrl(port, C_DTR | C_RTS); /* set DTR RTS on */ sio_flowctrl(port,0); /* set NO flow control */ } else { printf("Port #%d IOCTL error !\n", port + 1); delay(500); exit(0); } } void cdecl waijian_init(const int port) { if(!sio_open (port)) { if (sio_ioctl(port,B1200,BIT_7| P_EVEN| STOP_1)){ printf("Port #%d IOCTL error !\n", port + 1); delay(500); exit(0); } sio_lctrl(port, C_DTR | C_RTS); /* set DTR RTS on */ sio_flowctrl(port,0); /* set NO flow control */ } else { printf("Port #%d IOCTL error !\n", port + 1); delay(500); exit(0); } } void cdecl lattice_init(const int port) { if(!sio_open (port)) { if(sio_ioctl(port,B9600,BIT_8| P_NONE| STOP_1)){ printf("Port #%d IOCTL error !\n", port + 1); delay(500); exit(0); } sio_lctrl(port, C_DTR | C_RTS); /* set DTR RTS on */ sio_flowctrl(port,0); /* set NO flow control */ } else { printf("Port #%d IOCTL error !\n", port + 1); delay(500); exit(0); } } 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