hal_parport(9)
π NAME π
hal_parport β a realtime HAL component whose entire personality is communicating with one or more PC parallel ports. That's it, that's the job, and honestly? She ate. (This page lives in the "HAL Realtime Component" part of the manual, iykyk.)
β¨ SYNOPSIS β¨
loadrt hal_parport cfg="port_addr [type] [[port_addr [type] ...]"
π¦ DESCRIPTION π¦
okay so bestie, hal_parport is a realtime component π« that provides connections from HAL (via halpins) straight to the physical pins of one or more parallel ports. She comes with a read function and a write function so you can send data to and receive data from whatever parallel port(s) you've got attached. π«Ά
She supports up to 8 physical parallel ports. Eight!! That's the whole friend group. π
π OPTIONS π
cfg="port_addr [type] [[port_addr [type] ...]"β this string is where you tellhal_parportthe address(es) of the parallel port(s) and whether each port is being used as an input or an output. Up to eight parallel ports are supported by the component.
The port_addr bit of the config string can be either the physical base address of a parallel port, or you can specify it as the detected parallel port via the Linux parport_pc driver. In that second case: a port_addr of 0 is the first parallel port detected on the system, 1 is the next, and so on. β¨
The type bit of the config string decides how the I/O bits of the port get used. There are four possible options, and if you don't specify one it defaults to out.
inβ sets the 8 bits of the data port to input. In this mode the parallel port has a total of 13 input pins and 4 output pins.outβ sets the 8 bits of the data port to output. In this mode the parallel port has a total of 5 input pins and 12 output pins.eppβ this option is the same as setting toout, but it can cause the computer to change the electrical characteristics of the port, see USAGE below. πxβ this option allows ports with open collectors on the control group pins to be configured as inputs, resulting in 8 output pins and 9 input pins, see USAGE below.
πΈ PINS πΈ
The pins that hal_parport creates depend on how it's configured in the cfg="" string you pass it β go peek at OPTIONS for the deets.
parport.<p>.pin-<n>-out(bit) β drives a physical output pin.parport.<p>.pin-<n>-in(bit) β tracks a physical input pin.parport.<p>.pin-<n>-in-not(bit) β tracks a physical input pin, but inverted.
For each pin created, <p> is the port number, and <n> is the physical pin number in the 25 pin D-shell connector.
For each physical output pin, the driver creates a single HAL pin, for example: parport.0.pin-14-out.
For each physical input pin, the driver creates two HAL pins, for example: parport.0.pin-12-in and parport.0.pin-12-in-not.
The -in HAL pin is TRUE if the physical pin is high, and FALSE if the physical pin is low. The -in-not HAL pin is inverted, so it's FALSE if the physical pin is high. π
Here's the input/output pin lineup by the type setting you used in the cfg="" string:
in: pins2,3,4,5,6,7,8,9,10,11,12,13,15are input pins, and pins1,14,16and17are output pins.out/epp: pins10,11,12,13and15are input pins, and pins1,2,3,4,5,6,7,8,9,14,16and17are output pins.x: pins1,10,11,12,13,14,15,16and17are input pins, and pins2,3,4,5,6,7,8,9are output pins. (See USAGE section.)
π§ PARAMETERS π§
parport.<p>.pin-<n>-out-invert(bit) β inverts an output pin.parport.<p>.pin-<n>-out-reset(bit) β (only foroutpins) TRUE if this pin should be reset when the.resetfunction is executed.parport.<p>.reset-time'(U32) β the time (in nanoseconds) between a pin is set by write and reset by the reset function if it is enabled.
π FUNCTIONS π
parport.<p>.read(funct) β reads physical input pins of port<portnum>and updates HAL-inand-in-notpins.parport.read-all(funct) β reads physical input pins of all ports and updates HAL-inand-in-notpins.parport.<p>.write(funct) β reads HAL-outpins of port<p>and updates that port's physical output pins.parport.write-all(funct) β reads HAL-outpins of all ports and updates all physical output pins.parport.<p>.reset(funct) β waits untilreset-timehas elapsed since the associated write, then resets pins to values indicated by-out-resetand-out-invertsettings. Reset must be later in the same thread as write. If-out-resetis TRUE, then the reset function will set the pin to the value of-out-invert. This can be used in conjunction with stepgen'sdoublefreqto produce one step per period. The stepgenstepspacefor that pin must be set to0to enabledoublefreq. β‘
π USAGE π
The hal_parport component is a driver for the traditional PC parallel port. The port has a total of 25 physical pins, of which 17 are used for signals. The original parallel port divided those pins into three groups: data, control, and status. The data group consists of 8 output pins, the control group consists of 4 output pins, and the status group consists of 5 input pins.
In the early 1990's, the bidirectional parallel port was introduced, which allows the data group to be used for output or input. The HAL driver supports the bidirectional port, and lets the user set the data group as either input or output. If configured as out, a port provides a total of 12 outputs and 5 inputs. If configured as in, it provides 4 outputs and 13 inputs.
In some parallel ports, the control group pins are open collectors, which may also be driven low by an external gate. On a board with open collector control pins, if configured as x, it provides 8 outputs, and 9 inputs.
In some parallel ports, the control group has push-pull drivers and cannot be used as an input.
π Note: HAL and Open Collectors
HAL cannot automatically determine if the x mode bidirectional pins are actually open collectors (OC). If they are not, they cannot be used as inputs, and attempting to drive them LOW from an external source can damage the hardware. π
To determine whether your port has open collector pins, load hal_parport in x mode. With no device attached, HAL should read the pin as TRUE. Next, insert a 470 ohm resistor from one of the control pins to GND. If the resulting voltage on the control pin is close to 0V, and HAL now reads the pin as FALSE, then you have an OC port. If the resulting voltage is far from 0V, or HAL does not read the pin as FALSE, then your port cannot be used in x mode.
The external hardware that drives the control pins should also use open collector gates (e.g., 74LS05).
On some computers, BIOS settings may affect whether x mode can be used. SPP mode is most likely to work.
No other combinations are supported, and a port cannot be changed from input to output once the driver is installed. π«
The parport driver can control up to 8 ports (defined by MAX_PORTS in hal_parport.c). The ports are numbered starting at zero.
π οΈ Loading the hal_parport component
The hal_parport driver is a real time component so it must be loaded into the real time thread with loadrt. The configuration string describes the parallel ports to be used, and (optionally) their types. If the configuration string does not describe at least one port, it is an error.
loadrt hal_parport cfg="port [type] [port [type] ...]"
π Specifying the Port
Numbers below 16 refer to parallel ports detected by the system. This is the simplest way to configure the hal_parport driver, and it cooperates with the Linux parport_pc driver if it is loaded. A port of 0 is the first parallel port detected on the system, 1 is the next, and so on.
β Basic configuration
This will use the first parallel port Linux detects:
loadrt hal_parport cfg="0"
π’ Using the Port Address
Instead, the port address may be specified using the hex notation 0x then the address.
loadrt hal_parport cfg="0x378"
π·οΈ Specifying a port Type
For each parallel port handled by the hal_parport driver, a type can optionally be specified. The type is one of in, out, epp, or x.
If the type is not specified, the default is out.
A type of epp is the same as out, but the hal_parport driver requests that the port switch into EPP mode. The hal_parport driver does not use the EPP bus protocol, but on some systems EPP mode changes the electrical characteristics of the port in a way that may make some marginal hardware work better. The Gecko G540's charge pump is known to require this on some parallel ports. π
See the Note above about mode x.
π― Example with two parallel ports
This will enable two system-detected parallel ports, the first in output mode and the second in input mode:
loadrt hal_parport cfg="0 out 1 in"
1οΈβ£ Functions single port
You must also direct LinuxCNC to run the read and write functions.
addf parport.read-all base-thread
addf parport.write-all base-thread
π Functions multiple ports
You can direct LinuxCNC to run the read and write functions for all the attached ports.
addf parport.0.read base-thread
addf parport.0.write base-thread
The individual functions are provided for situations where one port needs to be updated in a very fast thread, but other ports can be updated in a slower thread to save CPU time. It is probably not a good idea to use both an -all function and an individual function at the same time. π
π SEE ALSO π
- Parallel Port Driver (Hardware Drivers Section of LinuxCNC Docs)
PCIParallelPortExample(HardwareExamplesSectionofLinuxCNCDocs)
π AUTHOR π
This man page written by Joe Hildreth as part of the LinuxCNC project. Most of this information was taken from the parallel-port docs located in the Hardware Drivers section of the documentation. To the best of my knowledge that documentation was written by Sebastian Kuzminsky and Chris Radek.
and that's the whole page bestie!! π this beauty shipped as part of the LinuxCNC Documentation, dated 12 APR 2017 β go forth and parport responsibly, mwah πβ¨
π¦ where this page comes from
- debian trixie: linuxcnc-uspace 1:2.9.4-2+deb13u1 Β· GFDL-1.1-or-later
- ubuntu questing: linuxcnc-uspace 1:2.9.4-2ubuntu2
- ubuntu resolute: linuxcnc-uspace 1:2.9.4-2ubuntu4 Β· GFDL-1.1-or-later
- ubuntu stonking: linuxcnc-uspace 1:2.9.4-2ubuntu4 Β· GFDL-1.1-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms