tags:

views:

698

answers:

4

Hello,

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

+4  A: 

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

ho1
+1  A: 

Thanks for the answer.

The Problem is that the important thing is that i want know is the TotalPrintedPages in the complete Life of the printer. This is stored in the printer, whith SNMP i get this information out of a network printer. But how can i do this with Local, USB or PPI connected Printers?

Thanks...

Werewolve
A: 

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.

Lex Li
I didn't say that i want use SNMP. I search for a Way to Get Information over USB or PPI like SNMP.
Werewolve
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.
Cristian
+4  A: 

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

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

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.

Cristian
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.
Lex Li
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.
Werewolve
I think that my last edit covers everything I can do on this topic, I have no more ideas without more information
Cristian
ok thanks.It's not a .Net assembly :(What informations do you need?
Werewolve