• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Get printer make and model

 
Ranch Hand
Posts: 205
2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am looking for a way to get the make, model and hardware version of a network printer. I found the following code but it only brings back the name not the information I need. Any suggestions on getting the information I need?



TIA
 
Marshal
Posts: 4510
572
VSCode Eclipse IDE TypeScript Redhat MicroProfile Quarkus Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You can get some queue-related information from the print services  attributes, but not what you are wanting.  Maybe there is a different API to get the actual hardware-related information?  If you knew the IP addresses, you could probably use SNMP to GET what you are looking for.

 
Ron McLeod
Marshal
Posts: 4510
572
VSCode Eclipse IDE TypeScript Redhat MicroProfile Quarkus Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Here's an example of retrieving the model number and serial number using SNMP.  There are a number of standardized OIDs that most printers should support.

I used a command line tool, but there are Java libraries as well.
 
Saloon Keeper
Posts: 27807
196
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
There may be an additional issue in that Java Print Services is probably going to return the logical printer names as defined to the local machine OS and not the canonical printer names and locations.

In and of itself, that's insufficient. It won't even tell you which machine the printer is on, much less the interface type (Centronics Parallel, USB, Ethernet, WiFi, etc.). Some interfaces, such as the old-style parallel were one-way and thus impossible to query. SNMP only works for direct network connections. It wouldn't work on my printer, because it's a USB device on a remote CUPS server.

So a universal solution - especially one that doesn't allow intrusion into remote systems - is probably impossible. If you have a specific set of printers - and they have direct network IP addresses - AND if you are allowed SNMP access to them, then you'll be able to use Java SNMP queries to find out more. Note that the OIDs returned for different printer models and manufacturers may vary so it's going to be more confirming your guesses than directly obtaining what you want.

As I mentioned, my own printer is presently connected as a USB device to a print server machine. Although initially I'd used a parallel-port cable. For comparison with SNMP, this is what a remote shell "lspci" command tells me about it:

 
John Morgan
Ranch Hand
Posts: 205
2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Just to clarify what I am trying to do. We have an application that sends overnight batch printing jobs to remote printers in different cities. Not all these printers have SNMP turned on for various reasons and some times the printers are changed with a different make and model without our knowledge. So what I am trying to do is reach out to the printer, grab the make and model, check that against an approved list of makes and models from our print server and if it is okay then send the print job, if not then send an email to the person in charge of that printer stating their batch print was not sent as the printer was not on the approved list. Most of this we have covered, except getting the hardware information.

Thanks for all the suggestions so far.
 
Tim Holloway
Saloon Keeper
Posts: 27807
196
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If you have sufficient authority to refuse to print, you likely can obtain authority to refuse printers that don't expose SNMP. SNMP being what it is, just using it means that you probably need a qualified technician to properly enable and secure it (think of it as Job Creation).

Modern printing systems actually don't restrict themselves to a single physical printer. If I was printing a lot, I could set up a whole bank of printers serving a single print queue and that would be done at the print server end. However, you don't see much of that anymore, since while the Paperles Office still eludes us, bulk printing is something that few concerns do unless they are bulk mailing.
 
Saloon Keeper
Posts: 7590
177
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Using a library like https://github.com/4thline/cling you can try to determine information via UPnP. DNS-SD, for which Java client libraries exist as well, is another route to gathering information about network devices.
 
reply
    Bookmark Topic Watch Topic
  • New Topic