From 2c4b42850eab58ac45a7d15331c577b480874a99 Mon Sep 17 00:00:00 2001 From: Wolfgang Hottgenroth Date: Thu, 11 Jul 2019 12:06:05 +0100 Subject: [PATCH] introduce inter comm delay, solves most error situations --- src/CmdServer.py | 12 +++++++++++- src/CommunicationProcessor.py | 4 ++++ src/Config.py | 2 +- src/registers.pkl | Bin 1322 -> 1384 bytes 4 files changed, 16 insertions(+), 2 deletions(-) diff --git a/src/CmdServer.py b/src/CmdServer.py index 89c49b2..34d3ce2 100644 --- a/src/CmdServer.py +++ b/src/CmdServer.py @@ -210,10 +210,20 @@ class CmdInterpreter(cmd.Cmd): self.__println("-----------") self.__println("List the configured datapoints") + def do_reset(self, arg): + for r in self.registers: + r.errorCount = 0 + r.processCount = 0 + + def help_reset(self): + self.__println("Usage: reset") + self.__println("-----------") + self.__println("Resets the statistics of configured datapoints") + def do_stats(self, arg): for i, r in enumerate(self.registers): if r.processCount == 0: - ratio = None + ratio = -1 else: ratio = float(r.errorCount) / float(r.processCount) self.__println("#{0:2d}: {1:15s} ({2:2d}, {3:5d}), pc: {4:7d}, ec: {5:7d}, q: {6:1.4f}" diff --git a/src/CommunicationProcessor.py b/src/CommunicationProcessor.py index ba70c2f..f2a03dc 100644 --- a/src/CommunicationProcessor.py +++ b/src/CommunicationProcessor.py @@ -5,6 +5,7 @@ import RegisterDatapoint from pymodbus.client.sync import ModbusSerialClient import wiringpi import MyRS485 +import time ERROR_PIN = 29 @@ -44,6 +45,9 @@ class CommunicationProcessor(threading.Thread): if client.socket is None: print("renew socket") client.socket = self.__getSerial() + finally: + time.sleep(self.config.interCommDelay) + diff --git a/src/Config.py b/src/Config.py index 89cd369..2a9abf6 100644 --- a/src/Config.py +++ b/src/Config.py @@ -10,4 +10,4 @@ class Config(object): self.registerFile = 'registers.pkl' self.serialPort = '/dev/ttyAMA0' self.serialBaudRate = 9600 - + self.interCommDelay = 0.025 diff --git a/src/registers.pkl b/src/registers.pkl index 5fb85c42f7ab85136e32a9d2a1277ec91892a433..ff7ea93077aad709327224db400ac0f5bd0830f6 100644 GIT binary patch literal 1384 zcmaiz+fvg|6o%8%Hl^h#;1LxMXi)??C&@s?Dkx{hhH%!=&> ztW`#A>@(s;bmWwzAPAPK5eo?=%b&N&zDqon1s*|C$#5lb4V94%+d4$5tfaX@Yy>1A z2E@v5Usr9J-$7aruQGF=WWq0lSWL~JQxc?ylJFH78Cj)^7jOg3GJU%3xTcOSrI$;a zfi~ILyE~$>RG;M?o2fcO&vEg37xd;c;x93qof}UYKhRe~zl>8#f)`|mF2R7(!ynCX z3L{>1Iv7+sxfqt-QLTVrXcwoYziMR7^-RYz*&)tIu?ni^=*0K)PGB>fm4s*{#Pb}l zBAw$>*ec15kjkC7>Po1oEeOA!W%{0tPySr!tq|E^CdUKu;`4A)6s5S zyY%mIRGX<7lNtUWJ(HxcuTr7AyhVJ+4EX%Qw+5W#cSHlRwDC=P@FXss^ zFhPHDMvH#vE%0dQR}d2Vzmu)0h|1%VFt- zDi))plbP>HEY%9U-e57;{Z-n$(Q<_fv1BO?HG5`Po