1PYTHONUSBTMC(1) Python USBTMC PYTHONUSBTMC(1)
2
3
4
6 pythonusbtmc - Python USBTMC Documentation
7
8 This Python package supports the USBTMC instrument control protocol for
9 controlling instruments over USB.
10
11 See also:
12
13 · Python USBTMC home page
14
15 · GitHub repository
16
17 Contents:
18
20 Overview
21 This Python package supports the USBTMC instrument control protocol for
22 controlling instruments over USB. The implementation is pure Python
23 and highly portable.
24
25 It is released under the MIT license, see LICENSE for more details.
26
27 Copyright (C) 2012-2013 Alex Forencich <alex@alexforencich.com>
28
29 See also:
30
31 · Python USBTMC home page
32
33 · GitHub repository
34
35 Features
36 · Supports Python 2 and Python 3
37
38 · Pure Python
39
40 · Highly portable
41
42 · Communicates with instruments that support the USB Test and Measure‐
43 ment Class
44
45 Requirements
46 · Python 2 or Python 3
47
48 · PyUSB
49
50 Installation
51 To install the module for all users on the system, administrator rights
52 (root) are required.
53
54 From source
55 Download the archive, extract, and run:
56
57 python setup.py install
58
59 Packages
60 There are also packaged versions for some Linux distributions:
61
62 Arch Linux
63 Python USBTMC is available under the name "python-usbtmc-git" in
64 the AUR.
65
67 Opening a connection
68 Connect to an Agilent MSO7104A oscilloscope on IP address
69 192.168.1.104:
70
71 >>> import usbtmc
72 >>> instr = usbtmc.Instrument(2391, 5973)
73 >>> print(instr.ask("*IDN?"))
74 'AGILENT TECHNOLOGIES,MSO7104A,MY********,06.16.0001'
75
76 Configuring connections
77 Open a connection and set the timeout:
78
79 >>> import usbtmc
80 >>> instr = usbtmc.Instrument(2391, 5973)
81 >>> instr.timeout = 60*1000
82 >>> print(instr.ask("*TST?"))
83 '0'
84
86 This module provides a USBTMC instrument driver.
87
88 Functions and Exceptions
89 exception usbtmc.UsbtmcError
90 Exception raised on various occasions; argument is a string
91 describing what is wrong.
92
93 Instrument class
94 class usbtmc.Instrument(*args, **kwargs)
95 USBTMC instrument interface client
96
97 ask(message, num=-1, encoding='utf-8')
98 Write then read string
99
100 ask_raw(data, num=-1)
101 Write then read binary data
102
103 clear()
104 Send clear command
105
106 local()
107 Send local command
108
109 lock() Send lock command
110
111 pulse()
112 Send a pulse indicator request, this should blink a light
113 for 500-1000ms and then turn off again. (Only if sup‐
114 ported)
115
116 read(num=-1, encoding='utf-8')
117 Read string from instrument
118
119 read_raw(num=-1)
120 Read binary data from instrument
121
122 read_stb()
123 Read status byte
124
125 remote()
126 Send remote command
127
128 trigger()
129 Send trigger command
130
131 unlock()
132 Send unlock command
133
134 write(message, encoding='utf-8')
135 Write string to instrument
136
137 write_raw(data)
138 Write binary data to instrument
139
141 License
142 Copyright (c) 2012-2016 Alex Forencich
143
144 Permission is hereby granted, free of charge, to any person obtaining a
145 copy of this software and associated documentation files (the "Soft‐
146 ware"), to deal in the Software without restriction, including without
147 limitation the rights to use, copy, modify, merge, publish, distribute,
148 sublicense, and/or sell copies of the Software, and to permit persons
149 to whom the Software is furnished to do so, subject to the following
150 conditions:
151
152 The above copyright notice and this permission notice shall be included
153 in all copies or substantial portions of the Software.
154
155 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
156 OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MER‐
157 CHANTABILITY FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
158 NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
159 CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
160 TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFT‐
161 WARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
162
163 · genindex
164
165 · modindex
166
167 · search
168
170 Alex Forencich
171
173 2013, Alex Forencich
174
175
176
177
1780.1 Jul 15, 2018 PYTHONUSBTMC(1)