Products > Test Equipment
Siglent SDS800X HD - Using SCPI with python via telnet to measure with 2 gates
(1/2) > >>
eTobey:
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?


--- Code: ---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()
--- End code ---

Output:

--- Code: ---Lese Daten...
Welcome to the SCPI instrument 'Siglent SDS824X HD'

>>



--- End code ---
dobsonr741:
The output does not match your code.
XiMMiX:
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.
eTobey:

--- Quote from: XiMMiX on April 25, 2024, 08:54:54 pm ---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.

--- End quote ---

This is actually not my kommando ;-). Just got that from the internet, and did not notice this. Should have actually looked more closer there.  ;D

Thank you  :-+
eTobey:
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):

--- Code: ---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()
--- End code ---
Navigation
Message Index
Next page
There was an error while thanking
Thanking...

Go to full version
Powered by SMFPacks Advanced Attachments Uploader Mod