There are two requirements that must be fulfilled before lnphost can get access to the tower. The driver or kernel module must be installed and the device must be readable and writable by the user that will run programs based on lnphost.

System configuration (Linux)

With serial ports and USB-to-serial-adapters this is generally not a problem, as most operating systems have built-in support for these devices. Permissions must be set to allow read and write access to the device. This can be accomplished by adding the user to the device's group:

  $ ls -l /dev/ttyS0
  crw-rw----    1 root     dialout    4,  64 Mar 14  2005 /dev/ttyS0
  $ adduser <username> dialout
  chmod g+rw /dev/ttyS0

Another alternative is to allow access by anybody:

  $ chmod 666 /dev/ttyS0

The device's name depends on details of the system, the following lists shows some typical examples.

  • /dev/ttyS0 - first serial port on Linux machines
  • /dev/ttya - first serial port on Solaris
  • /dev/ttyUSB0 - usb-serial-adapter
  • /dev/usb/legousbtower1 - Linux USB tower

Setting up the USB tower might be complicated on older systems. Recent Linux distributions with kernel 2.6 have a built-in module legousbtower which can automatically loaded by hotplug. If the module is not included or just too old (versions below 0.92 will cause problems), it must be compiled manually. Source code and instructions can be found on

Once the tower is plugged in, the module should be loaded and a device will be created somewhere in the /dev directory, most likely as /dev/usb/legousbtower1. If not, this can be also be done by hand.

  modprobe -v legousbtower packet_timeout=0
  mknod /dev/usb/legousbtower0 c 180 160

The option packet_timeout tells the tower to send every byte as soon as it arrives instead of holding it back until a complete packet is assembled. This is needed to improve the reaction time of lnphost in situations with heavy traffic or continuous data streams. It depends on the system where this option can be placed so that hotplug uses it by default. Basically the line...

  options legousbtower packet_timeout=0

must be added to the correct configuration file, most likely one of the following:


Consult your Linux documentation for the correct place. The device must be readable and writable by the user as discussed above.

System configuration (Windows)

Windows makes life a little easier in this case, serial towers do work out of the box. A windows driver for the USB tower is included in the Mindstorms SDK from Lego which can be downloaded from their website Just make sure that a tower icon appears in the device manager and in the control panel. The tower can be addressed using the following file names.

  • //./legotower1 - first Windows USB tower
  • com1 - first serial port on windows/cygwin

Programs compiled with Cygwin will refuse to work on other computers where Cygwin is not installed. You might need the libraries like cygwin1.dll and a few registry changes to get them working. Run cygwin.reg on the host to insert the following entries:

  [HKEY_LOCAL_MACHINE\SOFTWARE\Cygnus Solutions\Cygwin]
  [HKEY_LOCAL_MACHINE\SOFTWARE\Cygnus Solutions\Cygwin\mounts v2]
  [HKEY_LOCAL_MACHINE\SOFTWARE\Cygnus Solutions\Cygwin\mounts v2\/]
  [HKEY_LOCAL_MACHINE\SOFTWARE\Cygnus Solutions\Cygwin\Program Options]

Compiling lnphost

The installation is extremely easy. Just unpack the file, make sure that the needed tools are installed (mainly gcc and make) and run "make". A multi-protocol packet monitor is included in the lnphost package to demonstrate the main features of the library. The Makefile can easily be adapted for own programs.