Форум сайта python.su
0
Помогите разобраться.
Программа берет данные из файла ac.yaml данные для запроса.
Их много, но спотыкается только на этом:
reqs:
power1:
#disable: True
req: “\x03\x09\xea\x00\x02”
выдает ошибку:
Traceback (most recent call last): File "ac.py", line 63, in <module> main() File "ac.py", line 41, in main hex_result = moxa.send_command(ser, cmd, req_type) File "/opt/zabbix/pymoxa/MoxaClass.py", line 55, in send_command crc = modbus_crc(cmd) File "/usr/lib/python2.7/site-packages/minimalmodbus.py", line 1975, in _calculateCrcString _checkString(inputstring, description='input CRC string') File "/usr/lib/python2.7/site-packages/minimalmodbus.py", line 2224, in _checkString raise TypeError('The {0} should be a string. Given: {1!r}'.format(description, inputstring)) TypeError: The input CRC string should be a string. Given: u'\x02\x03\t\xea\x00\x02'
cond_addr = cfg['conditions'][cond]['id'] for req_type in sorted(cfg['reqs'].iterkeys()): if cfg['reqs'][req_type].get('disable'): continue cmd = cond_addr + cfg['reqs'][req_type]['req'] #cmd = cmd.encode('hex') #cmd = cmd.decode('hex') hex_result = moxa.send_command(ser, cmd, req_type) count = 3
Офлайн
857
Попробуй запустить программу на третьем питоне.
Офлайн