Jun-19-2020, 12:40 PM
I made this function to code some values according to func_code value but it does not work as aaspected:
Any idea?
def reg_val_list_binary2(s): r = [] for i in func_code(s): try: if i == 3: r = reg_val_list3(s) elif i == 1: r = reg_val_list_binary(s) except AttributeError: pass return rFinction reg_val_list3(s) is coded as follows:
def reg_val_list3(s): v = [] for p in s: if p.haslayer('ModbusADUResponse'): try: if p['ModbusADUResponse'][1].funcCode == 3: v += p['ModbusADUResponse'][1].registerVal except AttributeError: pass return vAnd function reg_val_list_binary(s):
def reg_val_list_binary(s): r = [] for x in reg_val_list1(s): r += [int(bit)for bit in str( bin(x) )[2:].zfill(8)] [::-1] return rThe problem is I have the impression that it cannot find func_code == 1 while it's in the func_code(s) list
Any idea?