Skip to main content

bendev

A crossplatform Python package for communicating with the USB/SCPI-enabled Bentham Instruments hardware devices such as the TLS120Xe. The package uses hidapi to send and receive text based commands and replies using the USB HID protocol.

Compatibility

This software has been tested on Mac OS X, Ubuntu, and Windows, with python 3.8 onwards. It is compatible Bentham Instruments devices with an SCPI over USB HID packet interface.

Installation

pip install bendev

Usage

bendev devices can be instantiated in context managers:

>>> import bendev
>>> with bendev.Device() as dev:
...     print(dev.query("*IDN?"))
"Bentham Instruments Ltd.","MSH150_RD_Direct","99999/9","1.2.53"

or normally:

>>> import bendev
>>> my_tls = bendev.Device()
>>> my_tls.write("SYSTEM:REMOTE")
>>> my_tls.query("MONO:GOTO? 555")
"1"

Devices can be opened by serial number, product string or manufacturer string:

>>> import bendev
>>> device_a = bendev.Device(serial_number="99999/9")
>>> device_b = bendev.Device(product_string="TLS120Xe")
>>> device_c = bendev.Device(manufacturer_string="Bentham")

For product_string and manufacturer_string, it is sufficient if the given substring is present in the device descriptor. The serial_number has to be exact. manufacturer_string defaults to "Bentham".

The package can also tell you what devices are connected:

>>> import bendev
>>> devs=bendev.list_connected_devices(verbose=True)
Connected Devices:
Device 18: Bentham Instruments, TLS120Xe, ...

Known issues

On ubuntu the python hidapi module has been noted to fail to read device strings for an unknown reason; until this is resolved the devices may be opened as raw hid devices, bypassing the hidapi module:

>>> import bendev
>>> my_device = bendev.Device(hidraw = "/dev/hidraw2")
>>> my_device.query("*IDN?")
'"Bentham Instruments Ltd.","TLS120Xe","12345/6","0.5.3"'

Version history

  • v0.0.1 - v0.0.3: test releases
  • v0.0.4: first release
  • v0.1.0: added ability to use raw hid devices
  • v0.1.1: fix formatting issue
  • v0.2.0: add reconnect command
  • v0.3.0: add python 3.11 compatibility
  • v0.3.1: fix inverted vendor ID filter in list_connected_devices

Metadata

Release files for bendev 0.3.6

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for bendev 0.3.6
File Size Uploaded Provenance Actions
bendev-0.3.6.tar.gz 9.6 kB Without provenance Details for bendev-0.3.6.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for bendev 0.3.6
File Interpreter ABI Platform Actions
bendev-0.3.6-py3-none-any.whl Python 3 none any Details for bendev-0.3.6-py3-none-any.whl

Total release size: 19.4 kB

Release files / bendev-0.3.6.tar.gz

Download URL bendev-0.3.6.tar.gz
Size 9.6 kB
Tags Source
SHA-256 checksum
How to use checksums
52ab54cf587d78aea62643921f9d20adb09861ecb621382b1ac985fe5e2d070d
BLAKE2b-256 checksum
How to use checksums
f63f6190266050b4038abf77cd11c39f51e03a7f3deb7af67ce2e5b4d6f3129b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.9.25

Release files / bendev-0.3.6-py3-none-any.whl

Download URL bendev-0.3.6-py3-none-any.whl
Size 9.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
2ad61e1c07df919b64e473ac2ccc0c6ddc154293b3a5daa50e325c70211e7606
BLAKE2b-256 checksum
How to use checksums
d5e0e8fccde5e1a38707958de85b1880bcfdc701b20b67d4d73a5ee0e2eea8ae
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.9.25

Security for bendev 0.3.6

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.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page