mirror of
https://github.com/Ircama/epson_print_conf.git
synced 2024-10-18 01:00:36 -04:00
Add --write-poweroff-timer option
This commit is contained in:
parent
cd7d4d0b66
commit
4e0f7ca3b7
2 changed files with 60 additions and 6 deletions
20
README.md
20
README.md
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
||||
|
@ -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
|
||||
|
||||
|
@ -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}}
|
||||
```
|
||||
|
||||
|
|
|
@ -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
|
||||
|
@ -1424,6 +1425,30 @@ class EpsonPrinter:
|
|||
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 = []
|
||||
|
@ -1735,6 +1760,14 @@ if __name__ == "__main__":
|
|||
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',
|
||||
|
@ -1896,6 +1929,19 @@ if __name__ == "__main__":
|
|||
"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(
|
||||
|
|
Loading…
Reference in a new issue