Skip to content

Commit

Permalink
Added ET-2700 Espon printer model
Browse files Browse the repository at this point in the history
  • Loading branch information
Ircama committed Oct 14, 2023
1 parent b0aa62f commit adb7dc5
Show file tree
Hide file tree
Showing 2 changed files with 111 additions and 11 deletions.
77 changes: 77 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,83 @@ python3 epson_print_conf.py -m XP-205 -a 192.168.1.87 -R 173,172

Note: resetting the ink waste counter is just removing a warning; not replacing the tank will make the ink spill.

## Utilities and notes

```
import epson_print_conf
import pprint
printer = epson_print_conf.EpsonPrinter()
# Decode write_key:
printer.reverse_caesar(bytes.fromhex("48 62 7B 62 6F 6A 62 2B")) # last 8 bytes
# Decode status:
pprint.pprint(printer.status_parser(bytes.fromhex("40 42 44 43 20 53 54 32 0D 0A ....")))
# Decode the level of ink waste
byte_sequence = "A4 2A"
divider = 62.06 # divider = ink_level / waste_percent
ink_level = int("".join(reversed(byte_sequence.split())), 16)
waste_percent = round(ink_level / divider, 2)
# Print the read key sequence in byte and hex formats:
printer = epson_print_conf.EpsonPrinter(model="ET-2700")
'.'.join(str(x) for x in printer.parm['read_key'])
" ".join('{0:02x}'.format(x) for x in printer.parm['read_key'])
# Print the write key sequence in byte and hex formats:
printer = epson_print_conf.EpsonPrinter(model="ET-2700")
printer.caesar(printer.parm['write_key'])
printer.caesar(printer.parm['write_key'], hex=True).upper()
# Print hex sequence of reading the value of EEPROM address 30 00:
" ".join('{0:02x}'.format(int(x)) for x in printer.eeprom_oid_read_address(oid=0x30).split(".")[15:]).upper()
# Print hex sequence of storing value 00 to EEPROM address 30 00:
" ".join('{0:02x}'.format(int(x)) for x in printer.eeprom_oid_write_address(oid=0x30, value=0x0).split(".")[15:]).upper()
# Print EEPROM write hex sequence of the raw ink waste reset:
for key, value in printer.parm["raw_waste_reset"].items():
" ".join('{0:02x}'.format(int(x)) for x in printer.eeprom_oid_write_address(oid=key, value=value).split(".")[15:]).upper()
```

### Byte sequences

Header:

```
1.3.6.1.4.1. [SNMP_OID_ENTERPRISE]
1248. [SNMP_EPSON]
1.2.2.44.1.1.2. [OID_PRV_CTRL]
1.
```

Full header sequence: `1.3.6.1.4.1.1248.1.2.2.44.1.1.2.1.`

Read EEPROM (EPSON-CTRL), after the header:

```
124.124.7.0. [7C 7C 07 00]
<READ KEY (two bytes)>
65.190.160. [41 BE A0]
<LSB EEPROM ADDRESS (one byte)>.<MSB EEPROM ADDRESS (one byte)>
```

Example: `1.3.6.1.4.1.1248.1.2.2.44.1.1.2.1.124.124.7.0.73.8.65.190.160.48.0`

Write EEPROM, after the header:

```
7C 7C 10 00 [124.124.16.0.]
<READ KEY (two bytes)>
42 BD 21 [66.189.33.]
<LSB EEPROM ADDRESS (one byte)>.<MSB EEPROM ADDRESS (one byte)>
<VALUE (one byte)>
<WRITE KEY (eight bytes)>
```

Example: `7C 7C 10 00 49 08 42 BD 21 30 00 1A 42 73 62 6F 75 6A 67 70`

## API Interface

### Specification
Expand Down
45 changes: 34 additions & 11 deletions epson_print_conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ class EpsonPrinter:
},
"XP-3150": {
"read_key": [80, 9],
"serial_number": range(0x644, 0x64e),
"serial_number": range(1604, 1614),
"printer_head_id_h": [171, 189, 190, 175],
"printer_head_id_f": [191, 188],
"stats": {
Expand Down Expand Up @@ -295,6 +295,26 @@ class EpsonPrinter:
}
# uncompleted
},
"ET-2700": { # Epson EcoTank ET-2700 Series
"read_key": [73, 8],
"write_key": b'Arantifo',
"serial_number": range(1604, 1614),
"main_waste": {"oids": [48, 49], "divider": 109.125},
"second_waste": {"oids": [50, 51], "divider": 16.31},
"stats": {
"Maintenance required level of 1st waste ink counter": [54],
"Maintenance required level of 2nd waste ink counter": [55],
},
"raw_waste_reset": {
48: 0, 49: 0, 47: 0, # Data of 1st counter
52: 0, 53: 0, # another store of 1st counter
54: 94, # Maintenance required level of 1st counter
50: 0, 51: 0, # Data of 2nd counter
55: 94, # Maintenance required level of 2st counter
28: 0 # ?
}
# uncompleted
},
}

CARTRIDGE_TYPE = { # map cartridge number with color
Expand Down Expand Up @@ -429,10 +449,13 @@ def stats(self):
logging.info(f"No value for method '{method}'.")
return stat_set

def caesar(self, key):
def caesar(self, key, hex=False):
"""Convert the string write key to a sequence of numbers"""
if hex:
return " ".join('{0:02x}'.format(b + 1) for b in key)
return ".".join(str(b + 1) for b in key)


def reverse_caesar(self, eight_bytes):
"""
Convert a bytes type sequence key (8 bytes length) to string.
Expand Down Expand Up @@ -466,8 +489,8 @@ def eeprom_oid_read_address(
return None
return (
f"{self.eeprom_link}"
".124.124" # || (0x7C 0x7C)
".7.0" # read
".124.124" # || (7C 7C)
".7.0" # read (07 00)
f".{self.parm['read_key'][0]}"
f".{self.parm['read_key'][1]}"
".65.190.160"
Expand Down Expand Up @@ -500,11 +523,11 @@ def eeprom_oid_write_address(
return None
write_op = (
f"{self.eeprom_link}"
".124.124" # || (0x7C 0x7C)
".16.0" # write
".124.124" # || 7C 7C
".16.0" # write (10 00)
f".{self.parm['read_key'][0]}"
f".{self.parm['read_key'][1]}"
".66.189.33"
".66.189.33" # 42 BD 21
f".{oid}.{msb}.{value}"
f".{self.caesar(self.parm['write_key'])}"
)
Expand Down Expand Up @@ -1113,7 +1136,7 @@ def get_printer_head_id(self) -> str: # only partially correct

def get_firmware_version(self) -> str:
"""Return firmware version."""
oid = f"{self.eeprom_link}.118.105.1.0.0"
oid = f"{self.eeprom_link}.118.105.1.0.0" # 76 69 01 00 00
label = "get_firmware_version"
logging.debug(
f"SNMP_DUMP {label}:\n"
Expand All @@ -1138,7 +1161,7 @@ def get_firmware_version(self) -> str:

def get_cartridges(self) -> str:
"""Return list of cartridge types."""
oid = f"{self.eeprom_link}.105.97.1.0.0"
oid = f"{self.eeprom_link}.105.97.1.0.0" # 69 61 01 00 00
label = "get_cartridges"
logging.debug(
f"SNMP_DUMP {label}:\n"
Expand Down Expand Up @@ -1185,7 +1208,7 @@ def get_ink_replacement_counters(self) -> str:

def get_printer_status(self):
"""Return printer status and ink levels."""
address = f"{self.eeprom_link}.115.116.1.0.1"
address = f"{self.eeprom_link}.115.116.1.0.1" # 73 74 01 00 01
logging.debug(f"PRINTER_STATUS:\n ADDRESS: {address}")
tag, result = self.snmp_mib(address, label="get_printer_status")
if not result:
Expand Down Expand Up @@ -1253,7 +1276,7 @@ def get_cartridge_information(self) -> str:
"""Return list of cartridge properties."""
response = []
for i in range(1, 9):
mib = f"{self.eeprom_link}.105.105.2.0.1." + str(i)
mib = f"{self.eeprom_link}.105.105.2.0.1." + str(i) # 69 69 02 00 01
logging.debug(
f"Cartridge {i}:\n"
f" ADDRESS: {mib}"
Expand Down

0 comments on commit adb7dc5

Please sign in to comment.