How to reliably use Serial port within the local network

The easiest way to reliably use Serial port within the local network is to use RS-232/422/485 NPort Device Server produced by Moxa company. I will shortly describe how to install NPort 5110 (1-port RS-232 serial device server) on Debian Wheezy.

Step 1

Connect device to the network, change default device IP address ( and operation mode to the Real COM mode.

Step 2

Identify device model, open product web-page NPort 5110, then click Drivers and Software link and download NPort Real TTY Driver for Linux.

Step 3

Extract downloaded source code.

$ tar xfvz npreal2_1.18_Build_12020919.tgz

Carefully read manual text file.

$ less tmp/moxa/README.TXT

Change working directory.

$ cd tmp/moxa

Build and install software.

$ sudo ./mxinst

Copyright (C) 2002-2012  Moxa Inc.
All Rights Reserved.

MOXA NPort Server Real TTY Driver V1.18 Installation.
System Imformation: Kernel 3.2.0-4-amd64; Machine x86_64.

Tar files, please wait ... OK!
Building driver...

If you want to use secure communication with target,
you might choose [y] to enable the SSL function.
Note: This function support RealCOM with secure mode only.
Do you want to enable secure function? [y/N].

make -C /lib/modules/3.2.0-4-amd64/build SUBDIRS=/home/milosz/tmp/moxa modules
make[1]: Entering directory `/usr/src/linux-headers-3.2.0-4-amd64'
  CC [M]  /home/milosz/tmp/moxa/npreal2.o
  Building modules, stage 2.
  MODPOST 1 modules
  CC      /home/milosz/tmp/moxa/npreal2.mod.o
  LD [M]  /home/milosz/tmp/moxa/npreal2.ko
make[1]: Leaving directory `/usr/src/linux-headers-3.2.0-4-amd64'
cp -p npreal2.ko /lib/modules/3.2.0-4-amd64/kernel/drivers/char/
depmod -a
cc -c npreal2d.c
cc npreal2d.o -o npreal2d
strip	npreal2d
cc -c redund_main.c
cc -c redund.c
cc	redund_main.o redund.o -lpthread -o npreal2d_redund
strip	npreal2d_redund
cc -o mxaddsvr mxaddsvr.c
strip mxaddsvr
cc -o mxdelsvr mxdelsvr.c
strip mxdelsvr
cc -o mxcfmat mxcfmat.c
strip mxcfmat
cc -o mxloadsvr mxloadsvr.c
strip mxloadsvr
cc -o mxsetsec mxsetsec.c
strip mxsetsec
Check Driver...
Copying configurations files ... OK!
Copying driver files ... OK!
Load driver...

Loading TTY Driver...
update-rc.d: using dependency based boot sequencing

Installation process is completed.
The all driver files are installed on /usr/lib/npreal2/driver.
Now you can cd /usr/lib/npreal2/driver and run ./mxaddsvr to add tty port.

You will find similar entry in dmesg output.

[ 1563.248831] MOXA Async/NPort server family Real TTY driver ttymajor 33 calloutmajor 38 verbose 1 (1.18 Build 12020919)

Step 4

To add first serial port on the NPort device execute the following command.

$ sudo /usr/lib/npreal2/driver/mxaddsvr 1
Adding Server...

ttyr00, cur00
Added RealCom server: ip :

mknod -m 666 ttyr00 c 33 0
mknod -m 666 cur00 c 38 0
update-rc.d: using dependency based boot sequencing

Now you can use /dev/ttyr00 device.

Potential problems

I have encountered problem with init script on Debian Wheezy but it can be quickly solved by executing /etc/init.d/npreals script from the /etc/rc.local shell script or by modifying mxloadsrv source code to create proper init script.


Configuration file is stored in the /usr/lib/npreal2/driver/ text file.

$ cat /usr/lib/npreal2/driver/
#   This configuration file is created by Moxa NPort      #
#   Administrator Program automatically, please do not    #
#   modify this file by yourself.                         #
#[Minor] [ServerIP]	[data]	[cmd]	[FIFO]	[SSL]	[ttyName] [coutName] [interface][mode][BackIP]
0	950	966	1	0	ttyr00	cur00	0	0	(null)

To remove server use mxdelsrv command.

$ sudo /usr/lib/npreal2/driver/mxdelsvr
Delete Server ...
rm -f /dev/ttyr00
rm -f /dev/cur00
update-rc.d: using dependency based boot sequencing
Deleted server:

update-rc.d: using dependency based boot sequencing

To uninstall driver use mxuinst command.

$ sudo /usr/lib/npreal2/driver/mxuninst
Driver Removal ...
update-rc.d: using dependency based boot sequencing

It is worth to note that Moxa provides also wide range of different products for industrial networking and automation.

Important note - 2015/08/19

Please contact your local Moxa distributor for an updated driver.

You will receive current (some kind of beta version, not official) driver, but it will work on Debian Jessie kernel 3.16.

Milosz Galazka's Picture

About Milosz Galazka

Milosz is a system administrator working for a successful Polish company and a long time supporter of Free Software Foundation and Debian operating system.

Gdansk, Poland