Skip to content

Commit

Permalink
UI menu bar, import/export conf files from the UI, exclude L3250
Browse files Browse the repository at this point in the history
  • Loading branch information
Ircama committed Nov 3, 2024
1 parent 1f993d7 commit 6304a02
Show file tree
Hide file tree
Showing 5 changed files with 434 additions and 89 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -160,3 +160,5 @@ cython_debug/
#.idea/
devices.xml
*.toml
*.srs
*.pickle
67 changes: 43 additions & 24 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ The *Epson Printer Configuration Tool* simplifies the management of Epson printe

A range of features are offered for both end-users and developers, making it easier to administer and maintain Epson printers.

The software provides a configurable printer dictionary, which can be easily extended. In addition, it is possible to import and convert external Epson printer configuration databases.

## Key Features

- __SNMP Interface__: Seamlessly connect and manage Epson printers using SNMP over TCP/IP, supporting Wi-Fi connections (not USB).
Expand All @@ -24,36 +26,27 @@ A range of features are offered for both end-users and developers, making it eas
- Reset the ink waste counter.

The ink waste counters track the amount of ink discarded during maintenance tasks to prevent overflow in the waste ink pads. Once the counters indicate that one of the printer pads is full, the printer will stop working to avoid potential damage or ink spills. Resetting the ink waste counter extends the printer operation while a pad maintenance or tank replacement is programmed.
- Adjust the power-off timer for more accurate energy efficiency.
- Adjust the power-off timer (for more accurate energy efficiency).
- Change the _First TI Received Time_,

The *First TI Received Time* in Epson printers typically refers to the timestamp of the first transmission instruction to the printer when it was first set up. This feature tracks when the printer first operated.

- Change the printer WiFi MAC address and the printer serial number (typically used in specialized scenarios where specific device identifiers are required).
- Access various administrative and debugging options.
- Read and write to EEPROM addresses for advanced configurations.
- Dump and analyze sets of EEPROM addresses.
- Detect the access key (*read_key* and *write_key*) and some attributes of the printer configuration.

The GUI includes some features that attempt to detect the attributes of an Epson printer whose model is not included in the configuration, which can also be used with known printers, to detect additional parameters.

- Import and export printer configuration datasets in various formats: epson_print_conf pickle, Reinkpy XML, Reinkpy TOML.

- Access various administrative and debugging options.

- __User-Friendly Interfaces__:
- __Graphical User Interface (GUI)__: Intuitive interface with an autodiscovery function that detects printer IP addresses and model names.
- __Command Line Tool__: For users who prefer command-line interactions, providing the full set of features.
- __Python API Interface__: For developers to integrate and automate printer management tasks.

The GUI can automatically find and display printer IP addresses and model names, allowing users to:

- Check printer status
- Open the printer web interface
- Change the printer power-off timer, the _First TI Received Time_, the printer WiFi MAC address, and the printer serial number
- Read and write the EEPROM
- Detect the access key (*read_key* and *write_key*) and some attributes of the printer configuration
- Reset the ink waste counter

Special features allow showing the internal configuration settings.

The *First TI Received Time* in Epson printers typically refers to the timestamp of the first transmission instruction to the printer when it was first set up. This feature tracks when the printer first operated.

The software provides a configurable printer dictionary, which can be easily extended. In addition, a tool allows importing and converting an extensive Epson printer configuration DB.

The GUI includes some features that attempt to detect the attributes of an Epson printer whose model is not included in the configuration. First press "Detect Printers". If the printer is not in the configuration, press "Detect Access Keys". If the output does not show errors, press "Detect Configuration". These commands produce a tree view and a text view, which are useful to analyze whether there is a configured model that might be close or possibly same to target one. Notice that these operations take many minutes to complete and the printer shall be kept switched on for the whole period. Temporarily disabling the auto power-off timer is suggested.

"Detect Configuration" can also be used with known printers, to detect additional parameters.

Note on the ink waste counter reset feature: resetting the ink waste counter is just removing a lock; not replacing the tank will reduce the print quality and make the ink spill.

## Installation
Expand All @@ -75,6 +68,8 @@ pip3 install pyasn1==0.4.8
pip3 install git+https://github.com/etingof/pysnmp.git
pip3 install tkcalendar
pip3 install pyperclip
pip3 install black
pip3 install tomli
cd epson_print_conf
```
Expand Down Expand Up @@ -125,6 +120,28 @@ optional arguments:
epson_print_conf GUI
```

### How to import an external printer configuration DB

With the GUI, the following operations are possible (from the file menu):

- Load a PICKLE configuration file or web URL.

This operation allows to open a file saved with the GUI ("Save the selected printer configuration to a PICKLE file") or with the *parse_devices.py* utility. In addition to the printer configuration DB, this file includes the last used IP address and printer model in order to simplify the GUI usage.

- Import an XML configuration file or web URL

This option allows to import the XML configuration file downloaded from https://codeberg.org/attachments/147f41a3-a6ea-45f6-8c2a-25bac4495a1d. Alternatively, this option directly accepts the [source Web URL](https://codeberg.org/attachments/147f41a3-a6ea-45f6-8c2a-25bac4495a1d) of this file, incorporating the download operation into the GUI.

- Import a TOML configuration file or web URL

Similar to the XML import, this option allows to load the TOML configuration file downloaded from https://codeberg.org/atufi/reinkpy/raw/branch/main/reinkpy/epson.toml and also accepts the [source Web URL](https://codeberg.org/atufi/reinkpy/raw/branch/main/reinkpy/epson.toml) of this file, incorporating the download operation into the GUI.

Other menu options allow to filter or clean up the configuration list, as well as select a specific printer model and then save data to a PICKLE file.

### How to detect parameters of an unknown printer

First press "Detect Printers". If the printer is not in the configuration, press "Detect Access Keys". If the output does not show errors, press "Detect Configuration". These commands produce a tree view and a text view, which are useful to analyze whether there is a configured model that might be close or possibly same to target one. Notice that these operations take many minutes to complete and the printer shall be kept switched on for the whole period. Temporarily disabling the auto power-off timer is suggested.

### How to revert a change performed through the GUI

The GUI displays a `[NOTE]` in the status box before performing any change, specifying the current EEPROM values before the rewrite operation. This line can be copied and pasted as is into the text box that appears when the "Write EEPROM" button is pressed; the execution of the related action reverts the changes to their original values.
Expand Down Expand Up @@ -649,14 +666,16 @@ Example of advanced printer status with an XP-205 printer:

## Resources

### snmpget (Linux)
### snmpget

Installation:
Installation with Linux:

```
sudo apt-get install snmp
```

There are also [binaries for Windows](https://netcologne.dl.sourceforge.net/project/net-snmp/net-snmp%20binaries/5.7-binaries/net-snmp-5.7.0-1.x86.exe?viasf=1) which include snmpget.exe, running with the same arguments.

Usage:

```
Expand Down Expand Up @@ -695,7 +714,7 @@ emanage x900: https://github.com/abrasive/x900-otsakupuhastajat/
- Epson Maintenance Reset Utility: https://epson.com/epsonstorefront/orbeon/fr/us_regular_s03/us_ServiceInk_Pad_Reset/new
- Epson Ink Pads Reset Utility Terms and Conditions: https://epson.com/Support/wa00370
- Epson Adjustment Program (developed by EPSON)
- WIC-Reset: https://wic-reset.com / https://www.2manuals.com / https://resetters.com (Use at your risk)
- WIC-Reset: https://www.wic.support/download/ / https://www.2manuals.com / (Use at your risk)
- PrintHelp: https://printhelp.info/ (Use at your risk)

### Other resources
Expand Down
46 changes: 44 additions & 2 deletions epson_print_conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import os
import yaml
from pathlib import Path
import pickle

# The pysnmp module uses functionality from importlib.util and
# importlib.machinery, which were seperated from the importlib module
Expand Down Expand Up @@ -262,6 +263,7 @@ class EpsonPrinter:
},
"serial_number": range(192, 202),
},
"""
"L3250": {
"alias": ["L3251", "L3253", "L3255"],
"read_key": [74, 54],
Expand Down Expand Up @@ -290,6 +292,7 @@ class EpsonPrinter:
"Total scan counter": [1843, 1842, 1841, 1840],
},
},
"""
"ET-2400": {
"alias": ["ET-2401", "ET-2403", "ET-2405"],
"read_key": [74, 54],
Expand Down Expand Up @@ -2480,6 +2483,41 @@ def write_simdata(self, file):
return True


def get_printer_models(input_string):
# Tokenize the string
tokens = re.split(" |/", input_string)
if not len(tokens):
return []

# Define the words to remove (uppercase, then case insensitive)
remove_tokens = {"EPSON", "SERIES"}

# Process tokens
processed_tokens = []
non_numeric_part = ""
pre_model = ""
for token in tokens:
upper_token = token.upper()

# Remove tokens that match remove_tokens
if any(word == upper_token for word in remove_tokens):
continue
if not any(char.isdigit() for char in token): # no alphanum inside
pre_model = pre_model + token + " "
continue
# Identify the non-numeric part of the first token
if not token.isnumeric() and not non_numeric_part:
non_numeric_part = "".join(c for c in token if not c.isdigit())
# if token is numeric, prepend the non-numeric part
if token.isnumeric():
processed_tokens.append(f"{pre_model}{non_numeric_part}{token}")
else:
processed_tokens.append(f"{pre_model}{token}")
if not processed_tokens and pre_model:
processed_tokens.append(pre_model.strip())
return processed_tokens


if __name__ == "__main__":
import argparse
from pprint import pprint
Expand Down Expand Up @@ -2687,7 +2725,11 @@ def auto_int(x):

conf_dict = {}
if args.pickle:
conf_dict = pickle.load(args.pickle[0])
try:
conf_dict = pickle.load(args.pickle[0])
except Exception as e:
print("Error while loading the pickle file:", e)
quit(1)

printer = EpsonPrinter(
conf_dict=conf_dict,
Expand Down Expand Up @@ -2733,7 +2775,7 @@ def auto_int(x):
print("List of known keys:")
print("\n".join(printer.list_known_keys()))
else:
print(f"Cannot found read_key")
print(f"Could not detect read_key.")
if args.ftrt:
print_opt = True
if printer.write_first_ti_received_time(
Expand Down
20 changes: 9 additions & 11 deletions parse_devices.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import textwrap
import tomli

from ui import get_printer_models
from epson_print_conf import get_printer_models, EpsonPrinter

WASTE_LABELS = [
"main_waste", "borderless_waste", "third_waste", "fourth_waste",
Expand Down Expand Up @@ -53,7 +53,7 @@ def traverse_data(element, depth=0):


def generate_config_from_xml(
config, traverse, add_fatal_errors, full, printer_model
config, traverse=False, add_fatal_errors=False, full=False, printer_model=False
):
irc_pattern = [
r'Ink replacement counter %-% (\w+) % \((\w+)\)',
Expand Down Expand Up @@ -231,12 +231,12 @@ def generate_config_from_xml(

def normalize_config(
config,
remove_invalid,
expand_names,
add_alias,
aggregate_alias,
maint_level,
add_same_as,
remove_invalid=True,
expand_names=True,
add_alias=True,
aggregate_alias=True,
maint_level=True,
add_same_as=True,
):
logging.info("Number of configuration entries before removing invalid ones: %s", len(config))
# Remove printers without write_key or without read_key
Expand Down Expand Up @@ -360,7 +360,7 @@ def normalize_config(
return config

def generate_config_from_toml(
config, printer_model, full,
config, printer_model=None, full=False,

):
# Generate "read_key" values
Expand Down Expand Up @@ -650,8 +650,6 @@ def main():
if args.pickle:
pickle.dump(normalized_config, args.pickle[0]) # serialize the list
args.pickle[0].close()

from epson_print_conf import EpsonPrinter
ep = EpsonPrinter(conf_dict=normalized_config, replace_conf=True)
logging.info("Number of expanded configuration entries: %s", len(ep.PRINTER_CONFIG))
quit()
Expand Down
Loading

0 comments on commit 6304a02

Please sign in to comment.