IEEE1284_GET_DEVICEI(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_get_deviceid β€” that's IEEE1284_GET_DEVICEI(3), from the Functions girlies ✨

okay so bestie. you wanna know what a printer is. like, its whole identity. its government name. that's this function, and honestly? it ate. πŸŽ€


🌸 SYNOPSIS 🌸

#include <ieee1284.h>

ssize_t ieee1284_get_deviceid(struct parport *port, int daisy,
                              int flags, char *buffer, size_t len);

πŸ¦‹ DESCRIPTION πŸ¦‹

so this function? it's the one that goes and fetches the IEEE 1284 Device ID of whatever device you point at. and how do you point at it? two ways, bestie:

  • by the port it's plugged into
  • optionally by an address (daisy) on the daisy chain of devices hanging off that port

now daisy is giving very specific instructions and you need to respect them:

  • -1 means "this device is NOT in an IEEE 1284.3 daisy chain, it's the last (or only) one on the port" πŸ‘‘
  • 0 through 3 inclusive means "yep, it's on the chain, and this is its address" β€” and btw 0 is the one next to the port, just so you know the order πŸ’…

then there's flags, and she's a bitwise union of whatever flags your program wants to use. here's the menu:

  • F1284_FRESH β€” no cap, guaranteed fresh Device ID. a cached one or an OS-provided one will not be used. it's giving farm-to-table. πŸ“

and your buffer? it has to be at least len bytes long, okay? on a successful return it'll hold the Device ID β€” including the initial two-byte length field and a terminating zero byte β€” or like, as much of all that as will actually fit in the buffer. so maybe make it big. just saying. πŸ™ˆ


πŸ’€ RETURN VALUE πŸ’€

if the return value is less than zero, that's an error (see the list below, bestie). otherwise, the return value is the number of bytes of buffer that got filled.

and if the return value equals the length of the buffer? that's the function gently telling you the Device ID might be longer than your buffer can hold. it's not mad, it's just disappointed. 😭

the errors, one by one:

  • E1284_NOID β€” the device did not provide an IEEE 1284 Device ID when interrogated (maybe the OS was asked instead, if F1284_FRESH wasn't specified). she simply had nothing to say. πŸ’€
  • E1284_NOTIMPL β€” one or more of the flags you passed isn't supported in this implementation, OR if you passed no flags at all, then this function just isn't implemented for this type of port or this type of system. also can come back at you if you specified a daisy chain address but daisy chain Device IDs are not yet supported. 🫠
  • E1284_NOTAVAIL β€” you said F1284_FRESH and the library can't even get at the port to interrogate the device. rude.
  • E1284_NOMEM β€” there is not enough memory. tragic.
  • E1284_INIT β€” there was a problem initializing the port. 😡
  • E1284_INVALIDPORT β€” the port parameter is invalid. check her again. πŸ‘€

πŸŽ€ NOTES πŸŽ€

okay this is the part where you actually listen, because it's important.

unless you give the F1284_FRESH flag, the library is gonna try to find the device's ID as unobtrusively as possible. the order of operations is:

  1. first it asks the operating system if it already knows it
  2. then it'll try actually asking the device for it

and because of that whole vibe, the Device ID you get back may be partially computed (the length field, for example) or even partially missing if the OS only remembered some parts of the ID. to guarantee you're getting the actual bytes the device sent, use F1284_FRESH. periodt.

⚠️ also be aware: the operating system may allow any user to inspect the Device IDs it provides, whereas actual device access is normally way more restricted. so like, yikes, know that before you go F1284_FRESH-ing everywhere.

and about that initial two-byte length field β€” she's a big-endian 16 bit unsigned integer provided by the device, and she may not be accurate. in particular, it's meant to indicate the length of the entire string including the length field itself; however, some manufacturers exclude the length field, or just set the length field to some arbitrary number greater than the ID length. manufacturers stay unserious. πŸ™„


πŸ‘‘ AUTHOR πŸ‘‘

  • Tim Waugh <twaugh@redhat.com> β€” Author.

Copyright Β© 2001-2003 Tim Waugh


and that's the whole page bestie, you're so welcome πŸ’œ this was IEEE1284_GET_DEVICEI(3), from the Functions section, dated 09/18/2007 β€” go forth and interrogate some devices, mwah 🫢✨