prologix-gpib-async


Nameprologix-gpib-async JSON
Version 1.4.13 PyPI version JSON
download
home_page
SummaryA Python AsyncIO library for the Prologix GPIB (Ethernet) adapter
upload_time2023-12-07 04:11:59
maintainer
docs_urlNone
author
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
from contextlib import AsyncExitStack

# Devices
from prologix_gpib_async import AsyncPrologixGpibEthernetController

ip_address = "127.0.0.1"


async def main():
    try:
        async with AsyncExitStack() as stack:
            gpib_device1, gpib_device2 = await asyncio.gather(
                stack.enter_async_context(AsyncPrologixGpibEthernetController(ip_address, pad=22)),
                stack.enter_async_context(AsyncPrologixGpibEthernetController(ip_address, pad=10)),
            )
            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": "",
    "name": "prologix-gpib-async",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.7",
    "maintainer_email": "",
    "keywords": "Prologix,GPIB,API",
    "author": "",
    "author_email": "Patrick Baus <patrick.baus@physik.tu-darmstadt.de>",
    "download_url": "https://files.pythonhosted.org/packages/f8/6e/62ccbc72553229730964ccfed054c3fe5cae4139d185b69e5cd5d4f89473/prologix_gpib_async-1.4.13.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\nfrom contextlib import AsyncExitStack\n\n# Devices\nfrom prologix_gpib_async import AsyncPrologixGpibEthernetController\n\nip_address = \"127.0.0.1\"\n\n\nasync def main():\n    try:\n        async with AsyncExitStack() as stack:\n            gpib_device1, gpib_device2 = await asyncio.gather(\n                stack.enter_async_context(AsyncPrologixGpibEthernetController(ip_address, pad=22)),\n                stack.enter_async_context(AsyncPrologixGpibEthernetController(ip_address, pad=10)),\n            )\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.13",
    "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": "0d1415099349e11cd665b40443a0fdb5f3fa72bd74cc991f846820a8d345aa55",
                "md5": "a13498c460e021b208ed279ab0a5f7b5",
                "sha256": "43e4e19eeccbc0afdd90f1528b4f4d60724d8374852d1e19070b75e496b7ff10"
            },
            "downloads": -1,
            "filename": "prologix_gpib_async-1.4.13-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "a13498c460e021b208ed279ab0a5f7b5",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.7",
            "size": 31321,
            "upload_time": "2023-12-07T04:11:57",
            "upload_time_iso_8601": "2023-12-07T04:11:57.502649Z",
            "url": "https://files.pythonhosted.org/packages/0d/14/15099349e11cd665b40443a0fdb5f3fa72bd74cc991f846820a8d345aa55/prologix_gpib_async-1.4.13-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "f86e62ccbc72553229730964ccfed054c3fe5cae4139d185b69e5cd5d4f89473",
                "md5": "66c1a053150c360529ac4e9db1c99b2f",
                "sha256": "9fed418a8c27373ac708e601ac498c469d8a22c8d53e14f939f33389c30bb126"
            },
            "downloads": -1,
            "filename": "prologix_gpib_async-1.4.13.tar.gz",
            "has_sig": false,
            "md5_digest": "66c1a053150c360529ac4e9db1c99b2f",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.7",
            "size": 31261,
            "upload_time": "2023-12-07T04:11:59",
            "upload_time_iso_8601": "2023-12-07T04:11:59.360451Z",
            "url": "https://files.pythonhosted.org/packages/f8/6e/62ccbc72553229730964ccfed054c3fe5cae4139d185b69e5cd5d4f89473/prologix_gpib_async-1.4.13.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-12-07 04:11:59",
    "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.32576s