semvec/pypi-packages huggingface dataset:
PyAR488 1.7.2
module to interface AR488 boards
License: MIT
Requires Python: >=3.6

# PyAR488

PyAR488 is a Python package to interact with **AR488** GPIB-USB
interface boards.\
It provides a thin abstraction layer over the serial interface to
simplify communication with GPIB instruments.

------------------------------------------------------------------------

## Installation

``` bash
pip install PyAR488
```

## Requirements

-   Python 3.6+
-   `pyserial` (installed automatically as a dependency)

------------------------------------------------------------------------

## Quickstart

``` python
from PyAR488.PyAR488 import AR488

# Open the interface (replace COM5 with your serial port)
interface = AR488("COM5")

# Set GPIB address and read
interface.address(22)
print(interface.read())
```

------------------------------------------------------------------------

## Using PyAR488 in Custom Instrument Classes

A recommended pattern is to inject the AR488 interface into your
instrument classes:

``` python
from PyAR488.PyAR488 import AR488

class HP3468A:
    def __init__(self, gpib_address: int, interface: AR488):
        self.address = gpib_address
        self.interface = interface

    def read_measurement(self):
        self.interface.address(self.address)
        return self.interface.read()

interface = AR488("COM5")
meter = HP3468A(22, interface)

reading = meter.read_measurement()
print(reading)
```

------------------------------------------------------------------------

## Safer Pattern: Enforcing Address Before Each Operation

If multiple instruments share the same interface, ensure the GPIB
address is set before every read/write:

``` python
class MyInstrument:
    def __init__(self, interface: AR488, address: int):
        self.interface = interface
        self.address = address

    def read(self, message: str = ""):
        self.interface.address(self.address)
        return self.interface.read(message)
```

This prevents accidental cross-talk when the interface address is
changed elsewhere in your code.

------------------------------------------------------------------------

## Debugging

Enable debug mode to print communication traffic:

``` python
interface = AR488("COM5", debug=True)
```

------------------------------------------------------------------------

## Support

-   Source code: https://github.com/Minu-IU3IRR/PyAR488
-   Issue tracker: https://github.com/Minu-IU3IRR/PyAR488/issues