Installation guide
Industrial Networking Solutions
8-13
info@moxa.com
www.moxa.com
Serial Device Servers >
Introduction to Serial Device Servers
8
IP Serial Library
What is IP Serial Library?
The IP Serial Library is a collection of Windows functions for NPort®
5000 device servers. Serial command sets and common subroutines
are provided. The purpose of the library is to help reduce complexity
and increase efficiency when programming serial communication
applications that run over a TCP/IP network. For example, Telnet
is limited because it can only transfer data but cannot monitor or
configure serial line parameters. The IP Serial Library can be used to
add new functionality to your Telnet sessions.
Use IP Serial Library for easier socket-based serial COM programming
IP Serial Library Example
IP Serial API Function List
For programmers who are familiar with serial communication, the IP
Serial Library provides well-designed function calls that have the same
style as Moxa’s PComm Library.
The IP Serial Library is amazingly simple and easy to understand.
By including the library in your VB, C, or Delphi programming
environment, you will be able to develop TCP/IP applications that can
control serial communication parameters.
When Real COM mode is used, the NPort® serial device servers use
two TCP ports for communication between an attached device and
a host computer’s Real COM driver. The two ports, a data port and a
command port, provide pure data transfer without requiring encoding
and decoding. With the IP Serial Library, only one port is used to
communicate with a user’s application, and no encoding or decoding
is required.
char NPort®ip=“192.168.1.10”;
char buffer[255];int port = 1; /*data buffer, 255 chars */
int portid; /*port handle*/
nsio_init(); /*initialize IP Serial Library*/
portid = nsio_open(NPort®ip, port); /*1st port, NPort® IP=192.168.1.10 */
nsio_ioctl(portid, B9600, (BIT_8 | STOP_1 | P_NONE) ); /*set 9600, N81 */
sleep(1000); /* wait for 1000 ms for data */
nsio_read(port, buffer, 200); /* read 200 bytes from port 1 */
nsio_close(portid); /* clost this serial port */
nsio_end(); /* close IP Serial Library */
Server Control Port Control Input/Output Data Port Status Inquiry Miscellaneous
nsio_init nsio_open nsio_read nsio_lstatus nsio_break
nsio_end nsio_close nsio_SetReadTimeouts nsio_data_status nsio_break_on
nsio_rese-
tserver
nsio_ioctl nsio_write --- nsio_break_off
nsio_checkalive nsio_fl owctrl nsio_SetWriteTimeouts --- nsio_breakcount
--- nsio_DTR --- --- ---
--- nsio_RTS --- --- ---
--- nsio_lctrl --- --- ---
--- nsio_baud --- --- ---
--- nsio_resetport --- --- ---