Loading openflexure_microscope/stage/sangaboard/extensible_serial_instrument.py +8 −7 Original line number Diff line number Diff line Loading @@ -143,7 +143,7 @@ class ExtensibleSerialInstrument(object): if self._ser.inWaiting() > 0: self._ser.flushInput() def readline(self): def readline(self, timeout=None): """Read one line from the serial port.""" with self.communications_lock: return ( Loading @@ -163,7 +163,7 @@ class ExtensibleSerialInstrument(object): self._communications_lock = threading.RLock() return self._communications_lock def read_multiline(self, termination_line=None): def read_multiline(self, termination_line=None, timeout=None): """Read one line from the underlying bus. Must be overriden. This should not need to be reimplemented unless there's a more efficient Loading @@ -179,11 +179,11 @@ class ExtensibleSerialInstrument(object): while ( termination_line not in last_line and len(last_line) > 0 ): # read until we get the termination line. last_line = self.readline() last_line = self.readline(timeout) response += last_line return response def query(self, queryString, multiline=False, termination_line=None): def query(self, queryString, multiline=False, termination_line=None, timeout=None): """ Write a string to the stage controller and return its response. Loading @@ -198,10 +198,10 @@ class ExtensibleSerialInstrument(object): logging.debug("Query written") if self.ignore_echo == True: # Needs Implementing for a multiline read! logging.debug("Reading first line...") first_line = self.readline().strip() first_line = self.readline(timeout).strip() logging.debug(f"Read finished. Got {first_line}") if first_line == queryString: return self.readline().strip() return self.readline(timeout).strip() else: logging.info("This command did not echo!!!") return first_line Loading @@ -214,7 +214,7 @@ class ExtensibleSerialInstrument(object): else: logging.debug("Reading response...") line = ( self.readline().strip() self.readline(timeout).strip() ) # question: should we strip the final newline? logging.debug(f"Read finished. Got {line}") return line Loading Loading @@ -352,6 +352,7 @@ class ExtensibleSerialInstrument(object): def find_port(self): """Iterate through the available serial ports and query them to see if our instrument is there.""" print("Auto-scanning ports") with self.communications_lock: success = False for ( Loading openflexure_microscope/stage/sangaboard/sangaboard.py +1 −1 Original line number Diff line number Diff line Loading @@ -102,7 +102,7 @@ class Sangaboard(ExtensibleSerialInstrument): # Initialise basic serial instrument with specified logging.info(f"Initialising ExtensibleSerialInstrument on port {port}") ExtensibleSerialInstrument.__init__(self, port, timeout=timeout, **kwargs) ExtensibleSerialInstrument.__init__(self, port, **kwargs) try: # Make absolutely sure that whatever port we're on is valid Loading Loading
openflexure_microscope/stage/sangaboard/extensible_serial_instrument.py +8 −7 Original line number Diff line number Diff line Loading @@ -143,7 +143,7 @@ class ExtensibleSerialInstrument(object): if self._ser.inWaiting() > 0: self._ser.flushInput() def readline(self): def readline(self, timeout=None): """Read one line from the serial port.""" with self.communications_lock: return ( Loading @@ -163,7 +163,7 @@ class ExtensibleSerialInstrument(object): self._communications_lock = threading.RLock() return self._communications_lock def read_multiline(self, termination_line=None): def read_multiline(self, termination_line=None, timeout=None): """Read one line from the underlying bus. Must be overriden. This should not need to be reimplemented unless there's a more efficient Loading @@ -179,11 +179,11 @@ class ExtensibleSerialInstrument(object): while ( termination_line not in last_line and len(last_line) > 0 ): # read until we get the termination line. last_line = self.readline() last_line = self.readline(timeout) response += last_line return response def query(self, queryString, multiline=False, termination_line=None): def query(self, queryString, multiline=False, termination_line=None, timeout=None): """ Write a string to the stage controller and return its response. Loading @@ -198,10 +198,10 @@ class ExtensibleSerialInstrument(object): logging.debug("Query written") if self.ignore_echo == True: # Needs Implementing for a multiline read! logging.debug("Reading first line...") first_line = self.readline().strip() first_line = self.readline(timeout).strip() logging.debug(f"Read finished. Got {first_line}") if first_line == queryString: return self.readline().strip() return self.readline(timeout).strip() else: logging.info("This command did not echo!!!") return first_line Loading @@ -214,7 +214,7 @@ class ExtensibleSerialInstrument(object): else: logging.debug("Reading response...") line = ( self.readline().strip() self.readline(timeout).strip() ) # question: should we strip the final newline? logging.debug(f"Read finished. Got {line}") return line Loading Loading @@ -352,6 +352,7 @@ class ExtensibleSerialInstrument(object): def find_port(self): """Iterate through the available serial ports and query them to see if our instrument is there.""" print("Auto-scanning ports") with self.communications_lock: success = False for ( Loading
openflexure_microscope/stage/sangaboard/sangaboard.py +1 −1 Original line number Diff line number Diff line Loading @@ -102,7 +102,7 @@ class Sangaboard(ExtensibleSerialInstrument): # Initialise basic serial instrument with specified logging.info(f"Initialising ExtensibleSerialInstrument on port {port}") ExtensibleSerialInstrument.__init__(self, port, timeout=timeout, **kwargs) ExtensibleSerialInstrument.__init__(self, port, **kwargs) try: # Make absolutely sure that whatever port we're on is valid Loading