def setup(self): Monitor.setup(self) self.logger.debug("TCP:%i opening" % TCP_PORT) tcp = socket.socket(socket.AF_INET, socket.SOCK_STREAM) tcp.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) while True: try: tcp.bind((TCP_HOST, TCP_PORT)) except socket.error, msg: logger.debug( "error connecting: %s - retry in 20s" % msg) time.sleep(20) continue break
def setup(self): Monitor.setup(self) self.logger.debug("wattson: port=%s" % self.port) # 19200, 8N1 # 8 data bits, no parity bit, 1 stop bit self.connection = serial.Serial( port=self.port, baudrate=19200, parity=serial.PARITY_NONE, stopbits=serial.STOPBITS_ONE, bytesize=serial.EIGHTBITS, timeout=1) self.connection.close() self.connection.open() assert self.connection.isOpen() data = self.communicate("nows") self.logger.info("connected to wattson device %s" % data)