Добавить шлюзы CAN/RS485 и Modbus и уточнить обработку CAN
This commit is contained in:
@@ -13,13 +13,14 @@ def decode_gas167(frame, node):
|
||||
result.protocol = "УМП %d / ProtoCAN GAS 167/v1" % node
|
||||
if not frame.ide or frame.rtr or frame.is_error:
|
||||
return result
|
||||
if result.id.msg_type not in (pc.MsgType.GENERAL_ADDRESS_SPACE,
|
||||
pc.MsgType.MODBUS_HOLDING):
|
||||
if result.id.msg_type not in (pc.MsgType.GENERAL_ADDRESS_SPACE, pc.MsgType.MODBUS): # Текущий ProtoCAN использует единый тип Modbus 0x5; отдельного MODBUS_HOLDING больше нет.
|
||||
return result
|
||||
if result.id.msg_type == pc.MsgType.GENERAL_ADDRESS_SPACE:
|
||||
start = result.id.body
|
||||
else:
|
||||
start, _count = pc.split_modbus(result.id.body)
|
||||
start, _count, function = pc.split_modbus(result.id.body) # Современный Body возвращает также функцию, определяющую банк регистров.
|
||||
if function != pc.ModbusFunction.HOLDING: # Ручная карта GAS 167/v1 относится к прежнему банку Holding, а не к дискретам или входным регистрам Modbus.
|
||||
return result # Остальные банки сохраняют штатную расшифровку ProtoCAN без ошибочной подстановки адресов карты УМП.
|
||||
words = result.registers
|
||||
if words is None:
|
||||
return result
|
||||
|
||||
Reference in New Issue
Block a user