introduce inter comm delay, solves most error situations
This commit is contained in:
@ -210,10 +210,20 @@ class CmdInterpreter(cmd.Cmd):
|
|||||||
self.__println("-----------")
|
self.__println("-----------")
|
||||||
self.__println("List the configured datapoints")
|
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):
|
def do_stats(self, arg):
|
||||||
for i, r in enumerate(self.registers):
|
for i, r in enumerate(self.registers):
|
||||||
if r.processCount == 0:
|
if r.processCount == 0:
|
||||||
ratio = None
|
ratio = -1
|
||||||
else:
|
else:
|
||||||
ratio = float(r.errorCount) / float(r.processCount)
|
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}"
|
self.__println("#{0:2d}: {1:15s} ({2:2d}, {3:5d}), pc: {4:7d}, ec: {5:7d}, q: {6:1.4f}"
|
||||||
|
@ -5,6 +5,7 @@ import RegisterDatapoint
|
|||||||
from pymodbus.client.sync import ModbusSerialClient
|
from pymodbus.client.sync import ModbusSerialClient
|
||||||
import wiringpi
|
import wiringpi
|
||||||
import MyRS485
|
import MyRS485
|
||||||
|
import time
|
||||||
|
|
||||||
|
|
||||||
ERROR_PIN = 29
|
ERROR_PIN = 29
|
||||||
@ -44,6 +45,9 @@ class CommunicationProcessor(threading.Thread):
|
|||||||
if client.socket is None:
|
if client.socket is None:
|
||||||
print("renew socket")
|
print("renew socket")
|
||||||
client.socket = self.__getSerial()
|
client.socket = self.__getSerial()
|
||||||
|
finally:
|
||||||
|
time.sleep(self.config.interCommDelay)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -10,4 +10,4 @@ class Config(object):
|
|||||||
self.registerFile = 'registers.pkl'
|
self.registerFile = 'registers.pkl'
|
||||||
self.serialPort = '/dev/ttyAMA0'
|
self.serialPort = '/dev/ttyAMA0'
|
||||||
self.serialBaudRate = 9600
|
self.serialBaudRate = 9600
|
||||||
|
self.interCommDelay = 0.025
|
||||||
|
Binary file not shown.
Reference in New Issue
Block a user