prologix-gpib-async


Nameprologix-gpib-async JSON
Version 1.4.14 PyPI version JSON
download
home_pageNone
SummaryA Python AsyncIO library for the Prologix GPIB (Ethernet) adapter
upload_time2024-06-22 12:40:05
maintainerNone
docs_urlNone
authorNone
requires_python>=3.7
licenseGNU General Public License v3 (GPLv3)
keywords prologix gpib api
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            [![pylint](../../actions/workflows/pylint.yml/badge.svg)](../../actions/workflows/pylint.yml)
[![PyPI](https://img.shields.io/pypi/v/prologix-gpib-async)](https://pypi.org/project/prologix-gpib-async/)
![PyPI - Python Version](https://img.shields.io/pypi/pyversions/prologix-gpib-async)
![PyPI - Status](https://img.shields.io/pypi/status/prologix-gpib-async)
[![License: GPL v3](https://img.shields.io/badge/License-GPL%20v3-blue.svg)](LICENSE)
[![code style](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)
# prologix_gpib_async
Python3 AsyncIO Prologix GPIB Driver. This library requires Python
[asyncio](https://docs.python.org/3/library/asyncio.html). In contrast to a synchronous implementation, this library
makes it possible to control multiple GPIB controllers at once and work with large setups.

The library is fully type-hinted.

## Supported Hardware
|Device|Supported|Tested|Comments|
|--|--|--|--|
|[GPIB-ETHERNET Controller 1.2](http://prologix.biz/gpib-ethernet-controller.html)|:heavy_check_mark:|:heavy_check_mark:|  |
|[GPIB-USB Controller 6.0](http://prologix.biz/gpib-usb-controller.html)|:x:|:x:|Need hardware

Tested using Linux, should work for Mac OSX, Windows and any OS with Python support.

## Setup
To install the library in a virtual environment (always use venvs with every project):

```bash
python3 -m venv env  # virtual environment, optional
source env/bin/activate
pip install prologix-gpib-async
```

## Usage
This library makes use of asynchronous context managers to hide all connection related stuff and
also handle cleanup. By the way: Context managers are great!

Initialize the GPIB adapter
```python
from prologix_gpib_async import AsyncPrologixGpibEthernetController

# Create a controller and talk to device address 22
async with AsyncPrologixGpibEthernetController("127.0.0.1", pad=22) as gpib_device:
    # Add your code here
    ...
```

Sending a "my command" command to address 22 (as set up previously)
```python
await gpib_device.write("my command")
```

Reading data from address 22
```python
data = await gpib_device.read()
```

Example program, that queries the version string as can be found at [examples/example.py](examples/example.py)
```python
import asyncio

# Devices
from prologix_gpib_async import AsyncPrologixGpibEthernetController


async def main():
    try:
        async with AsyncPrologixGpibEthernetController("127.0.0.1", pad=22) as gpib_device:
            version = await gpib_device.version()
            print("Controller version:", version)
    except (ConnectionError, ConnectionRefusedError):
        print("Could not connect to remote target. Is the device connected?")


asyncio.run(main())
```

See [examples/](examples/) for more working examples.

## Support for Multiple Devices
The Prologix GPIB adapter supports talking to multiple devices, but there are (theoretical) hardware limits. The
Prologix adapters do not have line drivers, so only a limited number of devices can be driven using one controller.

On the software side, there is full support for multiple devices and the driver will switch between different addresses
transparently. The driver internally manages the connection and keeps track of the GPIB controller state and manages the
state for each gpib object. It is important, that the driver is the only client editing the state of the GPIB
controller. Otherwise, the driver state and the controller state may get out of sync.

> :warning: **Concurrency with multiple devices**: Note, that when using a single adapter to control multiple devices,
> there is no concurrency on the GPIB bus. Whenever reading or writing to a remote device, the driver will lock the GPIB
> controller to ensure that reading from a controller is synchronous. This means, there is **no** speed increase, when
> making asynchronous reads from multiple devices on the bus. Using a GPIB Group Execute Trigger (GET) by invoking the
> trigger() function, concurrent measurements can be triggered though. Some devices also allow asynchronous function
> calls, that signal status updates via the srq register.

Example:
```python
import asyncio

# Devices
from prologix_gpib_async import AsyncPrologixGpibEthernetController

ip_address = "127.0.0.1"


async def main():
    """This example will print the IDs of the two different SCPI devices"""
    try:
        async with AsyncPrologixGpibEthernetController(
            ip_address, pad=22
        ) as gpib_device1, AsyncPrologixGpibEthernetController(ip_address, pad=10) as gpib_device2:
            await gpib_device1.write(b"*IDN?")  # Automatically changes address to device 22
            print(await gpib_device1.read())
            await gpib_device2.write(b"*IDN?")  # Automatically changes address to device 10
            print(await gpib_device2.read())
    except (ConnectionError, ConnectionRefusedError):
        print("Could not connect to remote target. Is the device connected?")


asyncio.run(main())
```

## Versioning
I use [SemVer](http://semver.org/) for versioning. For the versions available, see the
[tags on this repository](../../tags).

## Documentation
I use the [Numpydoc](https://numpydoc.readthedocs.io/en/latest/format.html) style for documentation.

## Authors
* **Patrick Baus** - *Initial work* - [PatrickBaus](https://github.com/PatrickBaus)

## License
This project is licensed under the GPL v3 license - see the [LICENSE](LICENSE) file for details

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "prologix-gpib-async",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.7",
    "maintainer_email": null,
    "keywords": "Prologix, GPIB, API",
    "author": null,
    "author_email": "Patrick Baus <patrick.baus@physik.tu-darmstadt.de>",
    "download_url": "https://files.pythonhosted.org/packages/23/c1/8547e202c2f1298fe8632da5fb6c5c8d405e4bc5695f30b848bd11ad6cef/prologix_gpib_async-1.4.14.tar.gz",
    "platform": null,
    "description": "[![pylint](../../actions/workflows/pylint.yml/badge.svg)](../../actions/workflows/pylint.yml)\n[![PyPI](https://img.shields.io/pypi/v/prologix-gpib-async)](https://pypi.org/project/prologix-gpib-async/)\n![PyPI - Python Version](https://img.shields.io/pypi/pyversions/prologix-gpib-async)\n![PyPI - Status](https://img.shields.io/pypi/status/prologix-gpib-async)\n[![License: GPL v3](https://img.shields.io/badge/License-GPL%20v3-blue.svg)](LICENSE)\n[![code style](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)\n# prologix_gpib_async\nPython3 AsyncIO Prologix GPIB Driver. This library requires Python\n[asyncio](https://docs.python.org/3/library/asyncio.html). In contrast to a synchronous implementation, this library\nmakes it possible to control multiple GPIB controllers at once and work with large setups.\n\nThe library is fully type-hinted.\n\n## Supported Hardware\n|Device|Supported|Tested|Comments|\n|--|--|--|--|\n|[GPIB-ETHERNET Controller 1.2](http://prologix.biz/gpib-ethernet-controller.html)|:heavy_check_mark:|:heavy_check_mark:|  |\n|[GPIB-USB Controller 6.0](http://prologix.biz/gpib-usb-controller.html)|:x:|:x:|Need hardware\n\nTested using Linux, should work for Mac OSX, Windows and any OS with Python support.\n\n## Setup\nTo install the library in a virtual environment (always use venvs with every project):\n\n```bash\npython3 -m venv env  # virtual environment, optional\nsource env/bin/activate\npip install prologix-gpib-async\n```\n\n## Usage\nThis library makes use of asynchronous context managers to hide all connection related stuff and\nalso handle cleanup. By the way: Context managers are great!\n\nInitialize the GPIB adapter\n```python\nfrom prologix_gpib_async import AsyncPrologixGpibEthernetController\n\n# Create a controller and talk to device address 22\nasync with AsyncPrologixGpibEthernetController(\"127.0.0.1\", pad=22) as gpib_device:\n    # Add your code here\n    ...\n```\n\nSending a \"my command\" command to address 22 (as set up previously)\n```python\nawait gpib_device.write(\"my command\")\n```\n\nReading data from address 22\n```python\ndata = await gpib_device.read()\n```\n\nExample program, that queries the version string as can be found at [examples/example.py](examples/example.py)\n```python\nimport asyncio\n\n# Devices\nfrom prologix_gpib_async import AsyncPrologixGpibEthernetController\n\n\nasync def main():\n    try:\n        async with AsyncPrologixGpibEthernetController(\"127.0.0.1\", pad=22) as gpib_device:\n            version = await gpib_device.version()\n            print(\"Controller version:\", version)\n    except (ConnectionError, ConnectionRefusedError):\n        print(\"Could not connect to remote target. Is the device connected?\")\n\n\nasyncio.run(main())\n```\n\nSee [examples/](examples/) for more working examples.\n\n## Support for Multiple Devices\nThe Prologix GPIB adapter supports talking to multiple devices, but there are (theoretical) hardware limits. The\nPrologix adapters do not have line drivers, so only a limited number of devices can be driven using one controller.\n\nOn the software side, there is full support for multiple devices and the driver will switch between different addresses\ntransparently. The driver internally manages the connection and keeps track of the GPIB controller state and manages the\nstate for each gpib object. It is important, that the driver is the only client editing the state of the GPIB\ncontroller. Otherwise, the driver state and the controller state may get out of sync.\n\n> :warning: **Concurrency with multiple devices**: Note, that when using a single adapter to control multiple devices,\n> there is no concurrency on the GPIB bus. Whenever reading or writing to a remote device, the driver will lock the GPIB\n> controller to ensure that reading from a controller is synchronous. This means, there is **no** speed increase, when\n> making asynchronous reads from multiple devices on the bus. Using a GPIB Group Execute Trigger (GET) by invoking the\n> trigger() function, concurrent measurements can be triggered though. Some devices also allow asynchronous function\n> calls, that signal status updates via the srq register.\n\nExample:\n```python\nimport asyncio\n\n# Devices\nfrom prologix_gpib_async import AsyncPrologixGpibEthernetController\n\nip_address = \"127.0.0.1\"\n\n\nasync def main():\n    \"\"\"This example will print the IDs of the two different SCPI devices\"\"\"\n    try:\n        async with AsyncPrologixGpibEthernetController(\n            ip_address, pad=22\n        ) as gpib_device1, AsyncPrologixGpibEthernetController(ip_address, pad=10) as gpib_device2:\n            await gpib_device1.write(b\"*IDN?\")  # Automatically changes address to device 22\n            print(await gpib_device1.read())\n            await gpib_device2.write(b\"*IDN?\")  # Automatically changes address to device 10\n            print(await gpib_device2.read())\n    except (ConnectionError, ConnectionRefusedError):\n        print(\"Could not connect to remote target. Is the device connected?\")\n\n\nasyncio.run(main())\n```\n\n## Versioning\nI use [SemVer](http://semver.org/) for versioning. For the versions available, see the\n[tags on this repository](../../tags).\n\n## Documentation\nI use the [Numpydoc](https://numpydoc.readthedocs.io/en/latest/format.html) style for documentation.\n\n## Authors\n* **Patrick Baus** - *Initial work* - [PatrickBaus](https://github.com/PatrickBaus)\n\n## License\nThis project is licensed under the GPL v3 license - see the [LICENSE](LICENSE) file for details\n",
    "bugtrack_url": null,
    "license": "GNU General Public License v3 (GPLv3)",
    "summary": "A Python AsyncIO library for the Prologix GPIB (Ethernet) adapter",
    "version": "1.4.14",
    "project_urls": {
        "Bug Tracker": "https://github.com/PatrickBaus/pyAsyncPrologixGpib/issues",
        "Download": "https://github.com/PatrickBaus/pyAsyncPrologixGpib/releases",
        "Homepage": "https://github.com/PatrickBaus/pyAsyncPrologixGpib"
    },
    "split_keywords": [
        "prologix",
        " gpib",
        " api"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "50c521ba06d6335934b2c36b47bdfd898e8f55318a5c9c33367a1c191e875eeb",
                "md5": "c89d3a376a1a3ba3938ef63cbe85c833",
                "sha256": "c9be8a824e4d4c89a83958fe770bf528fee3b8eee8d07fc001880552cda34db7"
            },
            "downloads": -1,
            "filename": "prologix_gpib_async-1.4.14-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "c89d3a376a1a3ba3938ef63cbe85c833",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.7",
            "size": 31317,
            "upload_time": "2024-06-22T12:40:03",
            "upload_time_iso_8601": "2024-06-22T12:40:03.233261Z",
            "url": "https://files.pythonhosted.org/packages/50/c5/21ba06d6335934b2c36b47bdfd898e8f55318a5c9c33367a1c191e875eeb/prologix_gpib_async-1.4.14-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "23c18547e202c2f1298fe8632da5fb6c5c8d405e4bc5695f30b848bd11ad6cef",
                "md5": "7c0c4b0f4b1fcb38a96cca519185a4d8",
                "sha256": "f62bc29bbdf43cfb3f2bc626685d81af958877fbeb22eec76ac1126fbbe17e56"
            },
            "downloads": -1,
            "filename": "prologix_gpib_async-1.4.14.tar.gz",
            "has_sig": false,
            "md5_digest": "7c0c4b0f4b1fcb38a96cca519185a4d8",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.7",
            "size": 31240,
            "upload_time": "2024-06-22T12:40:05",
            "upload_time_iso_8601": "2024-06-22T12:40:05.866719Z",
            "url": "https://files.pythonhosted.org/packages/23/c1/8547e202c2f1298fe8632da5fb6c5c8d405e4bc5695f30b848bd11ad6cef/prologix_gpib_async-1.4.14.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-06-22 12:40:05",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "PatrickBaus",
    "github_project": "pyAsyncPrologixGpib",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "prologix-gpib-async"
}
        
Elapsed time: 0.28955s