@@ -55,17 +54,17 @@ class ExtensibleSerialInstrument(object):
ignore_echo=False
port_settings={}
def__init__(self,port=None,**kwargs):
def__init__(self,port,**kwargs):
"""
Set up the serial port and so on.
"""
logging.info("Updating BSI port settings")
logging.info("Updating ESI port settings")
self.port_settings.update(kwargs)
logging.info("Opening BSI connection to port {}".format(port))
logging.info("Opening ESI connection to port {}".format(port))
self.open(port,False)# Eventually this shouldn't rely on init...
logging.info("Opened BSI connection to port {}".format(port))
logging.info("Opened ESI connection to port {}".format(port))
defopen(self,port=None,quiet=True):
defopen(self,port,quiet=True):
"""Open communications with the serial port.
If no port is specified, it will attempt to autodetect. If quiet=True
@@ -73,10 +72,9 @@ class ExtensibleSerialInstrument(object):
"""
withself.communications_lock:
ifhasattr(self,'_ser')andself._ser.isOpen():
ifnotquiet:print("Warning: attempted to open an already-open port!")
ifnotquiet:logging.warning("Attempted to open an already-open port!")
return
ifportisNone:port=self.find_port()
assertportisnotNone,"We don't have a serial port to open, meaning you didn't specify a valid port and autodetection failed. Are you sure the instrument is connected?"
assertportisnotNone,"We don't have a serial port to open, meaning you didn't specify a valid port. Are you sure the instrument is connected?"