-
Notifications
You must be signed in to change notification settings - Fork 19
/
Copy pathepson_print_conf.py
2940 lines (2831 loc) · 117 KB
/
epson_print_conf.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Epson Printer Configuration via SNMP (TCP/IP)
"""
import itertools
import re
from typing import Any, List
import datetime
import time
import textwrap
import ast
import logging
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
# in python>=3.11
try:
import importlib.util
import importlib.machinery
except ImportError:
pass
from pysnmp.hlapi.v1arch import * # this imports UdpTransportTarget
from pyasn1.type.univ import OctetString as OctetStringType
from itertools import chain
class EpsonPrinter:
"""SNMP Epson Printer Configuration."""
PRINTER_CONFIG = { # Known Epson models
"L386": {
"read_key": [16, 8],
"write_key": b"Sinabung",
"printer_head_id_h": range(122, 126),
"printer_head_id_f": [129],
"main_waste": {"oids": [24, 25, 30], "divider": 62.07},
"borderless_waste": {"oids": [26, 27, 34], "divider": 24.2},
"raw_waste_reset": {
24: 0, 25: 0, 30: 0, # Data of 1st counter
28: 0, 29: 0, # another store of 1st counter
46: 94, # Maintenance required level of 1st counter
26: 0, 27: 0, 34: 0, # Data of 2nd counter
47: 94, # Maintenance required level of 2nd counter
49: 0 # ?
},
"stats": {
"Manual cleaning counter": [147],
"Timer cleaning counter": [149],
"Power cleaning counter": [148],
"Total print pass counter": [171, 170, 169, 168],
"Total print page counter": [167, 166, 165, 164],
"Total scan counter": [471, 470, 469, 468],
"First TI received time": [173, 172],
"Maintenance required level of 1st waste ink counter": [46],
"Maintenance required level of 2nd waste ink counter": [47],
"Power off timer": [359, 358],
},
"serial_number": range(192, 202),
"last_printer_fatal_errors": [
453, 452, 455, 454, 457, 456, 459, 458, 461, 460, 467,
499, 498, 501, 500, 503, 502, 505, 504, 507, 506
],
},
"XP-205": {
"alias": ["XP-200", "XP-207"],
"read_key": [25, 7],
"printer_head_id_h": range(122, 127),
"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),
"brand_name": range(868, 932),
"model_name": range(934, 998),
"same-as": "XP-315"
},
"ET-4700": {
"read_key": [151, 7],
"write_key": b"Maribaya",
"main_waste": {"oids": [48, 49, 47], "divider": 63.46},
"borderless_waste": {"oids": [50, 51, 47], "divider": 34.16},
"raw_waste_reset": {
48: 0, 49: 0, 47: 0, 52: 0, 53: 0, 54: 94, 50: 0, 51: 0,
55: 94, 28: 0
},
"stats": {
"First TI received time": [9, 8],
"Total print pass counter": [133, 132, 131, 130],
"Total print page counter": [776, 775, 774, 773],
"Total scan counter": [1843, 1842, 1841, 1840],
"Total scan counter % (ADF)": [1855, 1854, 1853, 1852],
"Ink replacement counter - Black": [554],
"Ink replacement counter - Cyan": [555],
"Ink replacement counter - Magenta": [556],
"Ink replacement counter - Yellow": [557],
"Maintenance required level of 1st waste ink counter": [54],
"Maintenance required level of 2nd waste ink counter": [55],
},
"serial_number": range(1604, 1614),
},
"Stylus Photo PX720WD": {
"read_key": [54, 6],
"write_key": b"IhroroQU",
"main_waste": {"divider": 79.23, "oids": [14, 15]},
"borderless_waste": {"divider": 122.84, "oids": [16, 17]},
"raw_waste_reset": {
8: 0, 9: 0, 12: 0, 13: 0, 14: 0, 15: 0, 16: 0, 17: 0,
18: 0, 19: 0
},
"stats": {
"Manual cleaning counter": [126],
"Timer cleaning counter": [97],
"Total print pass counter": [47, 46, 45, 44],
"Total print page counter": [159, 158],
"Total print page counter - duplex": [161, 160],
"Total print CD-R counter": [75, 74],
"Total CD-R tray open/close counter": [163, 162],
"Total scan counter": [477, 476, 475, 474],
},
"ink_replacement_counters": {
"Black": {"1S": 102, "2S": 103, "3S": 98},
"Yellow": {"1S": 112, "2S": 113, "4S": 171},
"Magenta": {"1S": 104, "2S": 105, "4S": 99},
"Cyan": {"1S": 108, "2S": 109, "4S": 101},
"Light Magenta": {"1S": 106, "2S": 107, "3S": 100},
"Light Cyan": {"1S": 110, "2S": 111, "3S": 155},
},
"serial_number": range(231, 241),
"alias": ["TX720WD", "Artisan 720", "PX720WD"],
},
"Stylus Photo PX730WD": {
"alias": ["TX730WD", "PX730WD", "Stylus Photo PX730", "Artisan 730"],
"read_key": [119, 8], # "read_key": [0x8, 0x77], (I'm afraid 0x8, 0x77 is wrong)
"write_key": b'Cattleya',
"main_waste": {"oids": [0xe, 0xf, 60], "divider": 81.82},
"borderless_waste": {"oids": [0x10, 0x11, 60], "divider": 122.88},
"raw_waste_reset": {
8: 0, 9: 0, 12: 0, 13: 0, 14: 0, 15: 0, 16: 0, 17: 0,
18: 0, 19: 0, 60: 0, 61: 94, 62: 94
},
"stats": {
"Manual cleaning counter": [0x7e],
"Timer cleaning counter": [0x61],
"Total print pass counter": [0x2C, 0x2D, 0x2E, 0x2F],
"Total print page counter": [0x9E, 0x9F],
"Total print page counter (duplex)": [0xA0, 0xA1],
"Total print CD-R counter": [0x4A, 0x4B],
"Total print CD-R tray open/close counter": [0xA2, 0xA3],
"Total scan counter": [0x01DA, 0x01DB, 0x01DC, 0x01DD],
"Maintenance required level of 1st waste ink counter": [61],
"Maintenance required level of 2nd waste ink counter": [62],
},
"last_printer_fatal_errors": [0x3B, 0xC0, 0xC1, 0xC2, 0xC3, 0x5C],
"ink_replacement_counters": {
"Black": {"1S": 0x66, "2S": 0x67, "3S": 0x62},
"Yellow": {"1S": 0x70, "2S": 0x71, "4S": 0xAB},
"Magenta": {"1S": 0x68, "2S": 0x69, "4S": 0x63},
"Cyan": {"1S": 0x6C, "2S": 0x6D, "4S": 0x65},
"Light magenta": {"1S": 0x6A, "2S": 0x6B, "3S": 0x64},
"Light cyan": {"1S": 0x6E, "2S": 0x6F, "3S": 0x9B},
},
"serial_number": range(0xE7, 0xF1),
},
"WF-7525": {
"read_key": [101, 0],
"write_key": b'Sasanqua',
"alias": ["WF-7515"],
"main_waste": {"oids": [20, 21, 59], "divider": 196.5},
"borderless_waste": {"oids": [22, 23, 59], "divider": 52.05},
"serial_number": range(192, 202),
"stats": {
"Maintenance required level of 1st waste ink counter": [60],
"Maintenance required level of 2nd waste ink counter": [61],
"Manual cleaning counter": [131],
"Timer cleaning counter": [134],
"Ink replacement cleaning counter": [133],
"Total print pass counter": [159, 158, 157, 156],
"Total print page counter": [147, 146, 145, 144],
"Total scan counter": [471, 470, 469, 468],
"Total scan counter % (ADF)": [475, 474, 473, 472],
},
"ink_replacement_counters": {
"Black": {"1L": 242, "1S": 243, "2S": 244},
"Yellow": {"1S": 248, "2S": 249, "3S": 250},
"Magenta": {"1S": 251, "2S": 252, "3S": 253},
"Cyan": {"1S": 245, "2S": 246, "3S": 247},
},
"raw_waste_reset": {
20: 0, 21: 0, 22: 0, 23: 0, 24: 0, 25: 0, 59: 0, 60: 94, 61: 94
}
},
"L355": {
"read_key": [65, 9],
"write_key": b"Wakatobi",
"main_waste": {"oids": [24, 25, 30], "divider": 65.0},
"raw_waste_reset": {24: 0, 25: 0, 30: 0, 28: 0, 29: 0, 46: 94},
"stats": {
"Manual cleaning counter": [147],
"Timer cleaning counter": [149],
"Total print pass counter": [171, 170, 169, 168],
"Total print page counter - Color": [439, 438, 437, 436],
"Total print page counter - Black": [435, 434, 433, 432],
"Total print page counter - Blank": [443, 442, 441, 440],
"Total print page counter": [167, 166, 165, 164],
"Total scan counter": [471, 470, 469, 468],
"First TI received time": [173, 172],
"Ink replacement counter - Black": [242],
"Ink replacement counter - Yellow": [244],
"Ink replacement counter - Magenta": [245],
"Ink replacement counter - Cyan": [243],
},
"serial_number": range(192, 202),
},
"L366": {
"read_key": [130, 2],
"write_key": b'Gerbera*',
"main_waste": {"oids": [24, 25, 30], "divider": 62.0625},
"borderless_waste": {"oids": [26, 27, 34], "divider": 24.20},
"stats": {
"Maintenance required level of 1st waste ink counter": [46],
"Maintenance required level of 2nd waste ink counter": [47],
"Ink replacement counter - Black": [242],
"Ink replacement counter - Yellow": [243],
"Ink replacement counter - Cyan": [244],
"Ink replacement counter - Magenta": [245],
},
"raw_waste_reset": {
24: 0, 25: 0, 30: 0, 26: 0, 27: 0, 34: 0, 28: 0, 29: 0,
49: 0, 46: 94, 47: 94
},
"serial_number": range(192, 202),
},
"L3060": {
"read_key": [149, 3],
"write_key": b"Maninjau",
"main_waste": {"oids": [24, 25, 30], "divider": 62.07},
"borderless_waste": {"oids": [26, 27, 34], "divider": 24.2},
"raw_waste_reset": {
24: 0, 25: 0, 30: 0, 28: 0, 29: 0,
46: 94, 26: 0, 27: 0, 34: 0, 47: 94
},
"stats": {
"Maintenance required level of 1st waste ink counter": [46],
"Maintenance required level of 2nd waste ink counter": [47],
"Manual cleaning counter": [147],
"Timer cleaning counter": [149],
"Power cleaning counter": [148],
"Total print pass counter": [171, 170, 169, 168],
"Total print page counter - rear feed": [167, 166, 165, 164],
"Total scan counter": [471, 470, 469, 468],
"First TI received time": [173, 172],
"Ink replacement counter - Black": [242],
"Ink replacement counter - Yellow": [244],
"Ink replacement counter - Magenta": [245],
"Ink replacement counter - Cyan": [243],
},
"serial_number": range(192, 202),
},
"ET-2400": {
"alias": ["ET-2401", "ET-2403", "ET-2405"],
"read_key": [74, 54],
"write_key": b"Maribaya",
"main_waste": {"oids": [48, 49, 47], "divider": 63.46},
"borderless_waste": {"oids": [50, 51, 47], "divider": 34.16},
"third_waste": {"oids": [252, 253, 254], "divider": 13.0},
"raw_waste_reset": {
48: 0, 49: 0, 47: 0, 52: 0, 53: 0, 54: 94, 50: 0, 51: 0,
55: 94, 28: 0, 252: 0, 253: 0, 254: 0, 255: 94,
},
"stats": {
"Maintenance required level of 1st waste ink counter": [54],
"Maintenance required level of 2nd waste ink counter": [55],
"Maintenance required level of 3rd waste ink counter": [255],
"Manual cleaning counter": [90],
"Timer cleaning counter": [89],
"Power cleaning counter": [91],
"Total print pass counter": [133, 132, 131, 130],
"Total print page counter": [776, 775, 774, 773],
"Total scan counter": [1843, 1842, 1841, 1840],
},
"serial_number": range(1604, 1614),
},
"ET-2600": {
"alias": ["ET-2650", "L395"],
"read_key": [16, 8],
"write_key": b'Sinabung',
"main_waste": {"oids": [24, 25, 30], "divider": 62.06},
"raw_waste_reset": {24: 0, 25: 0, 30: 0, 28: 0, 29: 0, 46: 94},
"stats": {
"Manual cleaning counter": [147],
"Timer cleaning counter": [149],
"Power cleaning counter": [148],
"Total print pass counter": [171, 170, 169, 168],
"Total print page counter": [167, 166, 165, 164],
"Total scan counter": [471, 470, 469, 468],
"First TI received time": [173, 172],
},
"serial_number": range(192, 202),
},
"ET-2720": {
"alias": ["ET-2714", "ET-2721", "ET-2723", "ET-2725"],
"read_key": [151, 7],
"write_key": b'Maribaya',
"main_waste": {"oids": [48, 49, 47], "divider": 63.45},
"borderless_waste": {"oids": [50, 51, 47], "divider": 34.15},
"same-as": "ET-2700"
},
"ET-2750": {
"serial_number": range(1604, 1614),
"alias": ["ET-2751", "ET-2756"],
"read_key": [73, 8],
"write_key": b"Arantifo",
"main_waste": {"oids": [48, 49, 47], "divider": 109.13},
"borderless_waste": {"oids": [50, 51, 47], "divider": 16.31},
"raw_waste_reset": {
48: 0, 49: 0, 47: 0, 52: 0, 53: 0,
54: 94,
50: 0, 51: 0,
55: 94,
28: 0
},
"stats": {
"First TI received time": [9, 8],
"Total print pass counter": [133, 132, 131, 130],
"Total print page counter - rear feed": [755, 754, 753, 752],
"Total scan counter": [1843, 1842, 1841, 1840],
"Ink replacement counter - Black": [554],
"Ink replacement counter - Cyan": [555],
"Ink replacement counter - Magenta": [556],
"Ink replacement counter - Yellow": [557],
"Maintenance required level of 1st waste ink counter": [54],
"Maintenance required level of 2nd waste ink counter": [55],
},
},
"ET-2812": {
"read_key": [74, 54],
"write_key": b"Maribaya",
"main_waste": {"oids": [48, 49, 47], "divider": 63.46},
"borderless_waste": {"oids": [50, 51, 47], "divider": 34.16},
"third_waste": {"oids": [252, 253, 254], "divider": 13.0},
"raw_waste_reset": {
48: 0, 49: 0, 47: 0, 52: 0, 53: 0, 54: 94, 50: 0, 51: 0,
55: 94, 28: 0, 252: 0, 253: 0, 254: 0, 255: 94
},
"stats": {
"Maintenance required level of 1st waste ink counter": [54],
"Maintenance required level of 2nd waste ink counter": [55],
"Maintenance required level of 3rd waste ink counter": [255],
"Manual cleaning counter": [90],
"Timer cleaning counter": [89],
"Power cleaning counter": [91],
"Total print pass counter": [133, 132, 131, 130],
"Total print page counter": [776, 775, 774, 773],
"Total scan counter": [1843, 1842, 1841, 1840],
},
"serial_number": range(1604, 1614),
"alias": [
"ET-2814", "ET-2816", "ET-2818", "ET-2810", "ET-2811",
"ET-2813", "ET-2815"
],
},
"ET-4800": {
"read_key": [74, 54],
"write_key": b"Maribaya",
"main_waste": {"oids": [48, 49, 47], "divider": 63.46},
"borderless_waste": {"oids": [50, 51, 47], "divider": 34.16},
"third_waste": {"oids": [252, 253, 254], "divider": 13.0},
"raw_waste_reset": {
48: 0, 49: 0, 47: 0, 52: 0, 53: 0, 54: 94, 50: 0, 51: 0,
55: 94, 28: 0, 252: 0, 253: 0, 254: 0, 255: 94
},
"stats": {
"Manual cleaning counter": [90],
"Timer cleaning counter": [89],
"Power cleaning counter": [91],
"Total print pass counter": [133, 132, 131, 130],
"Total print page counter": [776, 775, 774, 773],
"Total scan counter": [1843, 1842, 1841, 1840],
"Total scan counter % (ADF)": [1855, 1854, 1853, 1852],
"Ink replacement counter %-- Black": [554],
"Ink replacement counter %-- Cyan": [555],
"Ink replacement counter %-- Magenta": [556],
"Ink replacement counter %-- Yellow": [557],
"Maintenance required level of 1st waste ink counter": [54],
"Maintenance required level of 2nd waste ink counter": [55],
"Maintenance required level of 3rd waste ink counter": [255],
},
"serial_number": [range(793, 803), range(1604, 1614)],
"wifi_mac_address": range(1920, 1926),
},
"L3150": {
"alias": ["L3151", "L3160", "L3166", "L3168"],
"read_key": [151, 7],
"write_key": b'Maribaya',
"main_waste": {"oids": [48, 49, 47], "divider": 63.46},
"borderless_waste": {"oids": [50, 51, 47], "divider": 34.16},
"same-as": "L4160"
},
"L405": {
"read_key": [149, 3],
"write_key": b"Maninjau",
"main_waste": {"oids": [24, 25, 30], "divider": 62.07},
"raw_waste_reset": {24: 0, 25: 0, 30: 0, 28: 0, 29: 0, 46: 94},
"stats": {
"Maintenance required level of waste ink counter": [46],
"Manual cleaning counter": [147],
"Timer cleaning counter": [149],
"Power cleaning counter": [148],
"Total print pass counter": [171, 170, 169, 168],
"Total print page counter": [167, 166, 165, 164],
"Total scan counter": [471, 470, 469, 468],
"First TI received time": [173, 172],
"Ink replacement counter - Black": [242],
"Ink replacement counter - Yellow": [244],
"Ink replacement counter - Magenta": [245],
"Ink replacement counter - Cyan": [243],
},
"serial_number": range(192, 202),
},
"R2000": {
"read_key": [1, 0],
"write_key": b"Yutamori",
"main_waste": {"divider": 215.0, "oids": [87, 88]},
"borderless_waste": {"divider": 70.3, "oids": [89, 90]},
"raw_waste_reset": {
83: 0, 84: 0, 85: 0, 86: 0, 87: 0, 88: 0, 89: 0, 90: 0,
58: 0, 59: 0
},
"stats": {
"Manual cleaning counter": [362],
"Timer cleaning counter": [364],
"Ink replacement cleaning counter": [363],
"Total print pass counter": [183, 182, 181, 180],
"Total print page counter": [179, 178, 177, 176],
"Total print CD-R counter": [185, 184],
"Total print page counter - fine paper": [211, 210, 209, 208],
"Total print page counter - board paper": [193, 192],
"Total print page counter - roll paper": [397, 396, 395, 394],
"Ink replacement counter - Yellow": [400],
"Ink replacement counter - Magenta": [401],
"Ink replacement counter - Matte Black": [402],
"Ink replacement counter - Red": [403],
"Ink replacement counter - Orange": [404],
"Ink replacement counter - Photo Black": [405],
"Ink replacement counter - Gloss Optimizer": [406],
"Ink replacement counter - Cyan": [407],
},
"serial_number": range(466, 476),
},
"L4160": {
"read_key": [73, 8],
"write_key": b'Arantifo',
"main_waste": {"oids": [48, 49, 47], "divider": 109.13},
"borderless_waste": {"oids": [50, 51, 47], "divider": 16.31},
"stats": {
"Maintenance required level of 1st waste ink counter": [54],
"Maintenance required level of 2nd waste ink counter": [55],
"First TI received time": [9, 8],
"Total print pass counter": [133, 132, 131, 130],
"Total print page counter": [776, 775, 774, 773],
"Total scan counter": [1843, 1842, 1841, 1840],
"Ink replacement counter - Black": [554],
"Ink replacement counter - Cyan": [555],
"Ink replacement counter - Magenta": [556],
"Ink replacement counter - Yellow": [557],
},
"serial_number": range(1604, 1614),
"raw_waste_reset": {
48: 0, 49: 0, 47: 0, 52: 0, 53: 0,
54: 94,
50: 0, 51: 0,
55: 94,
28: 0
},
},
"XP-315": {
"alias": ["XP-312", "XP-313"],
"read_key": [129, 8],
"write_key": b'Wakatobi',
"printer_head_id_h": range(122, 126),
"printer_head_id_f": [129],
"main_waste": {"oids": [24, 25, 30], "divider": 69},
"borderless_waste": {"oids": [26, 27, 34], "divider": 32.53},
"serial_number": range(192, 202),
"stats": {
"Manual cleaning counter": [147],
"Timer cleaning counter": [149],
"Ink replacement cleaning counter": [148],
"Total print pass counter": [171, 170, 169, 168],
"Total print page counter": [167, 166, 165, 164],
"Total scan counter": [0x01d7, 0x01d6, 0x01d5, 0x01d4],
"First TI received time": [173, 172],
"Maintenance required level of 1st waste ink counter": [46],
"Maintenance required level of 2nd waste ink counter": [47],
"Power off timer": [359, 358],
},
"raw_waste_reset": {
24: 0, 25: 0, 30: 0, # Data of 1st counter
28: 0, 29: 0, # another store of 1st counter
46: 94, # Maintenance required level of 1st counter
26: 0, 27: 0, 34: 0, # Data of 2nd counter
47: 94, # Maintenance required level of 2st counter
49: 0 # ?
},
"ink_replacement_counters": {
"Black": {"1B": 242, "1S": 208, "1L": 209},
"Yellow": {"1B": 248, "1S": 246, "1L": 247},
"Magenta": {"1B": 251, "1S": 249, "1L": 250},
"Cyan": {"1B": 245, "1S": 243, "1L": 244},
},
"last_printer_fatal_errors": [60, 203, 204, 205, 206, 0x01d3],
},
"XP-422": {
"alias": ["XP-423", "XP-425", "XP-225"],
"read_key": [85, 5],
"write_key": b'Muscari.',
"main_waste": {"oids": [24, 25, 30], "divider": 196.5},
"borderless_waste": {"oids": [26, 27, 34], "divider": 52.05},
"stats": {
"Maintenance required level of 1st waste ink counter": [46],
"Maintenance required level of 2nd waste ink counter": [47],
},
"raw_waste_reset": {
24: 0, 25: 0, 26: 0, 27: 0, 28: 0,
29: 0, 30: 0, 34: 0, 46: 94, 47: 94, 49: 0
},
"serial_number": range(192, 202),
},
"XP-432": {
"read_key": [133, 5],
"write_key": b"Polyxena",
"main_waste": {"oids": [24, 25, 30], "divider": 39.9},
"borderless_waste": {"oids": [26, 27, 34], "divider": 32.55},
"raw_waste_reset": {
24: 0, 25: 0, 30: 0, 28: 0, 29: 0, 46: 94, 26: 0, 27: 0,
34: 0, 47: 94, 49: 0
},
"stats": {
"Maintenance required level of 1st waste ink counter": [46],
"Maintenance required level of 2nd waste ink counter": [47]
},
"alias": ["XP-235", "XP-433", "XP-435"],
},
"XP-540": {
"read_key": [20, 4],
"write_key": b"Firmiana",
"main_waste": {"oids": [16, 17, 6], "divider": 48.06},
"borderless_waste": {"oids": [18, 19, 6], "divider": 20.82},
"raw_waste_reset": {16: 0, 17: 0, 6: 0, 52: 94, 20: 0, 21: 0, 18: 0, 19: 0, 53: 94, 493: 0},
"stats": {
"Timer cleaning counter": [245],
"Total print pass counter": [99, 98, 97, 96],
"Total scan counter": [453, 452, 451, 450],
"Maintenance required level of 1st waste ink counter": [52],
"Maintenance required level of 2nd waste ink counter": [53],
},
"serial_number": range(216, 226),
},
"XP-610": {
"alias": ["XP-611", "XP-615", "XP-510", "XP-55"],
"read_key": [121, 4],
"write_key": b"Gossypiu",
"main_waste": {"oids": [16, 17, 6], "divider": 84.5},
"borderless_waste": {"oids": [18, 19, 6], "divider": 29.03},
"raw_waste_reset": {
16: 0, 17: 0, 6: 0, 52: 94, 20: 0, 21: 0, 18: 0, 19: 0,
53: 94, 493: 0
},
"stats": {
"Timer cleaning counter": [245],
"Total print pass counter": [99, 98, 97, 96],
"Total print CD-R counter": [255, 254],
"Maintenance required level of 1st waste ink counter": [52],
"Maintenance required level of 2nd waste ink counter": [53],
},
"serial_number": range(216, 226),
"alias": ["XP-611", "XP-615"],
},
"XP-620": {
"read_key": [87, 5],
"write_key": b"Althaea.",
"main_waste": {"oids": [16, 17, 6], "divider": 84.5},
"borderless_waste": {"oids": [18, 19, 6], "divider": 33.7},
"raw_waste_reset": {
16: 0, 17: 0, 6: 0, 52: 94, 20: 0, 21: 0, 18: 0, 19: 0,
53: 94, 493: 0
},
"stats": {
"Timer cleaning counter": [245],
"Total print pass counter": [99, 98, 97, 96],
"Total print CD-R counter": [255, 254],
"Maintenance required level of 1st waste ink counter": [52],
"Maintenance required level of 2nd waste ink counter": [53],
},
"serial_number": range(216, 226),
"alias": ["XP-621", "XP-625"],
},
"XP-700": {
"read_key": [40, 0],
"write_key": b"Hibiscus",
"main_waste": {"oids": [16, 17, 6], "divider": 84.5},
"borderless_waste": {"oids": [18, 19, 6], "divider": 29.03},
"raw_waste_reset": {16: 0, 17: 0, 6: 0, 52: 94, 20: 0, 21: 0, 18: 0, 19: 0, 53: 94, 493: 0},
"stats": {
"Timer cleaning counter": [245],
"Total print pass counter": [99, 98, 97, 96],
"Total print CD-R counter": [255, 254],
"Maintenance required level of 1st waste ink counter": [52],
"Maintenance required level of 2nd waste ink counter": [53],
},
"serial_number": range(216, 226),
"alias": ["XP-701", "XP-702"],
},
"XP-760": {
"read_key": [87, 5],
"write_key": b"Althaea.",
"main_waste": {"oids": [16, 17, 6], "divider": 84.5},
"borderless_waste": {"oids": [18, 19, 6], "divider": 33.7},
"raw_waste_reset": {16: 0, 17: 0, 6: 0, 52: 94, 20: 0, 21: 0, 18: 0, 19: 0, 53: 94, 493: 0},
"stats": {
"Timer cleaning counter": [245],
"Total print pass counter": [99, 98, 97, 96],
"Total print CD-R counter": [255, 254],
"Maintenance required level of 1st waste ink counter": [52],
"Maintenance required level of 2nd waste ink counter": [53],
},
"serial_number": range(216, 226),
},
"XP-830": {
"read_key": [40, 9],
"write_key": b"Irisgarm", # (Iris graminea with typo?)
"main_waste": {"oids": [16, 17, 6], "divider": 84.5},
"borderless_waste": {"oids": [18, 19, 6], "divider": 33.7},
"raw_waste_reset": {16: 0, 17: 0, 6: 0, 52: 94, 20: 0, 21: 0, 18: 0, 19: 0, 53: 94, 493: 0},
"stats": {
"Timer cleaning counter": [245],
"Total print pass counter": [99, 98, 97, 96],
"Total print CD-R counter": [255, 254],
"Total scan counter": [453, 452, 451, 450],
"Total scan counter % (ADF)": [457, 456, 455, 454],
"Maintenance required level of 1st waste ink counter": [52],
"Maintenance required level of 2nd waste ink counter": [53],
},
"serial_number": range(216, 226),
"idProduct": 0x110b,
},
"XP-960": {
"read_key": [40, 9],
"write_key": b"Irisgarm",
"main_waste": {"oids": [16, 17, 6], "divider": 93.85},
"borderless_waste": {"oids": [18, 19, 6], "divider": 29.77},
"raw_waste_reset": {
16: 0, 17: 0, 6: 0, 52: 94, 18: 0, 19: 0, 20: 0, 21: 0,
53: 94, 493: 0
},
"stats": {
"Timer cleaning counter": [245],
"Total print pass counter": [99, 98, 97, 96],
"Total print CD-R counter": [255, 254],
"Total scan counter": [453, 452, 451, 450],
"Maintenance required level of 1st waste ink counter": [52],
"Maintenance required level of 2nd waste ink counter": [53],
},
"serial_number": range(216, 226),
},
"XP-820": {
"read_key": [87, 5],
"write_key": b"Althaea.",
"borderless_waste": {"oids": [18, 19, 6], "divider": 33.7},
"alias": ["XP-821"],
"same-as": "XP-850"
},
"XP-850": {
"read_key": [40, 0],
"write_key": b"Hibiscus",
"main_waste": {"oids": [16, 17, 6], "divider": 84.5},
"borderless_waste": {"oids": [18, 19, 6], "divider": 29.03},
"raw_waste_reset": {
16: 0, 17: 0, 6: 0, 52: 94, 20: 0, 21: 0, 18: 0, 19: 0,
53: 94, 493: 0
},
"stats": {
"Timer cleaning counter": [245],
"Total print pass counter": [99, 98, 97, 96],
"Total print CD-R counter": [255, 254],
"Maintenance required level of 1st waste ink counter": [52],
"Maintenance required level of 2nd waste ink counter": [53],
},
"serial_number": range(216, 226),
},
"XP-7100": {
"read_key": [40, 5],
"write_key": b"Leucojum",
"main_waste": {"oids": [16, 17, 6], "divider": 84.5},
"borderless_waste": {"oids": [18, 19, 6], "divider": 33.7},
"raw_waste_reset": {
16: 0, 17: 0, 6: 0, 52: 94, 20: 0, 21: 0, 18: 0,
19: 0, 53: 94, 493: 0
},
"stats": {
"First TI received time": [9, 8],
"Total print pass counter": [99, 98, 97, 96],
"Total print page counter - front feed lower": [696, 695, 694, 693],
"Total print page counter - front feed upper": [744, 743, 742, 741],
"Total print page counter - rear": [748, 747, 746, 745],
"Total print page counter - duplex": [752, 751, 750, 749],
"Total print CD-R counter": [255, 254],
"Total scan counter": [453, 452, 451, 450],
"Total scan counter (ADF)": [457, 456, 455, 454],
"Ink replacement counter - Black": [701],
"Ink replacement counter % PB": [705],
"Ink replacement counter - Cyan": [702],
"Ink replacement counter - Magenta": [703],
"Ink replacement counter - Yellow": [704],
"Maintenance required level of 1st waste ink counter": [52],
"Maintenance required level of 2nd waste ink counter": [53],
},
"serial_number": range(216, 226),
},
"XP-2150": {
"read_key": [80, 9],
"write_key": b"Bidadari",
"main_waste": {"oids": [337, 338, 336], "divider": 69.0},
"borderless_waste": {"oids": [339, 340, 336], "divider": 30.49},
"raw_waste_reset": {
336: 0, 337: 0, 338: 0, 339: 0, 340: 0, 341: 0, 343: 94,
342: 0, 344: 94, 28: 0
},
"stats": {
"First TI received time": [9, 8],
"Manual cleaning counter": [203],
"Timer cleaning counter": [205],
"Total print pass counter": [133, 132, 131, 130],
"Total scan counter": [1843, 1842, 1841, 1840],
"Total print page counter": [792, 791, 790, 789],
"Ink replacement counter - Black": [554],
"Ink replacement counter - Cyan": [555],
"Ink replacement counter - Magenta": [556],
"Ink replacement counter - Yellow": [557],
"Maintenance required level of 1st waste ink counter": [343],
"Maintenance required level of 2nd waste ink counter": [344],
},
"serial_number": range(1604, 1614),
"alias": ["XP-2100", "XP-2151", "XP-2155"],
},
"ET-2500": {
"read_key": [68, 1],
"write_key": b"Gerbera*",
"main_waste": {"oids": [24, 25, 30], "divider": 62.07},
"raw_waste_reset": {24: 0, 25: 0, 30: 0, 28: 0, 29: 0, 46: 94},
"stats": {"Maintenance required level of 1st waste ink counter": [46]},
"serial_number": range(192, 202),
},
"XP-3150": {
"alias": ["XP-3151", "XP-3155"],
"read_key": [80, 9],
"write_key": b'Bidadari',
"serial_number": range(1604, 1614),
"printer_head_id_h": [171, 189, 190, 175],
"printer_head_id_f": [191, 188],
"stats": {
"MAC Address": range(0x780, 0x786),
"First TI received time": [9, 8],
"Total print pass counter": [133, 132, 131, 130],
"Total print page counter": [0x2fb, 0x2fa, 0x2f9, 0x2f8],
"Total scan counter": [0x0733, 0x0732, 0x0731, 0x0730],
"Paper count color": [0x314, 0x313, 0x312, 0x311],
"Paper count monochrome": [0x318, 0x317, 0x316, 0x315],
"Ink replacement counter - Black": [0x22a],
"Ink replacement counter - Cyan": [0x22b],
"Ink replacement counter - Magenta": [0x22c],
"Ink replacement counter - Yellow": [0x22d],
"Maintenance_box_replacement_counter": [0x22e],
},
"last_printer_fatal_errors": chain(
range(0x120, 0x12a), range(0x727, 0x72c), range(0x7f4, 0x7fe)
),
},
"ET-2550": { # Epson EcoTank ET-2550
"read_key": [0x44, 0x01],
"write_key": b'Gazania*',
"main_waste": {"oids": [24, 25, 30], "divider": 62.06},
"serial_number": range(192, 202),
"stats": {
"Maintenance required level of waste ink counter": [46]
},
"raw_waste_reset": {
24: 0, 25: 0, 30: 0, # Data of the waste ink counter
28: 0, 29: 0, # another store of the waste ink counter
46: 94, # Maintenance required level of the waste ink counter
}
},
"ET-2700": { # Epson EcoTank ET-2700 Series
"alias": ["ET-2701", "ET-2703", "ET-2705"],
"read_key": [73, 8],
"write_key": b'Arantifo',
"serial_number": range(1604, 1614),
"main_waste": {"oids": [48, 49, 47], "divider": 109.13},
"borderless_waste": {"oids": [50, 51, 47], "divider": 16.31},
"stats": {
"Maintenance required level of 1st waste ink counter": [54],
"Maintenance required level of 2nd waste ink counter": [55],
"First TI received time": [9, 8],
"Total print pass counter": [133, 132, 131, 130],
"Total print page counter - rear feed": [755, 754, 753, 752],
"Total scan counter": [1843, 1842, 1841, 1840],
"Ink replacement counter - Black": [554],
"Ink replacement counter - Cyan": [555],
"Ink replacement counter - Magenta": [556],
"Ink replacement counter - Yellow": [557],
},
"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 # ?
}
},
}
CARTRIDGE_TYPE = { # map cartridge number with color
1811: 'Black', 1812: 'Cyan', 1813: 'Magenta', 1814: 'Yellow', # T18xx / 18XL
711: 'Black', 712: 'Cyan', 713: 'Magenta', 714: 'Yellow', # T7xx
10332: 'Black', 10360: 'Cyan', 10361: 'Magenta', 10362: 'Yellow', # 603XL
}
MIB_MGMT = "1.3.6.1.2"
PRINT_MIB = MIB_MGMT + ".1.43"
MIB_OID_ENTERPRISE = "1.3.6.1.4.1"
MIB_EPSON = MIB_OID_ENTERPRISE + ".1248"
OID_PRV_CTRL = "1.2.2.44.1.1.2"
EEPROM_LINK = f'{MIB_EPSON}.{OID_PRV_CTRL}.1'
MIB_INFO = {
"Model": f"{MIB_MGMT}.1.25.3.2.1.3.1",
"Epson Printer Name": f"{MIB_EPSON}.1.2.2.1.1.1.2.1",
"Model short": f"{MIB_EPSON}.1.1.3.1.3.8.0",
"Epson Personal Name": f"{MIB_EPSON}.1.2.2.1.1.1.3.1",
"EEPS2 firmware version": f"{MIB_MGMT}.1.2.2.1.2.1",
"Epson Version number": f"{MIB_EPSON}.1.2.2.2.1.1.2.1.4",
"Descr": f"{MIB_MGMT}.1.1.1.0",
"UpTime": f"{MIB_MGMT}.1.1.3.0",
"Name": f"{MIB_MGMT}.1.1.5.0",
"MAC Address": f"{MIB_MGMT}.1.2.2.1.6.1",
"Print input": f"{PRINT_MIB}.8.2.1.13.1.1",
"Lang 1": f"{PRINT_MIB}.15.1.1.3.1.1",
"Lang 2": f"{PRINT_MIB}.15.1.1.3.1.2",
"Lang 3": f"{PRINT_MIB}.15.1.1.3.1.3",
"Lang 4": f"{PRINT_MIB}.15.1.1.3.1.4",
"Lang 5": f"{PRINT_MIB}.15.1.1.3.1.5",
"Emulation 1": f"{PRINT_MIB}.15.1.1.5.1.1",
"Emulation 2": f"{PRINT_MIB}.15.1.1.5.1.2",
"Emulation 3": f"{PRINT_MIB}.15.1.1.5.1.3",
"Emulation 4": f"{PRINT_MIB}.15.1.1.5.1.4",
"Emulation 5": f"{PRINT_MIB}.15.1.1.5.1.5",
"Total printed pages": f"{PRINT_MIB}.10.2.1.4.1.1",
#"Total copies": f"{PRINT_MIB}.11.1.1.9.1.1",
#"Serial number": f"{PRINT_MIB}.5.1.1.17.1",
"IP Address": f"{MIB_EPSON}.1.1.3.1.4.19.1.3.1",
"IPP_URL_path": f"{MIB_EPSON}.1.1.3.1.4.19.1.4.1",
"IPP_URL": f"{MIB_EPSON}.1.1.3.1.4.46.1.2.1",
"WiFi": f"{MIB_EPSON}.1.1.3.1.29.2.1.9.0",
"MAC Addr": f"{MIB_EPSON}.1.1.3.1.1.5.0",
"device_id": f"{MIB_OID_ENTERPRISE}.11.2.3.9.1.1.7.0",
"Epson device id": f"{MIB_EPSON}.1.2.2.1.1.1.1.1",
"Power Off Timer": f"{EEPROM_LINK}.111.116.2.0.1.1"
}
MIB_INFO_ADVANCED = {
"Printer Status": f"{MIB_MGMT}.1.25.3.5.1.1", # hrPrinterStatus
"Printer Alerts": f"{MIB_MGMT}.1.43.18.1.1.8", # prtAlertDescription
"Printer Marker Supplies Level": f"{MIB_MGMT}.1.43.11.1.1.9", # prtMarkerSuppliesLevel
"Printer Marker Life Count": f"{MIB_MGMT}.1.43.11.1.1.6", # prtMarkerLifeCount
"Input Tray Status": f"{MIB_MGMT}.1.43.8.2.1.10", # prtInputStatus
"Output Tray Status": f"{MIB_MGMT}.1.43.9.2.1.10", # prtOutputStatus
"Printer Description": f"{MIB_MGMT}.1.25.3.2.1.3", # hrDeviceDescr
"Device Identification": f"{MIB_MGMT}.1.43.5.1.1.17", # prtGeneralSerialNumber
"Job Count": f"{MIB_MGMT}.1.43.10.2.1.4", # prtJobEntryJobCount
"Toner Level": f"{MIB_MGMT}.1.43.11.1.1.9.1", # prtMarkerSuppliesLevel
"Error Status": f"{MIB_MGMT}.1.43.16.5.1.2", # prtConsoleDisplayBufferText
"Power On Time": f"{MIB_MGMT}.1.25.3.2.1.5", # hrDeviceUptime
"Device Name": f"{MIB_MGMT}.1.1.5", # sysName
"Device Location": f"{MIB_MGMT}.1.1.6", # sysLocation
}
session: object
model: str
hostname: str
parm: dict
mib_dict: dict = {}
def __init__(
self,
conf_dict: dict = {},
replace_conf = False,
model: str = None,
hostname: str = None,
port: int = 161,
timeout: (None, float) = None,
retries: (None, float) = None,
dry_run: bool = False
) -> None:
"""Initialise printer model."""
def merge(source, destination):
for key, value in source.items():
if isinstance(value, dict):
merge(value, destination.setdefault(key, {}))
else:
if key == "alias" and "alias" in destination:
destination[key] += value
else:
destination[key] = value
return destination
if conf_dict:
self.expand_printer_conf(conf_dict)
if conf_dict and replace_conf:
self.PRINTER_CONFIG = conf_dict
else:
self.expand_printer_conf(self.PRINTER_CONFIG)
if conf_dict and not replace_conf:
self.PRINTER_CONFIG = merge(self.PRINTER_CONFIG, conf_dict)
for key, values in self.PRINTER_CONFIG.items():
if 'alias' in values:
values['alias'] = [
i for i in values['alias']
if i not in self.PRINTER_CONFIG
]
if not values['alias']:
del values['alias']
self.model = model
self.hostname = hostname
self.port = port
self.timeout = timeout
self.retries = retries
self.dry_run = dry_run
if self.model in self.valid_printers:
self.parm = self.PRINTER_CONFIG[self.model]
else:
self.parm = None
@property
def valid_printers(self):
"""Return list of defined printers."""
return {
printer_name
for printer_name in self.PRINTER_CONFIG.keys()
if "read_key" in self.PRINTER_CONFIG[printer_name]
}
@property
def list_methods(self):
"""
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):
"""
Expand "alias" and "same-as" of a printer database for all printers
"""
# process "alias" definintion
for printer_name, printer_data in conf.copy().items():
if "alias" in printer_data:
aliases = printer_data["alias"]
del printer_data["alias"]
if not isinstance(aliases, list):
logging.error(
"Alias '%s' of printer '%s' in configuration "
"must be a list.",
aliases, printer_name
)
continue
for alias_name in aliases:
if alias_name in conf:
logging.error(
"Alias '%s' of printer '%s' is already defined "
"in configuration.",
alias_name, printer_name
)
else:
conf[alias_name] = printer_data
# process "same-as" definintion
for printer_name, printer_data in conf.copy().items():
if "same-as" in printer_data: