Skip to content
Snippets Groups Projects
Commit e80ee027 authored by Martin Teichmann's avatar Martin Teichmann
Browse files

improve error messages

show what is bad, without overloading the output
parent 92ad6a33
No related branches found
No related tags found
No related merge requests found
...@@ -467,7 +467,7 @@ class SterilePacket(Packet): ...@@ -467,7 +467,7 @@ class SterilePacket(Packet):
def append(self, cmd, *args, counter=1): def append(self, cmd, *args, counter=1):
super().append(cmd, *args) super().append(cmd, *args)
self.counters[self.size - 2] = counter self.counters[self.size - 2] = {counter}
def sterile(self, index): def sterile(self, index):
ret = bytearray(self.assemble(index)) ret = bytearray(self.assemble(index))
...@@ -560,6 +560,9 @@ class SyncGroupBase: ...@@ -560,6 +560,9 @@ class SyncGroupBase:
continue continue
data = self.update_devices(data) data = self.update_devices(data)
newtime = monotonic() newtime = monotonic()
if newtime - lasttime > self.cycletime:
logging.warning('cycletime exceeded (%f ms)',
(newtime - lasttime) * 1000)
await sleep(self.cycletime - (newtime - lasttime)) await sleep(self.cycletime - (newtime - lasttime))
lasttime = monotonic() lasttime = monotonic()
finally: finally:
...@@ -594,11 +597,12 @@ class SyncGroup(SyncGroupBase): ...@@ -594,11 +597,12 @@ class SyncGroup(SyncGroupBase):
def update_devices(self, data): def update_devices(self, data):
self.current_data = bytearray(data) self.current_data = bytearray(data)
for pos, count in self.packet.counters.items(): for pos, counts in self.packet.counters.items():
if data[pos] != count: if data[pos] not in counts:
logging.warning( logging.warning(
'EtherCAT datagram was processe %i times, should be %i', 'EtherCAT datagram processed %i times, should be in %s',
data[pos], count) data[pos], counts)
counts.add(data[pos])
self.current_data[pos] = 0 self.current_data[pos] = 0
for dev in self.devices: for dev in self.devices:
dev.update() dev.update()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment