uscpi


Nameuscpi JSON
Version 0.3.0 PyPI version JSON
download
home_page
SummaryAn asynchronous SCPI instrumentation library.
upload_time2024-01-13 23:25:57
maintainer
docs_urlNone
author
requires_python>=3.11
licenseBSD 3-Clause License Copyright (c) 2023, Michael Czigler Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
keywords instrumentation scpi asynchronous
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # μSCPI

An asynchronous SCPI instrumentation library.

## Install

### PyPI

Installing the latest release from [PyPI](https://pypi.org).

```console
pip install -U uscpi
```

### Repository

When using [git](https://git-scm.com), clone the repository and 
change your present working directory.

```console
git clone http://github.com/mcpcpc/uscpi
cd uscpi/
```

Create and activate a virtual environment.

```console
python3 -m venv venv
source venv/bin/activate
```

Install μSCPI to the virtual environment.

```console
pip install -e .
```

## Usage

### Asynchronous

A basic example using the *asyncio* library.

```python
from asyncio import run
from uscpi import TCP
from uscpi import Instrument

client = TCP(host="127.0.0.1", port=5025)
instrument = Instrument(client=client)

async def main():
    response = await instrument.idn()
    print(response)

if __name__ == "__main__":
     run(main())
```

### Connection Timeout

By default, μSCPI will wait indefinitely for a connection to 
be established. If the `timeout` property is defined, an 
*asyncio.TimeoutError* will be raised after the specified 
connection time period (in seconds) is exceeded.

```python
TCP(host="127.0.0.1", port=5025, timeout=0.1)
```

### Automatic Connection Management

To ensure proper connection cleanup, the built-in asynchronous
context manager can be used. 

```python
async def main():
    async with TCP("127.0.0.1", 8080) as client:
        instrument = Instrument(client=client)
        response = await instrument.idn()
        print(response)
```

### Event Callbacks

There are four user callback functions that can be implemented 
and executed when a corresponding event is triggered:
`connection_made_cb`, `connection_lost_cb`, `data_received_cb`, 
and `eof_received_cb`. Each callable object must be passed to 
the client method during instantiation. 

```python
def user_cb():
    print("Connection made!")

TCP(host="127.0.0.1", port=5025, connection_made_cb=user_cb)
```

## Features

μSCPI is fairly lightweight and leaves a majority of 
instrument function commands to be implemented by the user. 
Nonetheless, the following IEEE-488.2 commands have been 
implemented:

- Clear Status Command
- Event Status Enable Command and Query
- Standard Event Status Register Query
- Identification Query
- Reset Command
- Service Request Enable Command and Query
- Read Status Byte Query
- Trigger Command
- Self-Test Query
- Wait-to-Continue Command

You can learn more about each of these commands by using the 
built-in `help` method.

```pycon
>>> from uscpi import Instrument
>>> help(Instrument)
```

## Credits

- [sockio](https://github.com/tiagocoutinho/sockio)
- [IEEE 488.2-1978 Protocol](https://ieeexplore.ieee.org/document/19528)
- [IEEE 488.2 Common Commands](https://rfmw.em.keysight.com/spdhelpfiles/truevolt/webhelp/US/Content/__I_SCPI/IEEE-488_Common_Commands.htm)

            

Raw data

            {
    "_id": null,
    "home_page": "",
    "name": "uscpi",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.11",
    "maintainer_email": "",
    "keywords": "instrumentation,SCPI,asynchronous",
    "author": "",
    "author_email": "Michael Czigler <michaelczigler@icloud.com>",
    "download_url": "https://files.pythonhosted.org/packages/45/ce/c2324930ecb3183b088b216a05c6ff5dc0c6fd6279e370086684c2d999e7/uscpi-0.3.0.tar.gz",
    "platform": null,
    "description": "# &mu;SCPI\n\nAn asynchronous SCPI instrumentation library.\n\n## Install\n\n### PyPI\n\nInstalling the latest release from [PyPI](https://pypi.org).\n\n```console\npip install -U uscpi\n```\n\n### Repository\n\nWhen using [git](https://git-scm.com), clone the repository and \nchange your present working directory.\n\n```console\ngit clone http://github.com/mcpcpc/uscpi\ncd uscpi/\n```\n\nCreate and activate a virtual environment.\n\n```console\npython3 -m venv venv\nsource venv/bin/activate\n```\n\nInstall &mu;SCPI to the virtual environment.\n\n```console\npip install -e .\n```\n\n## Usage\n\n### Asynchronous\n\nA basic example using the *asyncio* library.\n\n```python\nfrom asyncio import run\nfrom uscpi import TCP\nfrom uscpi import Instrument\n\nclient = TCP(host=\"127.0.0.1\", port=5025)\ninstrument = Instrument(client=client)\n\nasync def main():\n    response = await instrument.idn()\n    print(response)\n\nif __name__ == \"__main__\":\n     run(main())\n```\n\n### Connection Timeout\n\nBy default, &mu;SCPI will wait indefinitely for a connection to \nbe established. If the `timeout` property is defined, an \n*asyncio.TimeoutError* will be raised after the specified \nconnection time period (in seconds) is exceeded.\n\n```python\nTCP(host=\"127.0.0.1\", port=5025, timeout=0.1)\n```\n\n### Automatic Connection Management\n\nTo ensure proper connection cleanup, the built-in asynchronous\ncontext manager can be used. \n\n```python\nasync def main():\n    async with TCP(\"127.0.0.1\", 8080) as client:\n        instrument = Instrument(client=client)\n        response = await instrument.idn()\n        print(response)\n```\n\n### Event Callbacks\n\nThere are four user callback functions that can be implemented \nand executed when a corresponding event is triggered:\n`connection_made_cb`, `connection_lost_cb`, `data_received_cb`, \nand `eof_received_cb`. Each callable object must be passed to \nthe client method during instantiation. \n\n```python\ndef user_cb():\n    print(\"Connection made!\")\n\nTCP(host=\"127.0.0.1\", port=5025, connection_made_cb=user_cb)\n```\n\n## Features\n\n&mu;SCPI is fairly lightweight and leaves a majority of \ninstrument function commands to be implemented by the user. \nNonetheless, the following IEEE-488.2 commands have been \nimplemented:\n\n- Clear Status Command\n- Event Status Enable Command and Query\n- Standard Event Status Register Query\n- Identification Query\n- Reset Command\n- Service Request Enable Command and Query\n- Read Status Byte Query\n- Trigger Command\n- Self-Test Query\n- Wait-to-Continue Command\n\nYou can learn more about each of these commands by using the \nbuilt-in `help` method.\n\n```pycon\n>>> from uscpi import Instrument\n>>> help(Instrument)\n```\n\n## Credits\n\n- [sockio](https://github.com/tiagocoutinho/sockio)\n- [IEEE 488.2-1978 Protocol](https://ieeexplore.ieee.org/document/19528)\n- [IEEE 488.2 Common Commands](https://rfmw.em.keysight.com/spdhelpfiles/truevolt/webhelp/US/Content/__I_SCPI/IEEE-488_Common_Commands.htm)\n",
    "bugtrack_url": null,
    "license": "BSD 3-Clause License  Copyright (c) 2023, Michael Czigler  Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:  1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.  2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.  3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ",
    "summary": "An asynchronous SCPI instrumentation library.",
    "version": "0.3.0",
    "project_urls": {
        "homepage": "https://github.com/mcpcpc/uscpi",
        "repository": "https://github.com/mcpcpc/uscpi"
    },
    "split_keywords": [
        "instrumentation",
        "scpi",
        "asynchronous"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "bdc5afcef29cec8eef5b4b083d8e351b15cc29fc2b8a9baf10fdc1bdc21a9223",
                "md5": "be30da22773192d5a46f6a08a43cd149",
                "sha256": "1d296d252b6fb821f8253b4f6f63639caccd993813f334683d52de00268cd1e7"
            },
            "downloads": -1,
            "filename": "uscpi-0.3.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "be30da22773192d5a46f6a08a43cd149",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.11",
            "size": 8525,
            "upload_time": "2024-01-13T23:25:56",
            "upload_time_iso_8601": "2024-01-13T23:25:56.196499Z",
            "url": "https://files.pythonhosted.org/packages/bd/c5/afcef29cec8eef5b4b083d8e351b15cc29fc2b8a9baf10fdc1bdc21a9223/uscpi-0.3.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "45cec2324930ecb3183b088b216a05c6ff5dc0c6fd6279e370086684c2d999e7",
                "md5": "1a9ec05df70ba95bfd3140879c22cd34",
                "sha256": "9da9284803ddce7134a164463aeda29292fe94295d56c70e0bb08ee864547a83"
            },
            "downloads": -1,
            "filename": "uscpi-0.3.0.tar.gz",
            "has_sig": false,
            "md5_digest": "1a9ec05df70ba95bfd3140879c22cd34",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.11",
            "size": 10400,
            "upload_time": "2024-01-13T23:25:57",
            "upload_time_iso_8601": "2024-01-13T23:25:57.200887Z",
            "url": "https://files.pythonhosted.org/packages/45/ce/c2324930ecb3183b088b216a05c6ff5dc0c6fd6279e370086684c2d999e7/uscpi-0.3.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-01-13 23:25:57",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "mcpcpc",
    "github_project": "uscpi",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "uscpi"
}
        
Elapsed time: 0.46937s