---
name: "ieee1284_read_control"
section: "3"
platform: "linux"
package: "libieee1284"
version: "0.2.11-19"
release: "Arch Linux 2026-11-01"
platforms: ["linux"]
url: "https://new.carta.tech/ieee1284_read_control"
---

# ieee1284\_read\_control(3)

manipulate control lines

## NAME

ieee1284\_read\_control, ieee1284\_write\_control, ieee1284\_frob\_control, ieee1284\_do\_nack\_handshake - manipulate control lines

## SYNOPSIS

```
#include <ieee1284.h>
```

**int ieee1284\_read\_control(struct parport \****port***);**

**void ieee1284\_write\_control(struct parport \****port***, unsigned char** *ct***);**

**void ieee1284\_frob\_control(struct parport \****port***, unsigned char** *mask***, unsigned char** *val***);**

**int ieee1284\_do\_nack\_handshake(struct parport \****port***, unsigned char** *ct\_before***, unsigned char** *ct\_after***, struct timeval \****timeout***);**

## DESCRIPTION

There are four control lines, three of which are usually inverted on PC-style ports. Where they differ, libieee1284 operates on the IEEE 1284 values, not the PC-style inverted values. The control lines are represented by the following enumeration:

```
enum ieee1284_control_bits
{
  C1284_NSTROBE   = 0x01,
  C1284_NAUTOFD   = 0x02,
  C1284_NINIT     = 0x04,
  C1284_NSELECTIN = 0x08,
  /* To convert those values into PC-style register values, use this: */
  C1284_INVERTED = (C1284_NSTROBE|
                    C1284_NAUTOFD|
                    C1284_NSELECTIN),
};
```

These functions all act on the parallel port associated with *port*, which must be claimed.

The current values on the control lines are available by calling **ieee1284\_read\_control**, and may be set by calling **ieee1284\_write\_control**.

To adjust the values on a set of control lines, use **ieee1284\_frob\_control**. The effect of this can be expressed by: ctr = ((ctr & ~mask) ^ val); that is, the bits in *mask* are unset, and then those in *val* are inverted.

The special function **ieee1284\_do\_nack\_handshake** is for responding very quickly in a protocol where the peripheral sets nAck and the host must respond by setting a control line. Its operation, which relies on the host machine knowing which interrupt nAck generates, is as follows:

 1\. Set the control lines as indicated in *ct\_before*.

 2\. Wait for nAck interrupt. If *timeout* elapses, return **E1284\_TIMEDOUT**.

 3\. Set the control lines as indicated in *ct\_after*.

On Linux using the ppdev driver, this is performed by the device driver in the kernel, and so is faster than normally possible in a user-space library.

## RETURN VALUE

The return value of **ieee1284\_read\_control**, if non-negative, is a number representing the value on the control lines.

Possible error codes for **ieee1284\_read\_control**:

**E1284\_NOTAVAIL**

The control lines of this port are not accessible by the application.

**E1284\_INVALIDPORT**

The *port* parameter is invalid (for instance, perhaps it is not claimed).

Possible error codes for **ieee1284\_do\_nack\_handshake**:

**E1284\_OK**

The handshake was successful.

**E1284\_NOTAVAIL**

This operation is not available on this port type or system. This could be because port interrupts are not available, or because the underlying device driver does not support the operation.

**E1284\_INVALIDPORT**

The *port* parameter is invalid (for instance, perhaps it is not claimed).

## AUTHOR

**Tim Waugh** \<twaugh@redhat.com\>

Author.

## COPYRIGHT

Copyright © 2001-2003 Tim Waugh\
