#!/usr/bin/perl

require "../oscpl/osc.pl";

osc_connect("infocalypse.al.cl.cam.ac.uk", 4500, "GPIB0::7::INSTR");
osc_write("*rst") || die "osc_write: $!";

osc_write(':channel:label analog1,"ICC"');
osc_write(':channel:label dig0,"CLK"');
osc_write(':channel:label dig1,"VCC"');
osc_write(':channel:label dig2,"RST"');
osc_write(':channel:label dig3,"I/O"');
osc_write(':channel:label dig4,"VPP"');

osc_write(':display:label ON');
osc_write(':display:order dig0,dig3,dig2,dig1');

# trigger falling edge i/o
# only when rst and vcc high
osc_write(':trigger:pattern +6,+6,DIG3,FALL');
# wait for trigger
osc_write(':trigger:mode normal,pattern');
# single pass
osc_write(':single');# single pass
osc_write(':single');

osc_write(':ANAL1:RANG +1.60000E-01;OFFS +4.12500E-02');
osc_write(':timebase:reference left');

osc_write(':waveform:points all');

#### wait for use to acknowledge sample -- should add wait loop here

print "hit return when ready\n";
<>;

osc_write(':waveform:format byte');

# pod1
osc_write(':waveform:source pod1');
osc_write(':waveform:data?');
($bytes, $data) = osc_read();
print "pod1: $bytes bytes\n";

# pod2
#osc_write(':waveform:source pod2');
#osc_write(':waveform:data?');
#($bytes, $data) = osc_read();
#print "pod2: $bytes bytes\n";

# analog1
osc_write(':waveform:source analog1');
osc_write(':waveform:data?');
($bytes, $data) = osc_read();
print "analog1: $bytes bytes\n";




