pythonusbtmc man page

pythonusbtmc — Python USBTMC Documentation

This Python package supports the USBTMC instrument control protocol for controlling instruments over USB.

See also:

·
Python USBTMC home page
·
GitHub repository

Contents:

Introduction to Python Usbtmc

Overview

This Python package supports the USBTMC instrument control protocol for controlling instruments over USB. The implementation is pure Python and highly portable.

It is released under the MIT license, see License for more details.

Copyright (C) 2012-2013 Alex Forencich <alex@alexforencich.com>

See also:

·
Python USBTMC home page
·
GitHub repository

Features

·
Supports Python 2 and Python 3
·
Pure Python
·
Highly portable
·
Communicates with instruments that support the USB Test and Measurement Class

Requirements

·
Python 2 or Python 3
·
PyUSB

Installation

To install the module for all users on the system, administrator rights (root) are required.

From source

Download the archive, extract, and run:

python setup.py install

Packages

There are also packaged versions for some Linux distributions:

Arch Linux
Python USBTMC is available under the name "python-usbtmc-git" in the AUR.

Python Usbtmc Examples

Opening a connection

Connect to an Agilent MSO7104A oscilloscope on IP address 192.168.1.104:

>>> import usbtmc
>>> instr =  usbtmc.Instrument(2391, 5973)
>>> print(instr.ask("*IDN?"))
'AGILENT TECHNOLOGIES,MSO7104A,MY********,06.16.0001'

Configuring connections

Open a connection and set the timeout:

>>> import usbtmc
>>> instr =  usbtmc.Instrument(2391, 5973)
>>> instr.timeout = 60*1000
>>> print(instr.ask("*TST?"))
'0'

Usbtmc --- Usbtmc Driver

This module provides a USBTMC instrument driver.

Functions and Exceptions

exception usbtmc.UsbtmcError
Exception raised on various occasions; argument is a string describing what is wrong.

Instrument class

class usbtmc.Instrument(*args, **kwargs)

USBTMC instrument interface client

ask(message, num=-1, encoding='utf-8')
Write then read string
ask_raw(data, num=-1)
Write then read binary data
clear()
Send clear command
local()
Send local command
lock()
Send lock command
pulse()
Send a pulse indicator request, this should blink a light for 500-1000ms and then turn off again. (Only if supported)
read(num=-1, encoding='utf-8')
Read string from instrument
read_raw(num=-1)
Read binary data from instrument
read_stb()
Read status byte
remote()
Send remote command
trigger()
Send trigger command
unlock()
Send unlock command
write(message, encoding='utf-8')
Write string to instrument
write_raw(data)
Write binary data to instrument

Appendix

License

Copyright (c) 2012-2016 Alex Forencich

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR Copyright HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

·
genindex
·
modindex
·
search

Author

Alex Forencich

Info

Aug 17, 2016 0.1 Python USBTMC