[DECODER_PROPRE.PY] Code Improvements

master
Eloan ANDRÉ 2 years ago
parent 4140960d6c
commit 6c3939b912

@ -67,9 +67,14 @@ def decode(pkt):
else:
#Get the list of byte's values that have been read
status = modpkt.payload.getfieldval("registerVal")
#Add the read's status into the `connect` database
#Fill the list of the values/address that have been read
LPackets = []
for j in range(len(status)):
triPacket([miniL[0][1],miniL[2]+j,status[j]],connec)
LPackets.append([miniL[0][1],miniL[2]+j,status[j]])
#Add the read's status into the `connect` database
triPacket([miniL[0][1],miniL[2]+j,LPackets],connec)
#Reset the globalization's list
miniL = [0,0,0]
@ -97,11 +102,16 @@ def decode(pkt):
if "C" in type_call:
#Transform the byte's values into a list of bits values for each byte
status = BytesToBits(value)
#Add the write's status into the `connect` database
LPackets = []
#Get the number of bytes to be write in order to not reset to 0, address on the same bytes of the written one's
byte_count = modpkt.payload.getfieldval("quantityOutput")
#Fill the list of the values/address that while be write
for j in range(byte_count):
triPacket([miniL[0][1],addr+j,status[j]],connec)
LPackets.append([miniL[0][1],addr+j,status[j]])
#Add and check the write's status into the `connect` database
triPacket([miniL[0][1],addr+j,LPackets,connec)
#Single write request
else:
#Single write coil request

Loading…
Cancel
Save