Chapter 5. Printing, input, and output

On a PC, applications communicate with external devices such as printers, modems, and data loggers via the COM1: to COM4: serial ports and the LPT1: to LPT3: parallel ports.

This chapter describes how to assign these ports to take advantage of the equivalent capabilities of the Unix workstation.

The following table summarizes the default options for the COM and LPT ports:

Table 5-1. Default Options for the COM and LPT Ports

Option

Description

File

Output redirected to a specified file*

Pipe

Output directed to the print spooler for network printing*

Device

Input/output to a device connected to the workstation's serial port

None

No device assigned

*Output must be flushed.

These options are described in greater detail in the following sections.

Printing from SoftWindows

SoftWindows allows you to print from Windows and MS-DOS applications to either PostScript or non-PostScript printers.

Printing from Windows

Windows applications give best results when set up for a PostScript printer; refer to Chapter 5, “To set up Windows for a PostScript printer”.

If your Unix network printer does not support PostScript, refer to Chapter 5, “To print from Windows to a non-PostScript printer”.

Printing from MS-DOS

Most MS-DOS applications give best results when set up for a dot-matrix printer; refer to Chapter 5, “Printing from MS-DOS applications”.

Printing to a serial printer

SoftWindows can also drive a PC serial printer connected to a serial port on the Unix workstation so that your application can print directly to it; refer to Chapter 5, “Printing to a serial printer”.

Printing to PC network printers

You can also use SoftWindows to print to PC network printers that are not directly accessible to Unix. For more information refer to your PC network documentation.

Flushing output to a file or pipe

After outputting from a SoftWindows COM or LPT port to a file or pipe, you need to flush the output to ensure that the last partial buffer of data is sent to the file or pipe.

SoftWindows provides an Auto Flush option, which flushes the buffer automatically at specified interval after the last activity on the port.

Alternatively, you can flush output from a port manually when you know that output has finished.

See “To flush output automatically.”

To flush output automatically

  1. Choose Auto Flush… from the Options menu.

    This dialog box appears:

    Figure 5-1. The Auto Flush Dialog Box


  2. Check that the Enable Automatic Flushing box is selected.

  3. Set the required delay by moving the Autoflush Delay slider until the field shows the value you want. You can set any autoflush delay from 1 to 300 seconds.

The ideal autoflush delay depends on how quickly the PC application outputs data, and you may need to experiment by starting with a high value, and then reduce it to find the best setting.

You can set flushing for an individual file or pipe by setting the Enable Windows PostScript flushing option in the Printer Ports or Comms Ports dialog box.

Flushing with pipes

When data being sent to a pipe is flushed, the pipe process is stopped and another one is started. If you are piping data to the print spooler, this will stop the current job and start another one.

For pipes the autoflush delay must therefore be set to an interval greater than the time it takes to generate each buffer of data for a particular job; otherwise, unwanted print jobs and incorrect output may be generated.

To flush output manually

  1. Choose Flush Ports from the Actions menu.

    A cascade menu is displayed allowing you to select which ports to flush.

    Figure 5-2. The Flush Ports Menu in SoftWindows


  2. Choose All to flush all ports, or choose the port you want to flush.

The port should be flushed after outputting to a COM or LPT port from SoftWindows with the Pipe option.

The buffers are also flushed automatically when you quit from SoftWindows.

Printing from Windows applications

If your Unix printer is a PostScript printer, you will get the best results by printing PostScript from Windows.

Note that additional information about printing from Windows is provided in the file G:\PRINTERS.WRI.

To print PostScript to the Unix printer

  1. Choose Printer Ports… from the COM/LPT Ports cascade menu on the Options menu.

  2. The Printer Ports dialog box appears.

  3. Choose Pipe from the LPT1: popup menu. Check that this is set to the default setting, which sends output to the local print spooler, lp.

    Figure 5-3. The Printer Ports Dialog Box with PostScript Printer Setting


  4. Check the "Enable Windows PostScript Flushing" box.

  5. Make sure you have Windows set up for a PostScript printer. See Chapter 5, “To set up Windows for a PostScript printer”.

To set up Windows for a PostScript printer

  1. Double-click the Control Panel icon in the Windows Main program group.

  2. Double-click the Printers control panel icon to display the Printers dialog box.

    Figure 5-4. The Printers Dialog Box


    The currently selected printer is shown in the Default Printer box at the top of the dialog box.

  3. Check that this is set to PostScript Printer on LPT1.

  4. Click Cancel to close the dialog box.

  5. Print from the Windows application; typically, you do this by choosing Print… from the File menu.

  6. If your file does not print, check your Printer Ports settings in SoftWindows. See Chapter 5, “To print PostScript to the Unix printer” for details.

To print from Windows to a non-PostScript printer

If your Unix printer does not support PostScript, you should set up Windows for the printer you are using.

  1. First set up SoftWindows as described in Chapter 5, “To print from MS-DOS to a non-PostScript printer”.

  2. Double-click the Control Panel icon in the Windows Main program group.

  3. Double-click the Printers control panel icon to display the Printers dialog box.

  4. Select the appropriate option for your Unix printer from the list of Installed Printers, and click Set As Default Printer.

    Figure 5-5. The Set As Default Printer Button in the Printers Dialog Box


  5. Click Close to close the dialog box.

  6. Print from the Windows application; typically you do this by choosing Print… from the File menu.

Printing from MS-DOS applications

Most MS-DOS applications give best results when set up for a dot-matrix printer such as the widely-used LQ-2500.

To print from MS-DOS to a non-PostScript printer

  1. Choose Printer Ports… from the COM/LPT Ports cascade menu on the Options menu.

  2. The Printer Ports dialog box appears.

  3. Choose Pipe from the LPT1: popup menu. Check that this is set to the default setting, which sends output to the local print spooler, lp.

    Figure 5-6. The Printer Ports Dialog Box with Non-PostScript Printer Setting


  4. Choose the appropriate command to print from your MS-DOS application.

Printing to a serial printer

To print to a serial printer with default settings

You can print from an LPT port to a serial printer with the following fixed communications settings:

9600 baud, no parity, 8 data bits, 1 stop bit, XON/XOFF handshaking.

  1. Connect the printer to the serial port.

  2. Choose Printer Ports… from the COM/LPT Ports cascade menu on the Options menu.

    The Printer Ports dialog box appears.

  3. Choose Device from the LPT1: popup menu. By default this sends output to one of the serial ports. You may need to change this depending on which port you are using.

    Figure 5-7. The Printer Ports Dialog Box with Serial Printer Settings


To print to a serial printer with selectable settings

If you need to use different communications settings, set a COM port to Printer and use the MODE command to set the communications parameters. For example:

MODE COM1:9600,N,8,1

sets 9600 baud, no parity, 8 data bits, and 1 stop bit, the default setting. XON/XOFF handshaking is supported.

If your application can only print to an LPT port, use the MODE command to direct LPT output to the COM port, for example:

MODE LPT1:=COM1:

Include the MODE commands in your AUTOEXEC.BAT file if you want to use these settings every time you run SoftWindows.

Redirecting to a file and piping to a process

You can redirect all output from a specified port to a file in the Unix file system.

Redirecting output from SoftWindows to a file is a useful way of debugging problems with printing. The file can then be printed externally to SoftWindows.

To redirect output to a file

  1. Choose Printer Ports… or Comms Ports… from the COM/LPT Ports cascade menu on the Options menu, depending on whether you want to redirect an LPT or COM port.

  2. Choose File from the popup menu next to the port you want to redirect.

    Figure 5-8. The Printer Ports Dialog Box with Redirect File Setting


    The filename defaults to SoftWin.tmp in your home directory. Alternatively, enter the filename you want to use. If the file already exists, the output will be appended to it.

  3. Check that Enable Automatic Flushing is set in the Auto Flush dialog box, so that output is flushed to the file; refer to Chapter 5, “Flushing output to a file or pipe”.

You can pipe the output from a port to a Unix process that will accept text input. One use for this is to print a file which is not PostScript.

To pipe to a Unix process

  1. Choose Printer Ports… or Comms Ports… from the COM/LPT Ports cascade menu on the Options menu, depending on whether you want to pipe the output from an LPT or COM port.

  2. Choose Pipe from the popup menu next to the port whose output you want to pipe, and enter the name of the process.

    Figure 5-9. The Printer Ports Dialog Box with Pipe to a Unix Process Setting


    Do not include the leading pipe symbol, |, as this is assumed. By default, output is piped to lp, the Unix print spooler.

  3. Check that Enable Automatic Flushing is set in the Auto Flush dialog box, so that output is flushed to the pipe; refer to Chapter 5, “Flushing output to a file or pipe”.

Serial input and output

A COM port can be attached to either of the serial ports for input and output, with selectable serial parameters, using the DataComm option.

This option is intended for use by communications packages that provide their own handshaking.

The following serial parameters are supported:

Baud rate: 50, 75, 110, 134.5, 150, 300, 600, 1200, 1800, 2400, 4800, and 9600.

The following combinations are supported:

Table 5-2. Combinations for Serial Input and Output

Data bits

Parity

Stop bits

8

None

1

7

Even

1

7

None

2

7

Odd

1

By default, COM1: is set up by the following MODE command in the AUTOEXEC.BAT file:

MODE COM1:9600,N,8,1

This gives the following communications settings:

9600 baud, no parity, 8 data bits, and 1 stop bit.

This setting can be changed with the MODE command.

To use serial input and output

  1. Connect the serial device to the workstation's serial port.

  2. Choose Comms Ports… from the COM/LPT Ports cascade menu on the Options menu.

    The Comms Ports dialog box appears.

  3. Choose Device from the COM1: popup menu.

    Figure 5-10. The Comms Ports Dialog Box


    You should enter the appropriate device name for the port you want to use. If necessary, ask your system administrator.

  4. If the serial device needs flow control, set Flow Control.

Serial port emulation

SoftWindows uses facilities provided by the Unix terminal device drivers to determine the state of the serial port. As a result, the PC/AT serial port cannot be fully emulated, although most devices and packages designed to operate with it will work equally well on SoftWindows.

The following technical details are provided for users who need specialized help in getting a device or package to work properly or who are developing software which uses the serial ports.

DSR (Data Set Ready)

This line is always held high.

The effect is that devices can detect DTR (Data Terminal Ready), but a response from the device via DSR cannot be detected by SoftWindows. Therefore SoftWindows cannot support hardware handshaking, and XON/XOFF software handshaking should be used instead.

RI (Ring Indicator)

This modem input signal cannot be detected and is forced off by the software.

Input errors

The occurrence of input overrun and framing errors in the hardware or an input break condition cannot be detected.

Recommendations

The following should be noted if you are choosing a package to run under SoftWindows on the Unix workstation or you are developing software that uses the serial ports for communication.

  • You should normally use 4800 baud or lower. Higher speeds are likely to be less reliable.

  • The packet size should be kept small: 512 to 1024 bytes is a suitable size.

  • Interrupt driven is preferable to polled data transfer. When SoftWindows receives data from an external source with XON/XOFF data flow control, the program running on SoftWindows may have problems. This is due to host buffering of input data preventing the program from responding quickly enough to XOFF signals.