#! /usr/bin/env python3 import usb.core import usb.util def send(cmd,clen=0x100,cto=None): # address taken from results of print(dev): ENDPOINT 0x1: Bulk OUT ret=dev.write(1,cmd) # address taken from results of print(dev): ENDPOINT 0x81: Bulk IN result = (dev.read(0x81,clen,cto)) return result # ENDPOINT 0x81: Bulk IN =============================== # bLength : 0x7 (7 bytes) # bDescriptorType : 0x5 Endpoint # bEndpointAddress : 0x81 IN # bmAttributes : 0x2 Bulk # wMaxPacketSize : 0x40 (64 bytes) # bInterval : 0x20 # ENDPOINT 0x1: Bulk OUT =============================== # bLength : 0x7 (7 bytes) # bDescriptorType : 0x5 Endpoint # bEndpointAddress : 0x1 OUT # bmAttributes : 0x2 Bulk # wMaxPacketSize : 0x40 (64 bytes) # bInterval : 0x20 dev = usb.core.find(idVendor=0x5345, idProduct=0x1234) if dev is None: raise ValueError('Owon HDS200X scope not found; please set to HID mode and reconnect via USB.') exit() # print(dev) dev.set_configuration() try: print(send('*IDN?').tobytes().decode('utf-8')) resp = send(':FUNCtion?').tobytes().decode('utf-8') print(resp) resp = send(':FUNCtion:FREQuency?').tobytes().decode('utf-8') print(resp) resp = send(':FUNCtion:AMPLitude?').tobytes().decode('utf-8') print(resp) #resp = send(':FUNCtion RAMP').tobytes().decode('utf-8') resp = send(':FUNCtion SINE').tobytes().decode('utf-8') print(resp) except: print("An exception occurred") usb.util.dispose_resources(dev) dev.reset() usb.util.dispose_resources(dev) dev.reset()