Skip to content

Commit

Permalink
Add --write-poweroff-timer option
Browse files Browse the repository at this point in the history
  • Loading branch information
Ircama committed Nov 10, 2023
1 parent cd7d4d0 commit 4e0f7ca
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 6 deletions.
20 changes: 14 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ Epson Printer Configuration tool via SNMP (TCP/IP)
- Read and write EEPROM addresses
- Dump a set of EEPROM addresses
- Reset ink waste
- Change power off timer
- Other admin stuffs and debug options
- Command line tool (no GUI)
- Python API interface
Expand Down Expand Up @@ -38,10 +39,11 @@ It is tested with Ubuntu / Windows Subsystem for Linux, Windows.
```
usage: epson_print_conf.py [-h] -m MODEL -a HOSTNAME [-p PORT] [-i] [-q QUERY_NAME]
[--reset_waste_ink] [-d]
[--write-first-ti-received-time YEAR MONTH DAY] [--dry-run]
[-R ADDRESS_SET] [-W ADDRESS_VALUE_SET] [-e FIRST_ADDRESS LAST_ADDRESS]
[--detect-key] [-S SEQUENCE_STRING] [-t TIMEOUT] [-r RETRIES]
[-c CONFIG_FILE] [--simdata SIMDATA_FILE]
[--write-first-ti-received-time YEAR MONTH DAY]
[--write-poweroff-timer MINUTES] [--dry-run] [-R ADDRESS_SET]
[-W ADDRESS_VALUE_SET] [-e FIRST_ADDRESS LAST_ADDRESS] [--detect-key]
[-S SEQUENCE_STRING] [-t TIMEOUT] [-r RETRIES] [-c CONFIG_FILE]
[--simdata SIMDATA_FILE]
optional arguments:
-h, --help show this help message and exit
Expand All @@ -57,6 +59,8 @@ optional arguments:
-d, --debug Print debug information
--write-first-ti-received-time YEAR MONTH DAY
Change the first TI received time
--write-poweroff-timer MINUTES
Write poweroff tiler
--dry-run Dry-run change operations
-R ADDRESS_SET, --read-eeprom ADDRESS_SET
Read the values of a list of printer EEPROM addreses. Format is: address
Expand Down Expand Up @@ -84,7 +88,7 @@ Epson Printer Configuration via SNMP (TCP/IP)

Examples:

```
```bash
# Print the status information (-i is not needed):
python3 epson_print_conf.py -m XP-205 -a 192.168.1.87 -i

Expand All @@ -94,6 +98,9 @@ python3 epson_print_conf.py -m XP-205 -a 192.168.1.87 --reset_waste_ink
# Change the first TI received time to 31 December 2016:
python3 epson_print_conf.py -m XP-205 -a 192.168.1.87 --write-first-ti-received-time 2016 12 31

# Change the power off timer to 15 minutes:
python3 epson_print_conf.py -a 192.168.1.87 -m XP-205 --write-poweroff-timer 15

# Detect the read_key via brute force:
python3 epson_print_conf.py -m XP-205 -a 192.168.1.87 --detect-key

Expand Down Expand Up @@ -353,7 +360,8 @@ Example of advanced printer status with an XP-205 printer:
'Timer cleaning counter': 4,
'Total print page counter': 11569,
'Total print pass counter': 514602,
'Total scan counter': 4973},
'Total scan counter': 4973,
'poweroff_timer': 30},
'waste_ink_levels': {'borderless_waste': 4.72, 'main_waste': 90.8}}
```

Expand Down
46 changes: 46 additions & 0 deletions epson_print_conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ class EpsonPrinter:
"First TI received time": [173, 172],
"Maintenance required level of 1st waste ink counter": [46],
"Maintenance required level of 2nd waste ink counter": [47],
"poweroff_timer": [359, 358],
},
"raw_waste_reset": {
24: 0, 25: 0, 30: 0, # Data of 1st counter
Expand Down Expand Up @@ -1424,6 +1425,30 @@ def write_first_ti_received_time(
return False
return True

def write_poweroff_timer(self, mins: int) -> bool:
"""Update power-off timer"""
if not self.parm:
logging.error("EpsonPrinter - invalid API usage")
return None
try:
msb = self.parm["stats"]["poweroff_timer"][0]
lsb = self.parm["stats"]["poweroff_timer"][1]
except KeyError:
logging.info("write_poweroff_timer: missing parameter")
return False
logging.debug(
"poweroff: %s %s = %s %s",
hex(mins // 256), hex(mins % 256), mins // 256, mins % 256)
if not self.write_eeprom(
msb, mins // 256, label="Write power off timer"
):
return False
if not self.write_eeprom(
lsb, mins % 256, label="Write power off timer"
):
return False
return True

def list_known_keys(self):
""" List all known read and write keys for all defined printers. """
known_keys = []
Expand Down Expand Up @@ -1735,6 +1760,14 @@ def write_simdata(self, file):
nargs=3,
metavar=('YEAR', 'MONTH', 'DAY'),
)
parser.add_argument(
'--write-poweroff-timer',
dest='poweroff',
type=int,
help='Write poweroff tiler',
nargs=1,
metavar=('MINUTES'),
)
parser.add_argument(
'--dry-run',
dest='dry_run',
Expand Down Expand Up @@ -1896,6 +1929,19 @@ def write_simdata(self, file):
"Failed to write first TI received time."
" Check configuration."
)
if args.poweroff:
print_opt = True
if printer.write_poweroff_timer(args.poweroff[0]):
print(
"Write power off timer done ("
+ str(args.poweroff[0])
+ " minutes)."
)
else:
print(
"Failed to write power off timer."
" Check configuration."
)
if args.dump_eeprom:
print_opt = True
for addr, val in printer.dump_eeprom(
Expand Down

0 comments on commit 4e0f7ca

Please sign in to comment.