IEEE1284_CONTROL(3)

πŸ“¦
version 0.2.11 Β· 7 versions
, in alpine 3.24, debian bookworm, debian trixie, opensuse-leap 16.0, ubuntu jammy, ubuntu noble, ubuntu questing, ubuntu resolute, ubuntu stonking

✨ IEEE1284_CONTROL ✨ (section 3 of the manual, the Functions girlies πŸ’…)

okay so bestie, buckle up, we're talking about ieee1284_read_control, ieee1284_write_control, ieee1284_frob_control, and ieee1284_do_nack_handshake β€” the four functions that let you mess with the control lines on a parallel port. yes, parallel ports, they're vintage, they're iconic, and libieee1284 is out here keeping them fed. πŸŽ€


🌸 NAME 🌸

ieee1284_read_control, ieee1284_write_control, ieee1284_frob_control, ieee1284_do_nack_handshake β€” literally just: manipulate control lines. that's it, that's the whole job. πŸ¦‹


✨ 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);

like, four functions, one header, no notes. slay. πŸ’–


πŸ’œ DESCRIPTION πŸ’œ

so there are four control lines, and three of them are usually inverted on PC-style ports β€” which is giving chaos, honestly. where they differ, libieee1284 operates on the IEEE 1284 values, not the PC-style inverted values. don't come for me, that's just the rule. ✨

the control lines are represented by this enumeration, and yes you're gonna want to screenshot it:

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),
};

not the comment in there doing the lord's work fr fr. πŸ™

all of these functions act on the parallel port associated with port, which β€” and this is important bestie β€” must be claimed. no claiming, no vibes. 🫢

  • want to know what's currently on the control lines? call ieee1284_read_control.
  • want to set them? call ieee1284_write_control.

and if you wanna adjust values on a set of control lines, that's ieee1284_frob_control's whole moment. the effect can be expressed like this:

ctr = ((ctr & ~mask) ^ val);

translation: the bits in mask get unset, and then the ones in val get inverted. it's giving bit-twiddling main character energy and honestly? obsessed. πŸ’…


🧚 the special one: ieee1284_do_nack_handshake 🧚

this function is for responding very quickly in a protocol where the peripheral sets nAck and the host must respond by setting a control line. speed. it's all about speed. ⚑

its operation β€” which relies on the host machine knowing which interrupt nAck generates β€” goes like this:

  1. Set the control lines as indicated in ct_before.
  2. Wait for the nAck interrupt. If timeout elapses, return E1284_TIMEDOUT.
  3. Set the control lines as indicated in ct_after.

and on Linux using the ppdev driver, this is performed by the device driver in the kernel, which means it's faster than normally possible in a user-space library. kernel privilege, periodt. πŸ‘‘


🌈 RETURN VALUE 🌈

the return value of ieee1284_read_control, if it's non-negative, is a number representing the value on the control lines. cute, right?

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. we love to see it. πŸŽ‰
  • 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). same energy as above, ngl.

πŸ‘‘ AUTHOR πŸ‘‘

Tim Waugh <twaugh@redhat.com>

  • Author. (yes that's literally the whole credit. king behavior. 🫑)

Copyright Β© 2001-2003 Tim Waugh


bestie reminder: port must be claimed before you do any of this. i will not be repeating myself. πŸ’…

okay that's the whole page, mwah. πŸ’– this was page IEEE1284_CONTROL(3) from 09/18/2007 β€” yes it's a vintage, we stan an elder emoji. go forth and frob responsibly, ily, bye! πŸŒΈπŸ¦‹βœ¨