forked from Ratfink/ds1054z-screen-capture
-
Notifications
You must be signed in to change notification settings - Fork 2
/
e36312a-capture
executable file
·60 lines (49 loc) · 1.7 KB
/
e36312a-capture
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
#!/usr/bin/env python3
from telnetlib_receive_all import Telnet
from keysight import *
from common import *
import time
import sys
import os
INSTRUMENT_PORT = 5025
# Check command line parameters
script_name = os.path.basename(sys.argv[0])
filepath = os.getcwd()
def print_help():
global script_name
print ("Usage:")
print (" " + script_name + " [psu_ip]")
print ()
print ("Usage examples:")
print (" " + script_name)
print (" " + script_name + " 192.168.1.3")
print ()
print ("This program captures the screen of the power supply")
print (" as a BMP file with a timestamp in the file name.")
print ()
if len(sys.argv) == 1:
INSTRUMENT_IP = find_arp(KEYSIGHT_OUI)
if INSTRUMENT_IP is None:
print_help()
sys.exit("Error: Hardware address not found in ARP table, IP will have to be specified manually.")
elif len(sys.argv) == 2:
INSTRUMENT_IP = sys.argv[1]
else:
print_help()
sys.exit("Error: Wrong command line parameters.")
try:
tn = Telnet(INSTRUMENT_IP, INSTRUMENT_PORT)
except OSError as ex:
sys.exit('Connection error: ' + str(ex))
instrument_id = command(tn, "*IDN?").decode().rstrip()
tn.close()
instrument_manufacturer,instrument_model,instrument_serial,instrument_fw = instrument_id.split(",")
print("Found %s %s at %s" % (instrument_manufacturer, instrument_model, INSTRUMENT_IP))
print("Downloading screenshot..")
timestamp = time.strftime("%Y-%m-%d_%H:%M:%S", time.localtime())
filename = "E36312A_%s.bmp" % (timestamp)
file_length = e36312a_screenshot(INSTRUMENT_IP, "%s/%s" % (filepath, filename))
if file_length is not None:
print("Saved screenshot to %s" % (filename))
else:
print("Download failed.")