Skip to main content

Compile a Moxa Serial Widget Device Driver on Ubuntu Linux

We needed a Linux serial device driver for the Moxa U1250 series multi-port USB to Serial adaptors.  The released driver on the Moxa web site only works with Ubuntu Linux up to version 11 and with Fedora Linux up to version 16, so you need a Virtual Machine of the right version for it.  Otherwise, ask Moxa support for a Beta version of their driver for the newer kernels.

Ubuntu Software Installer

There are basically three Linux development streams:
  • Slackware
  • Debian 
  • Red Hat
The Ubuntu distribution is part of the Debian family.
The Fedora distribution is part of the Red Hat family.

Each of these families has their own incompatible code packaging systems.  Each distribution has its own set of file servers and when you install a system, it will be configured to look at those servers for updates.  These servers are distributed all over the world at universities and large corporations.  Because they are perfect copies of each other, the servers are also known as 'mirrors'.

The update program used by Ubuntu is known as 'apt'.  To get a program from a mirror, you run a program called 'apt-get'.

To install stuff, you need super user (administrator) privileges.  You can elevate your permissions temporarily using a program called 'sudo' (set user do).  So therefore the command to get all system updates is:
$ sudo apt-get update

Similarly, to install a program, you would run:
$ sudo apt-get install programname

Apt keeps a database of installation data, so you can also use apt to remove a program, or upgrade an installed program to the latest version.  The graphical software wizard, is simply a nice looking front end for apt.

Low level programs such as device drivers, are operating system kernel modules that can be loaded and unloaded at run time - on the fly.  When you plug a new thing in, the system will automatically load the required driver if it is available,  For that to work, the driver needs to match your running kernel exactly. 

The Linux system is changing all the time.  It has a very rapid development cycle.  Therefore, most drivers are distributed as C source code and you have to compile it on your system before you can use it.

Software Development Tools

To do software development and compile device drivers for example, you need GCC (the GNU Compiler Collection) and the interface definition for your kernel version (the kernel header files).  These can be installed using apt. The command is something like:
$ sudo apt-get install linux-headers(versionnumber)
$ sudo apt-get install build-essential


The kernel version number can be displayed with the 'uname' command.  The command 'uname -a' will show all version parameters of the current running kernel.  The command 'uname -r' will show only the version number, so one can make a generic install command like this:
$ sudo apt-get install linux-headers-$(uname -r) build-essential

Compile and Install

After the above, one can download and compile the U1250 Linux device driver from http://www.moxa.com (or email their support guys for a Beta version).

Compile and installation of any program usually follows a simple recipe, explained in the README and INSTALL files that come with each package.  The recipe is usually the same, but once in a blue moon it isn't, so it is always a good idea to read the readme file and in this case it is indeed different from the norm:
$ make driver_make

************************************************************************
 Ubuntu 12.04.2 LTS 
 \l 3.5.0-23-generic
 MOXA UPort 1200/1400/1600 series driver ver 1.2.5
 Release Date: 2013/04/03
************************************************************************

If and only if there are no errors above:
$ sudo make install
[sudo] password for herman: 
************************************************************************
 Ubuntu 12.04.2 LTS 
 \l 3.5.0-23-generic
 MOXA UPort 1200/1400/1600 series driver ver 1.2.5
 Release Date: 2013/04/03
************************************************************************
************************************************************************
 MOXA UPort 1200/1400/1600 series driver ver 1.2.5 installed successfully.
************************************************************************

Configure the Port

Now, when you plug the Moxa U1250 in, it should show up in /dev as ttyMXUSB0 and ttyMXUSB1.

Configure the device for RS232:
# setserial /dev/ttyMXUSB0 port 0x0

or for RS422:

# setserial /dev/ttyMXUSB0 port 0x2

and for RS485 2-wire:

# setserial /dev/ttyMXUSB0 port 0x1

It is all explained in the readme.txt file and I recommend you use it with Cutecom.

La voila.

Comments

  1. This is error we get after entering the below command.

    chandana@root:~/moxa/mxuport$ make
    #==========================================
    # MOXA UPort series driver v1.0
    # for Linux kernel 2.6.x
    #
    # release date : 04/03/2008
    #==========================================
    Building driver...
    make EXTRA_CFLAGS= -C /lib/modules/3.2.0-23-generic-pae/build SUBDIRS=/home/chandana/moxa/mxuport modules
    make[1]: Entering directory `/usr/src/linux-headers-3.2.0-23-generic-pae'
    CC [M] /home/chandana/moxa/mxuport/mxuport/mx-uport.o
    /home/chandana/moxa/mxuport/mxuport/mx-uport.c: In function ‘mxuport_open’:
    /home/chandana/moxa/mxuport/mxuport/mx-uport.c:624:25: error: ‘struct tty_driver’ has no member named ‘flush_buffer’
    /home/chandana/moxa/mxuport/mxuport/mx-uport.c:625:26: error: ‘struct tty_driver’ has no member named ‘flush_buffer’
    /home/chandana/moxa/mxuport/mxuport/mx-uport.c: In function ‘mxuport_close’:
    /home/chandana/moxa/mxuport/mxuport/mx-uport.c:790:16: error: ‘struct tty_driver’ has no member named ‘flush_buffer’
    /home/chandana/moxa/mxuport/mxuport/mx-uport.c:791:14: error: ‘struct tty_driver’ has no member named ‘flush_buffer’
    /home/chandana/moxa/mxuport/mxuport/mx-uport.c: In function ‘mxuport_ioctl’:
    /home/chandana/moxa/mxuport/mxuport/mx-uport.c:1140:69: warning: passing argument 2 of ‘user_termios_to_kernel_termios’ from incompatible pointer type [enabled by default]
    include/asm-generic/termios.h:115:19: note: expected ‘struct termios2 *’ but argument is of type ‘struct termios *’
    /home/chandana/moxa/mxuport/mxuport/mx-uport.c:1170:69: warning: passing argument 2 of ‘user_termios_to_kernel_termios’ from incompatible pointer type [enabled by default]
    include/asm-generic/termios.h:115:19: note: expected ‘struct termios2 *’ but argument is of type ‘struct termios *’
    /home/chandana/moxa/mxuport/mxuport/mx-uport.c:1248:38: error: ‘struct tty_driver’ has no member named ‘flush_buffer’
    /home/chandana/moxa/mxuport/mxuport/mx-uport.c:1249:42: error: ‘struct tty_driver’ has no member named ‘flush_buffer’
    /home/chandana/moxa/mxuport/mxuport/mx-uport.c:1272:38: error: ‘struct tty_driver’ has no member named ‘flush_buffer’
    /home/chandana/moxa/mxuport/mxuport/mx-uport.c:1273:42: error: ‘struct tty_driver’ has no member named ‘flush_buffer’
    /home/chandana/moxa/mxuport/mxuport/mx-uport.c: In function ‘mxuport_init’:
    /home/chandana/moxa/mxuport/mxuport/mx-uport.c:3632:2: error: implicit declaration of function ‘info’ [-Werror=implicit-function-declaration]
    cc1: some warnings being treated as errors
    make[3]: *** [/home/chandana/moxa/mxuport/mxuport/mx-uport.o] Error 1
    make[2]: *** [/home/chandana/moxa/mxuport/mxuport] Error 2
    make[1]: *** [_module_/home/chandana/moxa/mxuport] Error 2
    make[1]: Leaving directory `/usr/src/linux-headers-3.2.0-23-generic-pae'
    make: *** [modules] Error 2

    ReplyDelete
  2. Hi Shreyansh,

    The software is for kernel 2.6, which is rather ancient and it won't compile on a kernel 3.2 system.

    Please email the Moxa Support guys and ask for a Beta version of the device driver at "support-at-moxa-dot-com". (obfuscated as an anti-spam courtesy to Moxa). You should get a response from Germany within a few hours. The Beta version worked for me on Fedora 18.

    Regards,

    Herman

    ReplyDelete

Post a Comment

On topic comments are welcome. Junk will be deleted.

Popular posts from this blog

Parasitic Quadrifilar Helical Antenna

This article was reprinted in OSCAR News, March 2018:  http://www.amsat-uk.org If you want to receive Satellite Weather Pictures , then you need a decent antenna, otherwise you will receive more noise than picture. For polar orbit satellites, one needs an antenna with a mushroom shaped radiation pattern .  It needs to have strong gain towards the horizon where the satellites are distant, less gain upwards where they are close and as little as possible downwards, which would be wasted and a source of noise.  Most satellites are spin stabilized and therefore the antenna also needs circular polarization, otherwise the received signal will flutter as the antennas rotate through nulls. The helical antenna, first proposed by Kraus in 1948, is the natural solution to circular polarized satellite communications.  It is a simple twisted wire - there seems to be nothing to it.  Various papers have been published on helix antennas, so the operation is pretty well understood. Therefore,

Patch Antenna Design with NEC2

The older free Numerical Electromagnetic Code version 2 (NEC2) from Lawrence Livermore Lab assumes an air dielectric.  This makes it hard (but not impossible) for a radio amateur to experiment with Printed Circuit Board Patch antennas and micro strip lines. Air Spaced Patch Antenna Radiation Pattern You could use the free ASAP simulation program , which handles thin dielectrics, you could shell out a few hundred Dollars for a copy of NEC4 , You could buy GEMACS if you live in the USA, or you could add distributed capacitors to a NEC2 model with LD cards (hook up one capacitor in the middle of each element.), but that is far too much money/trouble for most. More information on driving an array antenna can be found here: https://www.aeronetworks.ca/2019/03/driving-quad-patch-array-antenna.htm l Air Dielectric Patch   The obvious lazy solution is to accept the limitation and make an air dielectric patch antenna. An advantage of using air dielectric, is that the antenn

Weather Satellite Turnstile Antennas for the 2 meter Band

NEC2, 2 m band, 146 MHz, Yagi Turnstile Simulation and Build This article describes a Turnstile Antenna for the 2 meter band, 146 MHz amateur satcom, 137 MHz NOAA and Russian Meteor weather satellites.  Weather satellite reception is described here .  A quadrifilar helical antenna is described here .   Engineering, is the art of making what you need,  from what you can get. Radiation Pattern of the Three Element Yagi-Uda Antenna Once one combine and cross two Yagis, the pattern becomes distinctly twisted. The right hand polarization actually becomes visible in the radiation pattern plot, which I found really cool. Radiation Pattern of Six Element Turnstile Antenna Only a true RF Geek can appreciate the twisted invisible inner beauty of a herring bone antenna... Six Element Turnstile Antenna Essentially, it is three crosses on a stick.  The driven elements are broken in the middle at the drive points.  The other elements can go straight throug