SNMP for Local printer?
Asked Answered
L

3

11

I am searching for a way to Get Information from a local printer. Maybe with the SNMP Protocol?

The printer is connected with USB or PPI (parallel port). All printers have a internal TotalPagesCount and support SNMP.

Here some examples of the Printers:

  • Brother HL1430
  • Brother HL5150
  • Brother HL1230
  • Kyocera 1118
  • Kyocera 1128
  • Kyocera 2000
  • Kyocera 1300
  • Kyocera 3920
  • Kyocera 1920
  • Kyocera 1350

Is this possible? Thanks

Lugar answered 30/4, 2010 at 12:35 Comment(3)
This is too vague to answer meaningfully. Please provide at least: What printer model? What information are you looking for? What do you want to do with the information?Effortless
Also, what does "connected with PPI" mean? Is PPI an interface? I've never heard of it. Please spell out all abbreviations in questions, unless they're really common (like USB :-) ).Effortless
The printer is from Kyocera, HP or Brother i can't say a specific model.... I look for the Toner status, the printedPages and the serialnumber. I want list the information in a listbox or something like this. PPI is parallel Port.Lugar
R
18

I think SNMP is the correct approach. Most printers implement the standard printer MIB and the RFC 1213 MIB so any property you can get from there is going to be model independent. For instance, if you look for the serial number your property is probably prtGeneralSerialNumber 1.3.6.1.2.1.43.5.1.1.17

For other properties you are going to need to search in the specific MIBs, for instance in the HP Laserjet MIB you have a lot of stuff like printed-media-usage, printed-media-simplex-count, printed-media-duplex-count, usage-average-toner-coverage, scanned-media-usage, total-color-page-count.....

To use SNMP the most extended library is Net-SNMP but it uses a C API and I don't recommend it if you need to use it in heavy multithreaded applications or using SNMPv3. There are other libraries like link text that look very promising, but most of the reliable libraries out there commercial and not very cheap.

All the above is quite easy to implement if the printer is network connected, now if the printer is USB or PPI connected you need to get your hands into the HP SNMP Proxy Agent, you can find a great post here. It says that basically it is a little Windows software that piggy-backs on the standard Windows SNMP service and provides SNMP data on the default HP printer connected to a computer via USB or parallel cable. I don't know if it works with any other brands but it looks like it uses the standard protocol DOT4 over USB to emulate typical TCP/IP communications. If there is any standard method to connect to all those printers this one is the most promising. Another method that I can think of is to hack the individual drivers of each model to see if they provide such information (which most certainly do) and make the respective calls to them to get it, but on this task I think that you are on your own.

EDIT

With driver hacking I mean reverse engineering probably the tools of each driver. For example, if a printer has a utility that shows the toner status try to understand how it works, I would start using Depends to open the executable and see which dlls it is using and what methods they publish, if you find a method like GetTonerStatus in the dll it is worth to try to use it.

alt text
(source: dependencywalker.com)

If the tool is written in .Net it much easier because yo can have access to the source code by decompiling it (I don't know about legal issues of this method). Use reflector to do it and you will see it clearly.

alt text
(source: corypeters.net)

There is a great book that covers this aspects called Reversing: Secrets of Reverse Engineering

As said before this is a long path but probably the only one to achieve what you want to do, you might want to reconsider the viability of project after investigating a bit the topics I mentioned.

Runofthemine answered 9/5, 2010 at 6:37 Comment(4)
Though it is not a public standard, it is nice to know that some vendor tries to utilize SNMP for more stacks. But yes, it is vendor dependent and may not work for all models.Oaten
Thanks for this long great Answer. ...... Do you have maybe a link over the driver hacking? I think the Proxy is not the right solution for me, because i cant see how it works and build my own application to monitoring printers.Lugar
I think that my last edit covers everything I can do on this topic, I have no more ideas without more informationRunofthemine
ok thanks. It's not a .Net assembly :( What informations do you need?Lugar
C
4

You can get out quite a bit of information about printers via WMI, though I'm not sure if it contains the information you're looking for:
http://msdn.microsoft.com/en-us/library/Aa394363

I think HP printers store their Serial-numbers somewhere under this registry key (possibly a key called identity or similar):
HKEY_LOCAL_MACHINE\SOFTWARE\Hewlett-Packard\

I've never used SNMP, though I remembered this library that might be of use if you go down that route:
http://www.codeproject.com/KB/cs/SNMPDLL.aspx

Cachet answered 30/4, 2010 at 21:45 Comment(0)
O
0

SNMP standard does not support USB or other connection types. It only supports TCP/IP stack over Ethernet. Therefore, the answer should be NO or impossible.

But we do see some companies immplement SNMP over other network/connection types. However, such customization is not standardized, and you cannot make SNMP queries using standard MIB browsers or so on.

Oaten answered 6/5, 2010 at 4:42 Comment(2)
I didn't say that i want use SNMP. I search for a Way to Get Information over USB or PPI like SNMP.Lugar
Although this is part of the reality, it is not always completely true, most printers implement the standard printer MIB and there is a proxy to do SNMP over USB. See my answer.Runofthemine

© 2022 - 2024 — McMap. All rights reserved.