How to use the pyvisa.constants 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 / rname.py View on Github external
:param resources: iterable of resources.
    :param query: query expression.
    """

    if '{' in query:
        query, _ = query.split('{')
        logger.warning('optional part of the query expression not supported. '
                       'See filter2')

    try:
        query = query.replace('?', '.')
        matcher = re.compile(query, re.IGNORECASE)
    except re.error:
        raise errors.VisaIOError(constants.VI_ERROR_INV_EXPR)

    return tuple(res for res in resources if matcher.match(res))
github pyvisa / pyvisa / pyvisa / attributes.py View on Github external
"""VI_ATTR_PXI_SLOT_LBUS_RIGHT specifies the slot number or special
    feature connected to the local bus right lines of this device.
    """
    resources = [(constants.InterfaceType.pxi, 'INSTR')]

    py_name = ''

    visa_name = 'VI_ATTR_PXI_SLOT_LBUS_RIGHT'

    visa_type = 'ViInt16'

    default = NotAvailable

    read, write, local = True, False, False

    min_value, max_value, values = 1, 18, [constants.VI_PXI_LBUS_UNKNOWN,
                                           constants.VI_PXI_LBUS_NONE,
                                           constants.VI_PXI_LBUS_STAR_TRIG_BUS_0,
                                           constants.VI_PXI_LBUS_STAR_TRIG_BUS_1,
                                           constants.VI_PXI_LBUS_STAR_TRIG_BUS_2,
                                           constants.VI_PXI_LBUS_STAR_TRIG_BUS_3,
                                           constants.VI_PXI_LBUS_STAR_TRIG_BUS_4,
                                           constants.VI_PXI_LBUS_STAR_TRIG_BUS_5,
                                           constants.VI_PXI_LBUS_STAR_TRIG_BUS_6,
                                           constants.VI_PXI_LBUS_STAR_TRIG_BUS_7,
                                           constants.VI_PXI_LBUS_STAR_TRIG_BUS_8,
                                           constants.VI_PXI_LBUS_STAR_TRIG_BUS_9,
                                           constants.VI_PXI_STAR_TRIG_CONTROLLER,
                                           constants.VI_PXI_LBUS_SCXI]

# noinspection PyPep8Naming
class AttrVI_ATTR_PXI_SLOT_LWIDTH(ValuesAttribute):
github pyvisa / pyvisa / pyvisa / attributes.py View on Github external
read, write, local = True, False, False

    min_value, max_value, values = 1, 18, [constants.VI_PXI_LBUS_UNKNOWN,
                                           constants.VI_PXI_LBUS_NONE,
                                           constants.VI_PXI_LBUS_STAR_TRIG_BUS_0,
                                           constants.VI_PXI_LBUS_STAR_TRIG_BUS_1,
                                           constants.VI_PXI_LBUS_STAR_TRIG_BUS_2,
                                           constants.VI_PXI_LBUS_STAR_TRIG_BUS_3,
                                           constants.VI_PXI_LBUS_STAR_TRIG_BUS_4,
                                           constants.VI_PXI_LBUS_STAR_TRIG_BUS_5,
                                           constants.VI_PXI_LBUS_STAR_TRIG_BUS_6,
                                           constants.VI_PXI_LBUS_STAR_TRIG_BUS_7,
                                           constants.VI_PXI_LBUS_STAR_TRIG_BUS_8,
                                           constants.VI_PXI_LBUS_STAR_TRIG_BUS_9,
                                           constants.VI_PXI_STAR_TRIG_CONTROLLER,
                                           constants.VI_PXI_LBUS_SCXI]

# noinspection PyPep8Naming
class AttrVI_ATTR_PXI_SLOT_LWIDTH(ValuesAttribute):
    """VI_ATTR_PXI_SLOT_LWIDTH specifies the PCI Express link width of the
    PXI Express peripheral slot in which the device resides. A value
    of –1 indicates that the device is not a PXI Express device.
    """
    resources = [(constants.InterfaceType.pxi, 'INSTR')]

    py_name = ''

    visa_name = 'VI_ATTR_PXI_SLOT_LWIDTH'

    visa_type = 'ViInt16'
github pyvisa / pyvisa / pyvisa / attributes.py View on Github external
def __init__(cls, name, bases, dct):
        super(AttributeType, cls).__init__(name, bases, dct)
        if not name.startswith('AttrVI_'):
            return
        cls.attribute_id = getattr(constants, cls.visa_name)
        cls.redoc()
        if cls.resources is AllSessionTypes:
            AttributesPerResource[AllSessionTypes].add(cls)
        else:
            for res in cls.resources:
                AttributesPerResource[res].add(cls)
        AttributesByID[cls.attribute_id] = cls
github pyvisa / pyvisa-sim / pyvisa-sim / usb.py View on Github external
def write(self, data):
        send_end = self.get_attribute(constants.VI_ATTR_SEND_END_EN)

        for i in range(len(data)):
            self.device.write(data[i:i+1])

        if send_end:
            # EOM 4882
            pass
github pyvisa / pyvisa / pyvisa / resources / helpers.py View on Github external
def _redoc(attribute_name, doc, extra_doc=''):
    if isinstance(attribute_name, string_types):
        if doc is None:
            doc = ''
        if not doc.endswith('\n\n'):
            doc += '\n\n'
        doc += ':VISA Attribute: %s.' % attribute_name
        if extra_doc:
            doc += '\n' + extra_doc
        attribute_name = getattr(constants, attribute_name)

    return attribute_name, doc
github pyvisa / pyvisa-py / pyvisa-py / gpib.py View on Github external
def _analyse_lines_value(value, line):
    """Determine the state of a GPIB line based on the iblines byte.

    """
    if line == constants.VI_ATTR_GPIB_REN_STATE:
        # REN bit valid = 0x10, REN bit value = 0x100
        validity_mask = 0x10
        value_mask = 0x100
    elif line == constants.VI_ATTR_GPIB_ATN_STATE:
        # ATN bit valid = 0x40, ATN bit value = 0x4000
        validity_mask = 0x40
        value_mask = 0x4000
    elif line == constants.VI_ATTR_GPIB_NDAC_STATE:
        # NDAC bit valid = 0x2, NDAC bit value = 0x200
        validity_mask = 0x2
        value_mask = 0x200
    elif line == constants.VI_ATTR_GPIB_SRQ_STATE:
        # SRQ bit valid = 0x20, SRQ bit value = 0x2000
        validity_mask = 0x20
        value_mask = 0x2000

    if not value & validity_mask:
        return constants.VI_STATE_UNKNOWN, StatusCode.success
    else:
        if value & value_mask:
github pyvisa / pyvisa / pyvisa / attributes.py View on Github external
(constants.InterfaceType.gpib, 'INTFC'),
                 (constants.InterfaceType.asrl, 'INSTR'),
                 (constants.InterfaceType.tcpip, 'INSTR'),
                 (constants.InterfaceType.tcpip, 'SOCKET'),
                 (constants.InterfaceType.usb, 'INSTR'),
                 (constants.InterfaceType.usb, 'RAW'),
                 (constants.InterfaceType.vxi, 'INSTR'),
                 (constants.InterfaceType.vxi, 'SERVANT')]

    py_name = ''

    visa_name = 'VI_ATTR_WR_BUF_OPER_MODE'

    visa_type = 'ViUInt16'

    default = constants.VI_FLUSH_WHEN_FULL

    read, write, local = True, True, True

    min_value, max_value, values = 0, 65535, []


# noinspection PyPep8Naming
class AttrVI_ATTR_WR_BUF_SIZE(RangeAttribute):
    """This is the current size of the formatted I/O output buffer for this
    session. The user can modify this value by calling viSetBuf().
    """
    resources = [(constants.InterfaceType.gpib, 'INSTR'),
                 (constants.InterfaceType.gpib, 'INTFC'),
                 (constants.InterfaceType.asrl, 'INSTR'),
                 (constants.InterfaceType.tcpip, 'INSTR'),
                 (constants.InterfaceType.tcpip, 'SOCKET'),
github pyvisa / pyvisa / pyvisa / attributes.py View on Github external
(Remote ENable) interface line.
    """
    resources = [(constants.InterfaceType.gpib, 'INSTR'),
                 (constants.InterfaceType.gpib, 'INTFC')]

    py_name = 'remote_enabled'

    visa_name = 'VI_ATTR_GPIB_REN_STATE'

    visa_type = 'ViInt16'

    default = NotAvailable

    read, write, local = True, False, False

    enum_type = constants.LineState


# noinspection PyPep8Naming
class AttrVI_ATTR_GPIB_SECONDARY_ADDR(RangeAttribute):
    """VI_ATTR_GPIB_SECONDARY_ADDR specifies the secondary address of the
    GPIB device used by the given session. For the GPIB INTFC
    Resource, this attribute is Read-Write.
    """
    resources = [(constants.InterfaceType.gpib, 'INSTR'),
                 (constants.InterfaceType.gpib, 'INTFC')]

    py_name = 'secondary_address'

    visa_name = 'VI_ATTR_GPIB_SECONDARY_ADDR'

    visa_type = 'ViUInt16'