Created
October 20, 2022 08:19
-
-
Save tai/408053a0955bf1712a5809240aa5544f to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
import time | |
import usbtmc | |
def capture(fmt='png'): | |
tmc = usbtmc.Instrument(0x1ab1, 0x04ce) | |
# magic initialization for DS1000Z | |
# | |
# - usbtmc.write_raw() does not work for now | |
# - DS1000Z dies with INITIATE_CLEAR sent by clear() call in open() | |
#tmc.write_raw(b'*IDN?') | |
open("/dev/usbtmc2", "w").write('*IDN?') # /dev/usbtmc<N> hardcoded for testing | |
tmc.write(':run') | |
time.sleep(1) # run for a while to get a trace on screen | |
tmc.write(':stop') | |
time.sleep(0.1) | |
tmc.write(':disp:data? on,off,%s' % fmt) | |
time.sleep(1) # needs to wait long enough | |
buf = tmc.read_raw(1024 * 1024) | |
img = buf[11:-4] | |
return img | |
if __name__ == '__main__': | |
img = capture('png') | |
open('rigol.png', 'wb').write(img) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment