How to use the pyvisa.logger.debug function in PyVISA

To help you get started, we’ve selected a few PyVISA 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 pyvisa / pyvisa / pyvisa / resources / messagebased.py View on Github external
with self.ignore_warning(constants.VI_SUCCESS_DEV_NPRESENT,
                                 constants.VI_SUCCESS_MAX_CNT):
            try:
                status = None
                while len(ret) < count:
                    size = min(chunk_size, left_to_read)
                    logger.debug('%s - reading %d bytes (last status %r)',
                                 self._resource_name, size, status)
                    chunk, status = self.visalib.read(self.session, size)
                    ret.extend(chunk)
                    left_to_read -= len(chunk)
                    if break_on_termchar and status == termchar_read:
                        break
            except errors.VisaIOError as e:
                logger.debug('%s - exception while reading: %s\n'
                             'Buffer content: %r',  self._resource_name, e,
                             ret)
                raise
        return bytes(ret)
github pyvisa / pyvisa / pyvisa / highlevel.py View on Github external
def close(self):
        """Close the resource manager session.

        """
        try:
            logger.debug('Closing ResourceManager (session: %s)', self.session)
            # Cleanly close all resources when closing the manager.
            for resource in self._created_resources:
                resource.close()
            self.visalib.close(self.session)
            self.session = None
            self.visalib.resource_manager = None
        except errors.InvalidSession:
            pass
github pyvisa / pyvisa / pyvisa / highlevel.py View on Github external
and will be removed in 1.12

    If neither can be found, raise a ValueError.
    """

    from .ctwrapper import IVIVisaLibrary
    ni_binary_found = bool(IVIVisaLibrary.get_library_paths())
    if ni_binary_found:
        logger.debug('The IVI implementation available')
        return 'ivi'
    else:
        logger.debug('Did not find IVI binary')

    try:
        get_wrapper_class('py')  # check for pyvisa-py availability
        logger.debug('pyvisa-py is available.')
        return 'py'
    except ValueError:
        logger.debug('Did not find pyvisa-py package')
    raise ValueError('Could not locate a VISA implementation. Install either the IVI binary or pyvisa-py.')
github pyvisa / pyvisa-py / pyvisa-py / gpib.py View on Github external
def gpib_pass_control(self, primary_address, secondary_address):
        """Tell the GPIB device at the specified address to become controller in charge (CIC).

        Corresponds to viGpibPassControl function of the VISA library.

        :param session: Unique logical identifier to a session.
        :param primary_address: Primary address of the GPIB device to which you want to pass control.
        :param secondary_address: Secondary address of the targeted GPIB device.
                                  If the targeted device does not have a secondary address,
                                  this parameter should contain the value Constants.VI_NO_SEC_ADDR.
        :return: return value of the library call.
        :rtype: :class:`pyvisa.constants.StatusCode`
        """
        # ibpct need to get the device id matching the primary and secondary address
        logger.debug("GPIB.pass control")
        try:
            did = gpib.dev(self.parsed.board, primary_address, secondary_address)
        except gpib.GpibError:
            logger.exception(
                "Failed to get id for %s, %d", primary_address, secondary_address
            )
            return StatusCode.error_resource_not_found

        status = gpib_lib.ibpct(did)
        return convert_gpib_status(status)
github pyvisa / pyvisa / pyvisa / highlevel.py View on Github external
Use IVI if the binary is found, else try to use pyvisa-py.

    'ni' VISA wrapper is NOT used since version > 1.10.0
    and will be removed in 1.12

    If neither can be found, raise a ValueError.
    """

    from .ctwrapper import IVIVisaLibrary
    ni_binary_found = bool(IVIVisaLibrary.get_library_paths())
    if ni_binary_found:
        logger.debug('The IVI implementation available')
        return 'ivi'
    else:
        logger.debug('Did not find IVI binary')

    try:
        get_wrapper_class('py')  # check for pyvisa-py availability
        logger.debug('pyvisa-py is available.')
        return 'py'
    except ValueError:
        logger.debug('Did not find pyvisa-py package')
    raise ValueError('Could not locate a VISA implementation. Install either the IVI binary or pyvisa-py.')
github pyvisa / pyvisa / pyvisa / resources / messagebased.py View on Github external
:param size: The chunk size to use when reading the data.

        :rtype: bytearray
        """
        size = self.chunk_size if size is None else size

        loop_status = constants.StatusCode.success_max_count_read

        ret = bytearray()
        with self.ignore_warning(constants.VI_SUCCESS_DEV_NPRESENT,
                                 constants.VI_SUCCESS_MAX_CNT):
            try:
                status = loop_status
                while status == loop_status:
                    logger.debug('%s - reading %d bytes (last status %r)',
                                 self._resource_name, size, status)
                    chunk, status = self.visalib.read(self.session, size)
                    ret.extend(chunk)
            except errors.VisaIOError as e:
                logger.debug('%s - exception while reading: %s\nBuffer '
                             'content: %r', self._resource_name, e, ret)
                raise

        return ret
github pyvisa / pyvisa / pyvisa / highlevel.py View on Github external
"""

    from .ctwrapper import IVIVisaLibrary
    ni_binary_found = bool(IVIVisaLibrary.get_library_paths())
    if ni_binary_found:
        logger.debug('The IVI implementation available')
        return 'ivi'
    else:
        logger.debug('Did not find IVI binary')

    try:
        get_wrapper_class('py')  # check for pyvisa-py availability
        logger.debug('pyvisa-py is available.')
        return 'py'
    except ValueError:
        logger.debug('Did not find pyvisa-py package')
    raise ValueError('Could not locate a VISA implementation. Install either the IVI binary or pyvisa-py.')
github pyvisa / pyvisa / pyvisa / highlevel.py View on Github external
def _get_default_wrapper():
    """Return an available default VISA wrapper as a string ('ivi' or 'py').

    Use IVI if the binary is found, else try to use pyvisa-py.

    'ni' VISA wrapper is NOT used since version > 1.10.0
    and will be removed in 1.12

    If neither can be found, raise a ValueError.
    """

    from .ctwrapper import IVIVisaLibrary
    ni_binary_found = bool(IVIVisaLibrary.get_library_paths())
    if ni_binary_found:
        logger.debug('The IVI implementation available')
        return 'ivi'
    else:
        logger.debug('Did not find IVI binary')

    try:
        get_wrapper_class('py')  # check for pyvisa-py availability
        logger.debug('pyvisa-py is available.')
        return 'py'
    except ValueError:
        logger.debug('Did not find pyvisa-py package')
    raise ValueError('Could not locate a VISA implementation. Install either the IVI binary or pyvisa-py.')