Using Serial Port redirection

Introduction

Using ThinLinc, it is possible to access the serial ports of the client from the ThinLinc session. This means that you can utilize peripheral devices which connect through a serial port, such as digital cameras, PDAs and modems. Up to two serial ports are supported at a time.

Requirements

  • The application which communicates with the serial port must be dynamically linked. Statically linked applications are not supported.

Enabling Serial Port Redirection

Serial port redirection is activated (for the current user session) by sourcing the file tl-serial-redir.sh. It can be done manually with this command:

$ source /opt/thinlinc/libexec/tl-serial-redir.sh

It is necessary to source this file, because it sets the environment variables CYCLADE_DEVICES and LD_PRELOAD. Thus, all applications needing serial port access should be started as a subprocess to this shell. The easiset way to accomplish this is to source tl-serial-redir.sh from the session startup scripts. To automatically activate serial port redirection at login for all users, execute this command:

$ sudo ln -s /opt/thinlinc/libexec/tl-serial-redir.sh \
   /opt/thinlinc/etc/xstartup.d/42-tl-serial-redir.sh

Accessing the redirected port from applications

When using redirected serial ports, applications should be configured to use a special, personal device-file, instead of a port such as /dev/ttyS0. The two device files are called $TLSESSIONDATA/dev/ttyS0. and $TLSESSIONDATA/dev/ttyS1.

Tip

Since the session number varies, it’s often convenient to use the symbolic link /var/opt/thinlinc/sessions/$USER/last, which points to the last started session directory. For example, the first serial port can be accessed as /var/opt/thinlinc/sessions/$USER/last/dev/ttyS0.

Limitations and additional information

  • When reconnecting to an existing session, it might take up to 10 seconds before the serial ports are available.

  • A maximum of two serial ports per session can be redirected.

  • The redirection is handled by processes called cyclades-ser-cli. It writes debugging information to $TLSESSIONDATA/ttyS0.log. and $TLSESSIONDATA/ttyS1.log. These processes will automatically terminate when the session terminates.

  • Applications that uses the ioctl TIOCMGET are not supported yet.