Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- """
- Version 1.0a, 29 Jun 13
- """
- import time, sys, array, string
- import rigol, usb.core, usb.util
- ds2072 = rigol.Scope(VID = 0x1ab1, PID = 0x04b0, EP_OUT=0x01, EP_IN=0x86)
- code = "LLLLLLLRLGLLDSDSA9LLLLLLLLLL"
- def main():
- try:
- # wait for the scope to come online
- ret = ds2072.findDevice()
- while (ret == False):
- print("Looking for device.")
- time.sleep(5)
- ret = ds2072.findDevice()
- print ("Device found.")
- # if you want to read the setup from a file instead of the
- # scope itself, use the following lines and comment out the
- # section of code below reading back the scope's setup
- """
- with open('example.stp', 'rd') as f:
- read_data = ":SYST:SET #9000002579" + f.read()
- """
- print ("Getting setup data.")
- # get the setup data from the scope
- ds2072.write(":SYSTem:SETup?")
- response = ds2072.trim_response(ds2072.read(no_of_bytes=500))
- read_data = ":SYST:SET " + str(response)
- while (len(response) == 500):
- response = response = ds2072.trim_response(ds2072.read(no_of_bytes=500))
- read_data += str(response)
- # apply the code
- print("Applying code:" + code)
- ds2072.write(":SYSTem:OPTion:INSTall " + code + "\n")
- time.sleep(2)
- print ("Writing back setup data.")
- # send back the setup data
- ds2072.write(read_data)
- # This exception will be caused by the USB device
- # going off-line (e.g. being unplugged).
- # It may also be cause by a timeout, usually surrounding
- # a device not having the bus closed on exit.
- except usb.core.USBError:
- pass
- ds2072.close()
- if __name__ == '__main__':
- main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement