SNMP - 解码十六进制字符串值 Epson L395

问题描述 投票:0回答:1

这是我的第一个问题,所以希望它能正确完成。

我正在尝试从 Epson L365 获取一些信息。问题是,当我尝试打印总页数时,我得到了十六进制字符串的响应

.1.3.6.1.4.1.1248.1.2.2.1.1.1.4.1  0x40 42 44 43 20 53 54 32 0D 0A 62 00 01 01 04 06 02 01 00 0F 0D 03 01 00 69 03 01 69 04 02 69 05 03 69 10 03 01 09 4E 13 01 01 19 0C 00 00 00 00 00 75 6E 6B 6E 6F 77 6E 24 02 00 00 28 04 FF 01 00 00 2F 01 01 36 14 FF FF FF FF FF FF FF FF DB 2C 00 00 09 09 00 00 A0 00 00 00 37 05 02 00 00 00 00 40 0A 58 32 4E 5A 34 36 31 33 39 31 OctetString

这就是我得到的回应

.1.3.6.1.4.1.1248.1.2.2.1.1.1.4.1  @BDC ST2 b......... ...i..i..i..i...    N..........unknown$...(...../..6..........,..       ......7......@ X2NZ461391  OctetString

我已经研究过了,不知道该去哪里。

printing snmp oid
1个回答
0
投票

可以通过安装epson_print_conf然后运行以下Python代码来解码某些数据:

import epson_print_conf
import pprint

printer = epson_print_conf.EpsonPrinter("", "", debug=True)
status = bytes.fromhex(
    "40 42 44 43 20 53 54 32 0D 0A 62 00 01 01 04 06 02 01 00 0F 0D 03 01 00 "
    "69 03 01 69 04 02 69 05 03 69 10 03 01 09 4E 13 01 01 19 0C 00 00 00 00 "
    "00 75 6E 6B 6E 6F 77 6E 24 02 00 00 28 04 FF 01 00 00 2F 01 01 36 14 FF "
    "FF FF FF FF FF FF FF DB 2C 00 00 09 09 00 00 A0 00 00 00 37 05 02 00 00 " 
    "00 00 40 0A 58 32 4E 5A 34 36 31 33 39 31"
)
decoded_status = printer.status_parser(status)
pprint.pprint(decoded_status)

输出:

Unaligned BDC ST2 header. Trying to fix...
Processing status - ftype 0x1 length: 1 item: 04
Processing status - ftype 0x6 length: 2 item: 01 00
Processing status - ftype 0xf length: 13 item: 03 01 00 69 03 01 69 04 02 69 05 03 69
Processing status - ftype 0x10 length: 3 item: 01 09 4e
Processing status - ftype 0x13 length: 1 item: 01
Processing status - ftype 0x19 length: 12 item: 00 00 00 00 00 75 6e 6b 6e 6f 77 6e
Processing status - ftype 0x24 length: 2 item: 00 00
Processing status - ftype 0x28 length: 4 item: ff 01 00 00
Processing status - ftype 0x2f length: 1 item: 01
Processing status - ftype 0x36 length: 20 item: ff ff ff ff ff ff ff ff db 2c 00 00 09 09 00 00 a0 00 00 00
Processing status - ftype 0x37 length: 5 item: 02 00 00 00 00
Processing status - ftype 0x40 length: 10 item: 58 32 4e 5a 34 36 31 33 39 31
>>> pprint.pprint(decoded_status)
{'cancel_code': 'No request',
 'ink_level': [(1, 0, 'Black', 'Black', 105),
               (3, 1, 'Cyan', 'Cyan', 105),
               (4, 2, 'Magenta', 'Magenta', 105),
               (5, 3, 'Yellow', 'Yellow', 105)],
 'jobname': 'Not defined',
 'loading_path': 'fixed',
 'maintenance_box_1': 'not full (0)',
 'maintenance_box_2': 'not full (0)',
 'maintenance_box_reset_count_1': 0,
 'maintenance_box_reset_count_2': 0,
 'paper_count_blank': 160,
 'paper_count_color': 11483,
 'paper_count_monochrome': 2313,
 'paper_count_normal': -1,
 'paper_count_page': -1,
 'paper_path': b'\x01\x00',
 'ready': True,
 'serial_number_info': 'X2NZ461391',
 'status': (4, 'Idle'),
 'unknown': [('0x24', b'\x00\x00'),
             ('0x28', b'\xff\x01\x00\x00'),
             ('0x2f', b'\x01')]}
© www.soinside.com 2019 - 2024. All rights reserved.