|
@@ -44,8 +44,11 @@ __author__ = 'RoGeorge'
|
44
|
44
|
logging.basicConfig(level=logging.INFO,
|
45
|
45
|
format='%(asctime)s - %(levelname)s - %(message)s',
|
46
|
46
|
filename=os.path.basename(sys.argv[0]) + '.log')
|
|
47
|
+logging.info("New run started...")
|
47
|
48
|
logging.info("Log message: INFO level set.")
|
48
|
49
|
|
|
50
|
+log_running_Python_versions()
|
|
51
|
+
|
49
|
52
|
# Update the next lines for your own default settings:
|
50
|
53
|
path_to_save = "captures/"
|
51
|
54
|
save_format = "PNG"
|
|
@@ -70,7 +73,6 @@ script_name = os.path.basename(sys.argv[0])
|
70
|
73
|
|
71
|
74
|
|
72
|
75
|
def print_help():
|
73
|
|
- # Print usage
|
74
|
76
|
print
|
75
|
77
|
print "Usage:"
|
76
|
78
|
print " " + "python " + script_name + " png|bmp|csv [oscilloscope_IP [save_path]]"
|
|
@@ -100,8 +102,6 @@ if len(sys.argv) <= 1:
|
100
|
102
|
elif sys.argv[1].lower() not in ["png", "bmp", "csv"]:
|
101
|
103
|
print_help()
|
102
|
104
|
print "This file type is not supported: ", sys.argv[1]
|
103
|
|
- print
|
104
|
|
- print_running_Python_versions()
|
105
|
105
|
sys.exit("ERROR")
|
106
|
106
|
|
107
|
107
|
file_format = sys.argv[1].lower()
|
|
@@ -132,21 +132,17 @@ instrument_id = command(tn, "*idn?") # ask for instrument ID
|
132
|
132
|
|
133
|
133
|
# Check if instrument is set to accept LAN commands
|
134
|
134
|
if instrument_id == "command error":
|
135
|
|
- print instrument_id
|
|
135
|
+ print "Instrument reply:", instrument_id
|
136
|
136
|
print "Check the oscilloscope settings."
|
137
|
137
|
print "Utility -> IO Setting -> RemoteIO -> LAN must be ON"
|
138
|
|
- print
|
139
|
|
- print_running_Python_versions()
|
140
|
138
|
sys.exit("ERROR")
|
141
|
139
|
|
142
|
140
|
# Check if instrument is indeed a Rigol DS1000Z series
|
143
|
141
|
id_fields = instrument_id.split(",")
|
144
|
142
|
if (id_fields[company] != "RIGOL TECHNOLOGIES") or \
|
145
|
143
|
(id_fields[model][:3] != "DS1") or (id_fields[model][-1] != "Z"):
|
146
|
|
- print
|
|
144
|
+ print "Found instrument model", id_fields[model], "instead of expected model, DS1*Z"
|
147
|
145
|
print "ERROR: No Rigol from series DS1000Z found at ", IP_DS1104Z
|
148
|
|
- print
|
149
|
|
- print_running_Python_versions()
|
150
|
146
|
sys.exit("ERROR")
|
151
|
147
|
|
152
|
148
|
print "Instrument ID:",
|
|
@@ -199,8 +195,6 @@ elif file_format == "csv":
|
199
|
195
|
if response == '1':
|
200
|
196
|
channel_list += [channel]
|
201
|
197
|
|
202
|
|
- print "Active channels on the display:", channel_list
|
203
|
|
-
|
204
|
198
|
csv_buff = ""
|
205
|
199
|
depth = get_memory_depth(tn)
|
206
|
200
|
|
|
@@ -224,25 +218,15 @@ elif file_format == "csv":
|
224
|
218
|
# if you get on the oscilloscope screen the error message
|
225
|
219
|
# "Memory lack in waveform reading!", then decrease max_chunk value
|
226
|
220
|
max_chunk = 100000 # tested for DS1104Z
|
227
|
|
- print "max_chunk=", max_chunk
|
228
|
|
- print "depth=", depth
|
229
|
|
- print "max_chunk > depth:", max_chunk > depth
|
230
|
221
|
if max_chunk > depth:
|
231
|
222
|
max_chunk = depth
|
232
|
223
|
|
233
|
|
- print "max_chunk=", max_chunk
|
234
|
224
|
n1 = 1
|
235
|
225
|
n2 = max_chunk
|
236
|
|
- print "n2=", n2
|
237
|
226
|
while data_available:
|
238
|
227
|
display_n1 = n1
|
239
|
|
- print
|
240
|
|
- print "n1=", n1
|
241
|
|
- print "n2=", n2
|
242
|
228
|
stop_point = is_waveform_from_to(tn, n1, n2)
|
243
|
|
- print "stop_point=", stop_point
|
244
|
229
|
if stop_point == 0:
|
245
|
|
- print_running_Python_versions()
|
246
|
230
|
logging.error("ERROR: Stop data point index is Zero while available data is True.")
|
247
|
231
|
sys.exit("ERROR")
|
248
|
232
|
elif stop_point < n1:
|