Hi,
i have made a little script to connect to the scope, and read data via SCPI. I have looked at the traffic, and i see, that there is data coming in from the SCPI command (see picture). But it is not printed. But interestingly, the welcome message got printed.
Anyone has an idea?
import telnetlib
class POP3Telnet:
def __init__(self, host, port):
self.tel = telnetlib.Telnet(host, port)
#self.lese_daten()
def close(self):
self.tel.close()
def lese_daten(self):
return self.tel.read_until(b"\n", 1.0)
def kommando(self, kom):
self.tel.write(("{}\r\n".format(kom)).encode())
return self.lese_daten()
host = "169.254.143.210"
port = 5024
user = ""
passwd = ""
pop = POP3Telnet(host, port)
#pop.kommando("USER {}".format(user))
#pop.kommando("PASS {}".format(passwd))
#
print("Lese Daten...")
print(pop.lese_daten().decode())
print(pop.lese_daten().decode())
pop.kommando(":MEAS:ADV:P2:STAT? ALL;")
print(pop.lese_daten().decode())
pop.kommando("QUIT")
print(pop.lese_daten().decode())
pop.close()
Output:
Lese Daten...
Welcome to the SCPI instrument 'Siglent SDS824X HD'
>>
The output does not match your code.
your kommando function doesn't just send the command to the scope, it also returns the first reply by running self.lese_daten().
You're not doing anything with the data the kommando function returns.
your kommando function doesn't just send the command to the scope, it also returns the first reply by running self.lese_daten().
You're not doing anything with the data the kommando function returns.
This is actually not my kommando ;-). Just got that from the internet, and did not notice this. Should have actually looked more closer there.
Thank you
I have now finished my script an have changee the title of this topic accordingly:
This is a script to measure certain values with 2 gates (Updates might follow):
import telnetlib
import time
class POP3Telnet:
def __init__(self, host, port):
self.tel = telnetlib.Telnet(host, port)
#self.lese_daten()
def close(self):
self.tel.close()
def lese_daten(self):
return self.tel.read_until(b"\n", 2)
def kommando(self, kom):
self.tel.write(("{}\r\n".format(kom)).encode())
time.sleep(0.02) # May need adjusting
return
host = "169.254.143.210"
port = 5024
user = ""
passwd = ""
gate_1A = -35
gate_1B = 35
gate_2A = 400
gate_2B = 8000
pop = POP3Telnet(host, port)
# Read and discard useless Messages
pop.lese_daten().decode()
pop.lese_daten().decode()
pop.kommando(":HISTOR:FRAM 1")
for x in range(0,80000):
x = x + 1 # starts from 0
# print time
pop.kommando(":HISTOR:TIME?")
print("{} {} ".format(x, pop.lese_daten().decode().strip('\n').replace(' ','')), end="")
# Measure first gate measure no. 2
pop.kommando(":MEAS:GATE:GA {}E-9".format(gate_1A))
pop.kommando(":MEAS:GATE:GB {}E-9".format(gate_1B))
pop.kommando(":MEAS:ADV:P2:VAL?")
data = pop.lese_daten().decode().strip('\n')
if data.find('*') >= 0:
print("-", end="")
else:
print(float(data), end="")
print(" ", end="")
# Measure second gate measure no. 1
pop.kommando(":MEAS:GATE:GB {}E-9".format(gate_2B)) # MOVE FURTHEST GATE FIRST! A cant overtake B !
pop.kommando(":MEAS:GATE:GA {}E-9".format(gate_2A))
pop.kommando(":MEAS:ADV:P1:VAL?")
data = pop.lese_daten().decode().strip('\n')
if data.find('*') >= 0:
print("-", end="")
else:
print(float(data), end="")
print("")
# Move on in frames
pop.kommando(":HISTOR:FRAM {}".format(x+1)) # set next frame
pop.kommando(":HISTOR:FRAM?")
if float(pop.lese_daten().decode()) == x: # no more frames!
break
pop.kommando("QUIT")
pop.close()
This is a good way to achieve some functions that cannot be done by oscilloscope through python.
It takes a long time for oscilloscope to add functions, while scripting code takes a short time and is very flexible.
Others can also add their own needs and scripts.
This is a good way to achieve some functions that cannot be done by oscilloscope through python.
It takes a long time for oscilloscope to add functions, while scripting code takes a short time and is very flexible.
Others can also add their own needs and scripts.
While not familiar with python, SCPI and the scope, it took me like 4 hours. It might be flexible, but it is very sloooow. About 2 measurments per second.
Maybe SCPI speed can be improved?
While not familiar with python, SCPI and the scope, it took me like 4 hours. It might be flexible, but it is very sloooow. About 2 measurments per second.
Maybe SCPI speed can be improved?
The first time is 4 hours, when you are familiar with python, you may only need half an hour. I think the main time consumption is the processing time of the oscilloscope after sending multiple commands, so the speed of 2 times per second is okay, you can executing the script When sleep.
sending multiple commands, so the speed of 2 times per second is okay, you can executing the script When sleep.
I could not... As it is only 2 meters away from my bed, it its pretty loud and uses a lot of power. It should be able to do more than 2 times per second for this powerconsumption.