Skip to main content

Control module for Bentham Instruments Ltd SCPI devices

Project description

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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

bendev-0.3.1.tar.gz (6.8 kB view details)

Uploaded Source

Built Distribution

bendev-0.3.1-py3-none-any.whl (8.0 kB view details)

Uploaded Python 3

File details

Details for the file bendev-0.3.1.tar.gz.

File metadata

  • Download URL: bendev-0.3.1.tar.gz
  • Upload date:
  • Size: 6.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.18

File hashes

Hashes for bendev-0.3.1.tar.gz
Algorithm Hash digest
SHA256 8aa1f006f82d5d41648809f67b6b1afe3fb9a3fa25d7a8d8b3dd7f2dab23f05b
MD5 0f3b4e54b0ea100852369bb3e9109dfa
BLAKE2b-256 c4e807390ecde70c1791bfb7c9924a17e800c1696905bc171886e88098bbd3a0

See more details on using hashes here.

File details

Details for the file bendev-0.3.1-py3-none-any.whl.

File metadata

  • Download URL: bendev-0.3.1-py3-none-any.whl
  • Upload date:
  • Size: 8.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.18

File hashes

Hashes for bendev-0.3.1-py3-none-any.whl
Algorithm Hash digest
SHA256 71739c43b6678e4eab27de2aa7a00021582f8e7fc9b0c9bb6d6dc48b331de64d
MD5 dd0c1183ea0900f0765dd0866ff9d978
BLAKE2b-256 2c42318d8c522e83406dd54155708be262065332d89e56a55f2749b8cdb8c13c

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page