HDS ViewStation System Administrator's Guide

A Hypertext Document


Using Other Input Devices on the ViewStation

This page describes the "opendev" command and ways it can be used to connect external devices to the ViewStation.

Access to ViewStation Ports
The ViewStation's Ports, one parallel and two serial, are generally accessible by any device on the network with conventional naming techniques. They are designated:

parallel port = /dev/pp0
serial port 1 (RJ11) = /dev/tty1
serial port 2 (DB25) = /dev/tty2

Other ports are named the same way:
audio port = /dev/audio

The opendev Command
The "opendev" command available from the ViewStation's Console window is the entry point for a generalized bi-directional read/write capability for the ViewStation's serial and parallel ports (the parallel port is write-only). This capability is described more fully below.

Remote Access to ViewStation Ports
It is sometimes desireable to permit a process running on a host to have direct access to one of the ports on the ViewStation; in other words, letting the remote ViewStation port act as a local port on the host. One situation where this would be useful might be additional user input from a serial device, such as a digitizer tablet, modem, or barcode reader. Other devices, such as badge readers or a security key, could also be connected to the ViewStation serial ports.

The ViewStation server has a command called "opendev". This command opens a device on the ViewStation, specified as an argument to the command, for bi-directional communication. The argument to the opendev command may be any device driver installed at a /dev/xxx node. The command syntax is as follows:

rsh <fxname> opendev [ /dev/ttyx ]

which executes a remote shell command to the ViewStation to execute the opendev command with the specified device. This means that standard input from the rsh TCP port is written to /dev/ttyx, and data from /dev/ttyx is written as output to the rsh TCP port. The ViewStation has two serial ports, designated /dev/tty1 (an RJ11, RS-232 port) and /dev/tty2 (a DB25, RS-232 port), and one paral lel port designated /dev/pp0 (DB25 Centronics) for local printing.

You could also use the rsh command in conjunction with a stty command to give transparent access to the port. For example, typing a command line directly into a modem might use:

stty raw -echo; rsh <fxname> opendev [ /dev/tty x ]

The rsh command may be used either in a shell script or in a compiled program. The shell syntax is given above, and would normally be activated as a sub-shell to allow redirection of the file descriptors created by the rsh command. Terminating the rsh command would terminate the process.

Usepty Script
The usepty script to use a pseudo-tty, provided on the HDSware tape in the ./hds- fx/contrib/usepty/src directory, is also useful here. A typical command line for a pseudo-tty for port 1 might look like:

usepty /dev/ptyrb rsh <fxname> opendev /dev/tty1 &

The usepty process will repeatedly monitor the pseudo-tty port and wait for a process to open on the corresponding slave side. When the slave side is opened, usepty will execute the rsh command to open the port on the ViewStation. When the slave side is closed, the usepty process will resume monitoring the pseudo-tty port.

Implementing "opendev" in a C Program
To use this command in a C program, the typical technique would create two pipes, one for input and one for output, then fork a child process and let the child process execute the rsh command. The sample file below illustrates this technique ( ". . ." indicates omitted code segments of the user's choice):

...
char *cmd = RSH_PATH; /* "/usr/ucb/rsh" or "rsh" */
char *rem_host = "hds-fx"; /* example only */
char *opendev = "opendev";
char *rem_device = "/dev/tty1"; /* example only */
int pvin[2];
int pvout[2];
...
pipe (pvin); /* pipe to read from remote device */
pipe (pvout); /* pipe to write to remote device */
if (fork() == 0
{
dup2 (pvin[1], 1); /* stdout goes to pipe pvin */
close (pvin[0]);
close (pvin[1]);
dup2 (pvout[0], 0); /* stdin comes from pipe pvout */
close (pvout[0]);
close (pvout[1]);
execlp (cmd, cmd, rem_host, opendev, rem_device, (char *) 0);
exit(1); /* exec() failed */
}
close (pvin[1]);
close (pvout[0]); /* Now can use pvin[0] for reading, pvout[1] for writing */
...
cc = read (pvin[0], buffer, buf_size);
...
cc = write (pvout[1], buffer, count);
...

Return to Section Heading Page


Return to the Home Page

If you need more information than is available here, you can reach HDS via email at info@hds.com, or call us at 1.800.HDS.1551 in the USA, or at +610.277.8300 from outside the US. For questions or problems regarding the HDS WWW page, contact webmaster@hds.com.
© 1996 by HDS Network Systems Inc.