code: def _attempt_command_recovery(command, ack, serial_conn):
      '''Recovery after following a failed write_and_return() atempt'''
      with serial_with_temp_timeout(serial_conn, RECOVERY_TIMEOUT) as device:
          response = _write_to_device_and_return(command, ack, device)
      if response is None:
          log.debug("No valid response during _attempt_command_recovery")
          raise RuntimeError(
              "Recovery attempted - no valid serial response "
              "for command: {} in {} seconds".format(
                  command.encode(), RECOVERY_TIMEOUT))
      return responsf _attempt_command_recovery(command, ack, serial_conn):
      '''Recovery after following a failed write_and_return() atempt'''
      with serial_with_temp_timeout(serial_conn, RECOVERY_TIMEOUT) as device:
          response = _write_to_device_and_return(command, ack, device)
      if response is None:
          log.debug("No valid response during _attempt_command_recovery")
          raise RuntimeError(
              "Recovery attempted - no valid serial response "
              "for command: {} in {} seconds".format(
                  command.encode(), RECOVERY_TIMEOUT))
      return response
docs: Recovery after following a failed write_and_return() atempt