μSCPI
An asynchronous SCPI instrumentation library.
Install
PyPI
Installing the latest release from PyPI.
pip install -U uscpi
Repository
When using git, clone the repository and change your present working directory.
git clone http://github.com/mcpcpc/uscpi
cd uscpi/
Create and activate a virtual environment.
python3 -m venv venv
source venv/bin/activate
Install μSCPI to the virtual environment.
pip install -e .
Usage
Asynchronous
A basic example using the asyncio library.
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.
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.
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.
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.
>>> from uscpi import Instrument
>>> help(Instrument)
Credits
Metadata
Release files for uscpi 0.3.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| uscpi-0.3.0.tar.gz | 10.4 kB | Without provenance | Details for uscpi-0.3.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| uscpi-0.3.0-py3-none-any.whl | Python 3 | none | any | Details for uscpi-0.3.0-py3-none-any.whl |
Total release size: 18.9 kB
Release files / uscpi-0.3.0.tar.gz
| Download URL | uscpi-0.3.0.tar.gz |
|---|---|
| Size | 10.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
9da9284803ddce7134a164463aeda29292fe94295d56c70e0bb08ee864547a83
|
|
BLAKE2b-256 checksum How to use checksums |
45cec2324930ecb3183b088b216a05c6ff5dc0c6fd6279e370086684c2d999e7
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.9.18
|
Release files / uscpi-0.3.0-py3-none-any.whl
| Download URL | uscpi-0.3.0-py3-none-any.whl |
|---|---|
| Size | 8.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
1d296d252b6fb821f8253b4f6f63639caccd993813f334683d52de00268cd1e7
|
|
BLAKE2b-256 checksum How to use checksums |
bdc5afcef29cec8eef5b4b083d8e351b15cc29fc2b8a9baf10fdc1bdc21a9223
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.9.18
|
Security for uscpi 0.3.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.