How to use the minimalmodbus.Instrument.read_string function in minimalmodbus

To help you get started, we’ve selected a few minimalmodbus examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github CINF / PyExpLabSys / PyExpLabSys / drivers / crowcon.py View on Github external
def read_string(self, *args, **kwargs):
        """Read string from instrument (with retries)

        The argument definition is the same as for the minimalmodbus method, see the full
        documentation `read_string
        `_ for details.

        """
        for retry in range(0, self.retries + 1):
            try:
                return Instrument.read_string(self, *args, **kwargs)
            except ValueError as exception:
                if retry < self.retries:
                    LOGGER.warning("Communication error in read_string, retrying %s "
                                   "out of %s times", retry + 1, self.retries)
                    continue
                else:
                    raise exception