Coder Social home page Coder Social logo

epson-printer-snmp's Introduction

epson-printer-snmp

GitHub license GitHub last commit Code style: black

Read information and reset waste ink counters on Epson printers, using SNMP.

Description

This project was designed for a EPSON WF-7525 Series printer, but inspired by projects for other models. Hopefully, releasing this code will help save a printer from the trash and improve consumer repairability for these devices. Information about specific models is stored in models.json, as a dictionary. Feel free to raise an issue/pull request for adding support for another model of printer, with logs from wicreset or similar attached.

The format for reading values is:

{eeprom_link}.124.124.7.0.{password}.65.190.160.{oid}.0

The format for setting values is:

{eeprom_link}.124.124.16.0.{password}.66.189.33.{oid}.0.{value}.{eeprom_write}

Where eeprom_link is consistently 1.3.6.1.4.1.1248.1.2.2.44.1.1.2.1 and password is two values, e.g. 101.0. password and eeprom_write seem to vary between different models of printer. This can be found by using a tool, such as wicreset, and checking the request it sends. A method for brute forcing the password is provided in Session.brute_force, which tries to get a value from the EEPROM, for every permutation of [0x00, 0x00] to [0xFF, 0xFF].

Setting values is done by getting an address, where the OID and value to set is specified in the query. Certain values of these formats also vary between models of printer.

Various methods are defined to get specific information. The Printer.stats method will return a dictionary of most useful information.

Values for waste ink levels are stored across multiple addresses, which, when reversed, combine to make a value in hex. This value is then divided by a constant, which again seems to vary across models of printer, to make the percentage. The constant value can be found by using wicreset to read the counters' percentage, getting the hex values of these OIDs, then following the above process to solve: e.g.

# Percentage is 80%.
# Hex values are (0x68, 0x3d) => 0x3d68

(0x3d68 / 80) * 100 = 19650.0

Please note that different counters for the same printer may use different constants.

Courtesy of @PeaShooterR, some models of printers seem to store waste ink counters in a slightly different way, across three counters instead of two (see issue #1).

To compare, wicreset writes the following values for the specified model of printer:

WF-7525PX-047A
OID Value Usage
20 104 Counter 1 (shown)
21 61 Counter 1 (shown)
22 68 Counter 2 (shown)
23 16 Counter 2 (shown)
24 0 Counter 1 (real)
25 0 Counter 1 (real)
59 0 Unknown
60 94 Maintenance level 1
61 94 Maintenance level 2
OID Value Usage
24 120 Counter 1 (shown)
25 12 Counter 1 (shown)
26 44 Counter 2 (shown)
27 10 Counter 2 (shown)
30 0 Counter 1 (shown)
28 0 Counter 1 (real)
29 0 Counter 1 (real)
34 0 Counter 2 (shown)
46 94 Maintenance level 1
47 94 Maintenance level 2
49 0 Unknown

Whenever a print job is received, the printer will compare the REAL data and the SHOWN data, then updates SHOWN data to the larger value. After performing operations such as head cleaning that increase the counter, the printer increments the SHOWN data and saves it to both (24, 25, 30) and (28, 29).

Libraries

Resources

reink-net = https://github.com/gentu/reink-net

  • Used as a starting point to create this Python implementation and translated for different model of printer

epson-l4160-ink-waste-resetter = https://github.com/nicootto/epson-l4160-ink-waste-resetter

wicreset = https://wic-reset.com / https://www.2manuals.com / https://resetters.com

  • The key, trial, can be used to reset your counters to 80%. After packet sniffing with wireshark, the correct OIDs can be found
  • This application also stores a log containing SNMP information at ~/.wicreset/application.log on Linux-based systems, or %APPDATA%\wicreset\application.log on Windows.

License

epson-printer-snmp is licensed under the GPL v3 for everyone to use, modify and share freely.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

GPL v3 Logo

Donate

If you found this project useful, please consider donating. Any amount is greatly appreciated! Thank you ๐Ÿ˜ƒ

PayPal

My bitcoin address is: bc1q5aygkqypxuw7cjg062tnh56sd0mxt0zd5md536

epson-printer-snmp's People

Contributors

rickbonavigo avatar zedeldi avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

epson-printer-snmp's Issues

Support for ET-2700

Hi, this project seems the key to my printer, but i cannot get it working on my ET-2700.
I have not understand well the readme, i have to obtain the oid from wicreset? If that's the case i'm in big problem, because i have already used my trial key, and i cannot get the log file from reading the counter.

I attach the error that the script outputs:

Traceback (most recent call last):
File "/home/adriadam10/epson-printer-snmp/main.py", line 198, in
pprint(printer.stats)
^^^^^^^^^^^^^
File "/home/adriadam10/epson-printer-snmp/main.py", line 52, in stats
return {
^
File "/home/adriadam10/epson-printer-snmp/main.py", line 53, in
method[4:]: self.session.getattribute(method)() for method in methods
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/adriadam10/epson-printer-snmp/main.py", line 135, in get_serial_number
for value in self.read_eeprom_many(
^^^^^^^^^^^^^^^^^^^^^^
File "/home/adriadam10/epson-printer-snmp/main.py", line 110, in read_eeprom_many
return [self.read_eeprom(oid) for oid in oids]
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/adriadam10/epson-printer-snmp/main.py", line 110, in
return [self.read_eeprom(oid) for oid in oids]
^^^^^^^^^^^^^^^^^^^^^
File "/home/adriadam10/epson-printer-snmp/main.py", line 99, in read_eeprom
response = re.findall(r"EE:[0-9A-F]{6}", response)[0][3:]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^
IndexError: list index out of range

Epson L366

Unfortunately, I didn't understand how to modify models.json to make it work with other printers, but I can provide log file from wicreset...
application.log

WIC goes back to its previous value after reboot+print

I forked a copy of your code and made modifications for my own printer.

By sniffering WIC Reset Utility I found that it reads 24, 25, 30, 26, 27, 34. And the 'write' command of my printer is
.78.118.116.100.98.115.106.47

I reset the values of 24, 25, 30, 26, 27, and 34 to 0. After rebooting the printer and printing a document, the second waste ink level successfully reset to 0, but the first waste ink level reverted back to its previous value.

I noticed that you also set a few other oids in line 168.
data = {20: 0, 21: 0, 22: 0, 23: 0, 24: 0, 25: 0, 59: 0, 60: 94, 61: 94}
I think the issue might be related to those additional oids.
Could you please let me know what they are and how I can find them?

Thank your for your work.

Can you explain what is solved

Can you explain what exactly is solved and why:

Values for waste ink levels are stored across multiple addresses, which, when reversed, combine to make a value in hex. This value is then divided by a constant, which again seems to vary across models of printer, to make the percentage. The constant value can be found by using wicreset to read the counters' percentage, getting the hex values of these OIDs, then following the above process to solve: e.g.

# Percentage is 80%.
# Hex values are (0x68, 0x3d) => 0x3d68

(0x3d68 / 80) * 100 = 19650.0

I originally used https://github.com/gentu/reink-net/ with some modifcations (gentu/reink-net#1) and found that the values get reset after the printer restarts.

I finally just ran wicreset and reset with the trial code and also cleared the errors
wic-application.log

I see 79.99% and 80%

From the log 18C216 and 266316
6,338/79.99 = 79.234904363045380672584073009126
9827/80 = 122.8375;

Only later that I saw that you said to not write first but read first... anyway here is the read only (done after the fact)
wic-application-read.log

I see 80.97% and 80%, maybe due to a printer purge cycle?

The ruby app gets these value. There is a bug in the multibyte read getting 19F16 is 415 instead of 190F16 which is 6415

5% Waste ink counter 1. Value: 415 // should have been 6415 = 190F16
80% Waste ink counter 2. Value: 9827 = 266316

  def waste_ink_levels
    val1 = read_eeprom_multibyte(@printer[:waste_ink1])
    puts "%i%%\tWaste ink counter 1. Value: %i" % [(val1/81.92).round, val1]

    val2 = read_eeprom_multibyte(@printer[:waste_ink2])
    puts "%i%%\tWaste ink counter 2. Value: %i" % [(val2/122.88).round, val2]
  end

6415/80.97 = 79.226874150920093861924169445474; //seems to correlate quite well with WicReset prior value, but not reink
9827/80 = 122.8375; // close to reink value (hex did not change since last time)

So now that I have this (at least I think I have these) values how do I use them?

Very curious, with my limited understand it looks like wicreset also reads OE16 OF16 and 1016 and 1116, but it also seems to read 3C16.

EDIT:
Well I just reset the for 1016, 1116, 0E10, 0F16 again, values were at 0 and after test page print one counter was set to 1.6% and after a head cleaning moved to 3.23%.... normal? I don't know enough . I wonder if I didn't turn off the printer fast enough last time or that reink maybe needs to reset some other values

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.