From 7e8e1d948e3071e25692f01bf698bf8d3ac6a87f Mon Sep 17 00:00:00 2001 From: Kevin Caccamo Date: Fri, 8 Apr 2016 03:29:26 -0400 Subject: [PATCH] Fix all errors that occur when trying to initialize the driver. Most of the errors were references to nonexistent variables. I've finally got to testing this driver, and fixed these errors in the process. --- bin/weewx/drivers/ws1.py | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/bin/weewx/drivers/ws1.py b/bin/weewx/drivers/ws1.py index e52771ca..35a295c7 100644 --- a/bin/weewx/drivers/ws1.py +++ b/bin/weewx/drivers/ws1.py @@ -66,7 +66,8 @@ class WS1Driver(weewx.drivers.AbstractDevice): [Required. Default is serial] port - Serial port or network address. - [Required. Default is /dev/ttyS0 for serial, and 192.168.36.25:3000 for TCP/IP] + [Required. Default is /dev/ttyS0 for serial, + and 192.168.36.25:3000 for TCP/IP] max_tries - how often to retry serial communication before giving up. [Optional. Default is 5] @@ -101,8 +102,8 @@ class WS1Driver(weewx.drivers.AbstractDevice): DEBUG_READ = int(stn_dict.get('debug_read', DEBUG_READ)) if con_mode == 'tcp' or con_mode == 'udp': - self.station = StationInet(self.port, con_mode, timeout, max_tries, - retry_wait) + self.station = StationInet(self.port, con_mode, timeout, + self.max_tries, self.retry_wait) else: self.station = StationSerial(self.port, timeout=timeout) self.station.open() @@ -284,6 +285,9 @@ class StationInet(object): ip_addr = None ip_port = None + self.max_retries = max_retries + self.retry_interval = retry_interval + if addr.find(':') != -1: self.conn_info = addr.split(':') try: @@ -297,10 +301,10 @@ class StationInet(object): self.conn_info = (ip_addr, ip_port) try: - if self.protocol == 'tcp': + if protocol == 'tcp': self.net_socket = socket.socket( socket.AF_INET, socket.SOCK_STREAM) - elif self.protocol == 'udp': + elif protocol == 'udp': self.net_socket = socket.socket( socket.AF_INET, socket.SOCK_DGRAM) except (socket.error, socket.herror), ex: