コード例 #1
0
scope = Oscilloscope()
scope_channel = 1
if not scope.is_attached():
    print "No scope detected! Check connection!"
    sys.exit(1)
print "Setting up scope!"
# TODO: Are all these extra calls for setup needed?
scope.set_voltage_division(100, 200)
scope.set_voltage_division(1, 6)
scope.set_sampling_rate(500)
samplerate = 1000 * 1000
scope.set_sampling_rate(24)
scope.setup_dso_cal_level()
cal_level = scope.get_calibration_data()
scope.set_dso_calibration(cal_level)

data = []
total = 0

print "Reading data from scope!"
for x in range(0, 10):
    print x
    data.append(
        scope.read_data_from_scope(1047550, raw_data=True)[scope_channel - 1])
    total += len(data[x])

filename = "test.wav"
print "Writing out data from scope to {}".format(filename)
with open(filename, "wb") as wf:
    wf.write("RIFF")
コード例 #2
0
scope = Oscilloscope()
scope_channel = 1
if not scope.is_attached():
    print "No scope detected! Check connection!"
    sys.exit(1)
print "Setting up scope!"
# TODO: Are all these extra calls for setup needed?
scope.set_voltage_division(100, 200)
scope.set_voltage_division(1, 6)
scope.set_sampling_rate(500)
samplerate = 1000 * 1000
scope.set_sampling_rate(24)
scope.setup_dso_cal_level()
cal_level = scope.get_calibration_data()
scope.set_dso_calibration(cal_level)

data = []
total = 0

print "Reading data from scope!"
for x in range(0, 10):
    print x
    data.append(scope.read_data_from_scope(1047550, raw_data=True)[scope_channel-1])
    total += len(data[x])

filename = "test.wav"
print "Writing out data from scope to {}".format(filename)
with open(filename, "wb") as wf:
    wf.write("RIFF")
    wf.write(pack("<L", 44 + total - 8))