Skip to content

Commit bd3e676

Browse files
committed
fixed heartbeat
1 parent fa2562e commit bd3e676

File tree

8 files changed

+3
-11
lines changed

8 files changed

+3
-11
lines changed
Binary file not shown.
Binary file not shown.
Binary file not shown.

python-serial/src/thermoflex/devices.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -374,7 +374,6 @@ def disableAll(self):
374374
for x in self.muscles.keys():
375375
command = command_t(self, SE, device = f'm{self.muscles[x].idnum+1}', params = [False] )
376376
self.net.command_buff.append(command)
377-
378377

379378

380379
def endself(self):

python-serial/src/thermoflex/network.py

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -167,26 +167,19 @@ def disperse(self, rec_packet):
167167
node_l = self.node_list.copy()
168168
response = deconst_serial_response(rec_packet['payload'])
169169
matching_node = None
170-
print(self.node_list, node_l, packet_node_id) #TEST
171170
# Check if the node already exists in the network
172171

173172
for node in node_l:# TODO: Disperse packet to node or muscle accordingly
174173
if node.node_id == packet_node_id:
175174
matching_node = node
176-
print("matching node found") #TEST
175+
177176
D.debug(DEBUG_LEVELS['DEBUG'], self.debug_name, f"Packet dispersing to existing node with id: {node.node_id}")
178177
break
179178
else: # If the node does not exist in the network, add it
180179
matching_node = self.addNode(packet_node_id)
181-
#print(self.node_list, node_l, packet_node_id) #TEST
182-
# try:
183-
# matching_node = self.getDevice(packet_node_id)
184-
# except IndexError:
185-
# print("Node {packet_node_id} not added.")
186180

187181
D.debug(DEBUG_LEVELS['DEBUG'], self.debug_name, f"Packet dispersing to new node with id: {packet_node_id}")
188182

189-
#print(self.node_list, node_l, packet_node_id) #TEST
190183
matching_node.msgrec = True
191184

192185
if 'status' in response[0]:
@@ -215,10 +208,10 @@ def time_check(self):
215208
currtime = int(t.time())
216209
for node in self.node_list:
217210
if node.heartbeat == True:
218-
if (node.tlastmsgrec + 1) > NodeNet.TIMEOUT:
211+
if (currtime-(node.tlastmsgrec + 1)) >= NodeNet.TIMEOUT:
219212
node.endself()
220213

221-
if node.tlastmsgsent > NodeNet.TIMEOUT:
214+
if (currtime-node.tlastmsgsent) >= NodeNet.TIMEOUT:
222215
send_command(node.pulse, self)
223216

224217
def update_network(self):
Binary file not shown.
Binary file not shown.
Binary file not shown.

0 commit comments

Comments
 (0)