-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathOscilloscopeConnectionTest.py
More file actions
70 lines (55 loc) · 1.63 KB
/
OscilloscopeConnectionTest.py
File metadata and controls
70 lines (55 loc) · 1.63 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
# OscilloscopeConnectionTest.py
#
# This example performs a connection test.
#
# Find more information on http://www.tiepie.com/LibTiePie .
from __future__ import print_function
import time
import sys
import libtiepie
from printinfo import *
# Print library info:
print_library_info()
# Enable network search:
libtiepie.network.auto_detect_enabled = True
# Search for devices:
libtiepie.device_list.update()
# Try to open an oscilloscope with connection test support:
scp = None
for item in libtiepie.device_list:
if item.can_open(libtiepie.DEVICETYPE_OSCILLOSCOPE):
scp = item.open_oscilloscope()
if scp.has_connection_test:
break
else:
scp = None
if scp:
try:
# Enable all channels that support connection testing:
for ch in scp.channels:
ch.enabled = ch.has_connection_test
# Print oscilloscope info:
print_device_info(scp)
# Start connection test:
scp.start_connection_test()
# Wait for connection test to complete:
while not scp.is_connection_test_completed:
time.sleep(0.01) # 10 ms delay, to save CPU time
# Get data:
result = scp.get_connection_test_data()
# Print result:
print()
print('Connection test result:')
ch = 1
for value in result:
print('Ch' + str(ch) + ' = ' + str(value))
ch += 1
except Exception as e:
print('Exception: ' + e.message)
sys.exit(1)
# Close oscilloscope:
del scp
else:
print('No oscilloscope available with connection test support!')
sys.exit(1)
sys.exit(0)