Parallel port

(10 dec 2004) Umberto Zanghieri

ZP Engineering srl [L1 ] offers the LPTTCL extension for parallel-port access that works on Windows 98, NT, 2K and XP.

A new version has been released; there is no web page for the moment on our host, you can grab the ZIP file at [L2 ]. The old version is still there, you can get the ZIP file at [L3 ].

We reorganized this page with separate sections for the two versions. Please refer to the lpttcl page for a command reference and some tcl code to start with, along with compatibility notes between the two versions.


LPTTCL ver. 3.0

To overcome some of the limitations of LPTTCL v.1.0, a new wrapper has been added to the Inpout32.dll available at Logix4U [L4 ].

This new low-level access library allows you to avoid any installation and uninstall (a great advantage!!) and offers better compatibility on WinXP and on all machines (as we were reported that some desktops did not work properly with rev 1.0). In addition:

  • we added commands to address a generic offest (perfect for accessing the LPT Extended Control Register, useful for advanced tricks.....)
  • allowed 32-bit base address (useful for PCI-based parallel port cards)
  • added LPT selection by number and not only by address (finally); now you can select LPT1 or LPT2 and avoid looking on the Hardware Device Manager to find out the base address
  • we tried to make the command set fully backward-compatible with version 1.0; so, on existing code you may only change LPT selection (if you wish).

Please notice that the new LPT selection mode and the removed requirement for installation allow you to simply copy a few files with a wrapped executable, and you have a perfectly transportable Tcl application with LPT access. We do this with TclKit and Freewrap all the time.

Installation can be as follows: keep both DLLs in your working directory, or copy them on the system32 folder.

Consider that the extension is just released, so please report any issues you may find. In particular, we could not verify proper access with a PCI card; these LPT cards typically require a high base address ( > 1024).


LPTTCL ver. 1.0

There are still reasons to keep the old LPTTCL around: access is a faster, and may be interesting for slower hosts; also for Windows 98 it does not require installation.

A brief summary of its characteristics:

  • parallel port access is rather easy on Win98, but requires a driver on NT, 2000 and XP. LPTTCL attempts to provide the same technique on all three platforms.
  • read and write access to data port, control and status registers
  • it has been designed for simple control of external devices and emulation of serial protocols as I2C.
  • uninstall must be done manually (sorry for this), by deleting the files and by removing the HKEY_LOCAL_MACHINE\SYSTEM\CURRENTCONTROLSET\SERVICES\ZPPORT entry from the Windows registry.
  • only works for low-range I/O (ISA style). If you have a PCI parallel port card that maps into a high I/O, you will not be able to access it.
  • you need to explicitly specify the LPT base address by issuing a lp_setba command; there is no detection of base address from BIOS.
  • LPTTCL must be installed and run by a user with administrator privileges (not relevant on Win98)
  • we received feedback from many programmers that use it for access to custom hardware, development boards and similar. Someone has used it for PLD download, others for I2C bit-bang emulation, others for adding pushbuttons to a PC...
  • LPTTCL does NOT conflict with Windriver-based drivers (i.e., Xilinx parallel port cable), provided, of course, you are not using both on the same port...

Users have reported that it works correctly under Windows XP, but on some hosts it fails; we could not identify the reason, but in any case the new 3.0 version works fine for the same users.


TV (Nov 21 2003) I just tried it on XP SP1 on a few year old home pc with tcl 8.4.1, and it works fine with your driver and tcl extension. In fact it seems to process about 300 KiloBytes per second, which is hardly slow, in tcl. Do you consider it reasonable to ask for the sources, for instance of the driver? At least the machine I can use isn't in electronic isolation anymore, which is great!

For those interested, I'll make a page on applying the parallel port to drive a LED and read a switch from tcl.

(15 april 2004) Anyone ever try this library with a USB-to-parallel connection ? (I want to know if that could work on a note-book!)

UZ 15 apr04 I never tried, but I think it will not work as LPTTCL works directly on parallel port registers.


On Linux (or any other PC Unix) just open the right device (/dev/parportX, X = 0 for first port, then 1, 2, etc) and then read and write it as you wish for basic access.

Marc van DoornikOn Linux, this doesn't work for me (as root, obviously):

 set f [open /dev/parport0 r]
 set data [read $f]

as it gives me "error reading "file6": invalid argument". When I try this:

 set f [open /dev/lp0 r]
 set data [read $f]

it gives me "error reading "file6": I/O error". So what gives, here?


More-or-less public packages for dealing with parallel ports include dlportio [L5 ] and winioport.


Serial port programming is of related interest.


Category Device Control