forked from hadmack/pyusbtmc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
get_data.py
executable file
·29 lines (26 loc) · 935 Bytes
/
get_data.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#!/usr/bin/env python
#
# PyUSBtmc
# get_data.py
#
# Copyright (c) 2011 Mike Hadmack
# This code is distributed under the MIT license
import numpy
import sys
from matplotlib import pyplot
from pyusbtmc import RigolScope
""" Capture data from Rigol oscilloscope and write to a file
usage: python save_channel.py <filename>
if filename is not given STDOUT will be used"""
try:
filename = sys.argv[1]
except:
filename = ""
if filename == "--help":
print """Usage: 1%s [filename]\n Reads both traces from oscilloscope and writes as ASCII tabular data to filename. If no filename is given the program outputs to STDOUT. STDOUT can be directed into a file or piped into another application. For example:\n 1%s myfile\n 1%s > myfile\n 1%s | ./plot_data.py"""%sys.argv[0]
sys.exit(1)
print filename
scope = RigolScope("/dev/usbtmc0")
scope.grabData()
scope.writeWaveformToFile(filename)
scope.close()