|
@@ -1,6 +1,5 @@
|
1
|
1
|
__author__ = 'RoGeorge'
|
2
|
2
|
#
|
3
|
|
-# TODO: Port for Linux
|
4
|
3
|
# TODO: Add command line parameters for IP, file path and file format
|
5
|
4
|
# TODO: Add GUI
|
6
|
5
|
# TODO: Add browse and custom filename selection
|
|
@@ -12,6 +11,7 @@ import Image
|
12
|
11
|
import StringIO
|
13
|
12
|
import sys
|
14
|
13
|
import os
|
|
14
|
+import platform
|
15
|
15
|
|
16
|
16
|
# Update the next lines for your own default settings:
|
17
|
17
|
path_to_save = ""
|
|
@@ -38,7 +38,7 @@ script_name = os.path.basename(sys.argv[0])
|
38
|
38
|
# Print usage
|
39
|
39
|
print
|
40
|
40
|
print "Usage:"
|
41
|
|
-print " " + script_name + " [oscilloscope_IP [save_path [PNG | BMP]]]"
|
|
41
|
+print " " + script_name + " [oscilloscope_IP [save_path [png | bmp]]]"
|
42
|
42
|
print
|
43
|
43
|
print "Usage examples:"
|
44
|
44
|
print " " + script_name
|
|
@@ -61,34 +61,38 @@ print
|
61
|
61
|
|
62
|
62
|
|
63
|
63
|
# Check network response (ping)
|
64
|
|
-response = os.system("ping -n 1 " + IP_DS1104Z + " > nul")
|
|
64
|
+if platform.system() == "Windows":
|
|
65
|
+ response = os.system("ping -n 1 " + IP_DS1104Z + " > nul")
|
|
66
|
+else:
|
|
67
|
+ response = os.system("ping -c 1 " + IP_DS1104Z + " > /dev/null")
|
|
68
|
+
|
65
|
69
|
if response != 0:
|
66
|
|
- print
|
67
|
|
- print "No response pinging " + IP_DS1104Z
|
68
|
|
- print "Check network cables and settings."
|
69
|
|
- print "You should be able to ping the oscilloscope."
|
|
70
|
+ print
|
|
71
|
+ print "No response pinging " + IP_DS1104Z
|
|
72
|
+ print "Check network cables and settings."
|
|
73
|
+ print "You should be able to ping the oscilloscope."
|
70
|
74
|
|
71
|
75
|
# Open a modified telnet session
|
72
|
76
|
# The default telnetlib drops 0x00 characters,
|
73
|
77
|
# so a modified library 'telnetlib_receive_all' is used instead
|
74
|
78
|
tn = telnetlib_receive_all.Telnet(IP_DS1104Z, port)
|
75
|
|
-tn.write("*idn?") # ask for instrument ID
|
|
79
|
+tn.write("*idn?") # ask for instrument ID
|
76
|
80
|
instrument_id = tn.read_until("\n", 1)
|
77
|
81
|
|
78
|
82
|
# Check if instrument is set to accept LAN commands
|
79
|
83
|
if instrument_id == "command error":
|
80
|
|
- print instrument_id
|
81
|
|
- print "Check the oscilloscope settings."
|
82
|
|
- print "Utility -> IO Setting -> RemoteIO -> LAN must be ON"
|
83
|
|
- sys.exit("ERROR")
|
|
84
|
+ print instrument_id
|
|
85
|
+ print "Check the oscilloscope settings."
|
|
86
|
+ print "Utility -> IO Setting -> RemoteIO -> LAN must be ON"
|
|
87
|
+ sys.exit("ERROR")
|
84
|
88
|
|
85
|
89
|
# Check if instrument is indeed a Rigol DS1000Z series
|
86
|
90
|
id_fields = instrument_id.split(",")
|
87
|
91
|
if (id_fields[company] != "RIGOL TECHNOLOGIES") or \
|
88
|
|
- (id_fields[model][:3] != "DS1") or (id_fields[model][-1] != "Z"):
|
89
|
|
- print
|
90
|
|
- print "ERROR: No Rigol from series DS1000Z found at ", IP_DS1104Z
|
91
|
|
- sys.exit("ERROR")
|
|
92
|
+ (id_fields[model][:3] != "DS1") or (id_fields[model][-1] != "Z"):
|
|
93
|
+ print
|
|
94
|
+ print "ERROR: No Rigol from series DS1000Z found at ", IP_DS1104Z
|
|
95
|
+ sys.exit("ERROR")
|
92
|
96
|
|
93
|
97
|
print "Instrument ID:"
|
94
|
98
|
print instrument_id
|
|
@@ -104,10 +108,10 @@ buff = tn.read_until("\n", big_wait)
|
104
|
108
|
|
105
|
109
|
# Just in case the transfer did not complete in the expected time
|
106
|
110
|
while len(buff) < expected_len:
|
107
|
|
- tmp = tn.read_until("\n", small_wait)
|
108
|
|
- if len(tmp) == 0:
|
109
|
|
- break
|
110
|
|
- buff += tmp
|
|
111
|
+ tmp = tn.read_until("\n", small_wait)
|
|
112
|
+ if len(tmp) == 0:
|
|
113
|
+ break
|
|
114
|
+ buff += tmp
|
111
|
115
|
|
112
|
116
|
# Strip TMC Blockheader and terminator bytes
|
113
|
117
|
buff = buff[TMC_header_len:-terminator_len]
|