Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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