Code additions for version 4.0

- Detect the printer configuration
- Change the printer WiFi MAC address and the printer serial number
- Special features allow showing the internal configuration settings
This commit is contained in:
Ircama
2024-10-20 13:10:42 +02:00
parent c863a4c3f0
commit f09eff6b98
3 changed files with 894 additions and 71 deletions

View File

@@ -36,11 +36,13 @@ A range of features are offered for both end-users and developers, making it eas
The GUI can automatically find and display printer IP addresses and model names, allowing users to:
- Check printer status
- Set the power-off timer
- Reset the ink waste counter
- Configure the _First TI Received Time_
- Open the printer web interface
- Detect the printer configuration
- 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 (only the *read_key* at the moment)
- Detect the access key (*read_key* and *write_key*)
- 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.

View File

@@ -75,6 +75,7 @@ class EpsonPrinter:
"printer_head_id_f": [136, 137, 138, 129],
"main_waste": {"oids": [24, 25, 30], "divider": 73.5},
"borderless_waste": {"oids": [26, 27, 34], "divider": 34.34},
"wifi_mac_address": range(130, 136),
"same-as": "XP-315"
},
"ET-4700": {
@@ -954,7 +955,15 @@ class EpsonPrinter:
@property
def list_methods(self):
"""Return list of available information methods about a printer."""
"""
Return the list of methods that can be invoked to get the printer
information data.
Used by stats() and other modes to return all available information
about a printer.
A conforming method shall start with "get_".
Do not use "get_" for new methods if you do not want them to be part
of list_methods.
"""
return(filter(lambda x: x.startswith("get_"), dir(self)))
def expand_printer_conf(self, conf):
@@ -1655,6 +1664,7 @@ class EpsonPrinter:
data_set["unknown"].append((hex(ftype), item))
return data_set
# Start of "get_" methods
def get_snmp_info(
self,
mib_name: str = None,
@@ -1687,8 +1697,8 @@ class EpsonPrinter:
:
result.find(b';')
].decode()
), byteorder="little") / 60
sys_info[name] = f"{power_off_h} hours"
), byteorder="little")
sys_info[name] = f"{power_off_h} minutes"
except Exception:
sys_info[name] = "(unknown)"
elif name == "hex_data" and result is not False:
@@ -1720,6 +1730,22 @@ class EpsonPrinter:
self.parm["serial_number"], label="serial_number")
)
def get_wifi_mac_address(self) -> str:
"""Return the WiFi MAC address of the printer."""
if not self.parm:
logging.error("EpsonPrinter - invalid API usage")
return None
if "wifi_mac_address" not in self.parm:
return None
try:
return '-'.join(
octet.upper() for octet in self.read_eeprom_many(
self.parm["wifi_mac_address"], label="get_wifi_mac_address"
)
)
except Exception:
return False
def get_stats(self, stat_name: str = None) -> str:
"""Return printer statistics."""
if not self.parm:
@@ -1904,18 +1930,6 @@ class EpsonPrinter:
label="last_printer_fatal_errors"
)
def ink_color(self, number):
"""
Return a list including the cartridge input number and the related
name of the ink color (or "unknown color" if not included
in self.CARTRIDGE_TYPE).
"""
return [
number,
self.CARTRIDGE_TYPE[
number] if number in self.CARTRIDGE_TYPE else "unknown color",
]
def get_cartridge_information(self) -> str:
"""Return list of cartridge properties."""
response = []
@@ -1944,6 +1958,19 @@ class EpsonPrinter:
if not response:
return None
return self.cartridge_parser(response)
# End of "get_" methods
def ink_color(self, number):
"""
Return a list including the cartridge input number and the related
name of the ink color (or "unknown color" if not included
in self.CARTRIDGE_TYPE).
"""
return [
number,
self.CARTRIDGE_TYPE[
number] if number in self.CARTRIDGE_TYPE else "unknown color",
]
def cartridge_parser(self, cartridges: List[bytes]) -> str:
"""Parse the cartridge properties and decode as much as possible."""
@@ -2024,6 +2051,36 @@ class EpsonPrinter:
)
return d
def update_parameter(
self,
parameter: str,
value_list: list,
dry_run=False
) -> bool:
"""
Update printer parameter by writing value data to EEPROM
(tested with "serial_number" and "wifi_mac_address").
"""
if not self.parm:
logging.error("EpsonPrinter - invalid API usage")
return None
if (
not parameter
or parameter not in self.parm
or not self.parm[parameter]
or not value_list
or not len(value_list)
or len(self.parm[parameter]) != len(value_list)
):
return None
if dry_run:
return True
for oid, value in zip(self.parm[parameter], value_list):
if not self.write_eeprom(oid, value, label="update_" + parameter):
return False
return True
return False
def reset_waste_ink_levels(self, dry_run=False) -> bool:
"""
Set waste ink levels to 0.

864
ui.py

File diff suppressed because it is too large Load Diff