Python: erreur boucle for et if
J'ai fait la fonction suivante pour récupérer mais valeurs de registres
Code:
1 2 3 4 5 6 7 8 9 10 11 12
|
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 r |
Sachant que la fonction reg_val_list3(s) est codée comme ça :
Code:
1 2 3 4 5 6 7 8 9 10 11
|
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 v |
et la fonction reg_val_list_binary(s) est codée ainsi:
Code:
1 2 3 4 5 6 7
|
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 r |
J'ai l'impression qu'il ne trouve pas func_code == 1 alors qu'il y est
Un idée ?