4 use Comedi qw( :Functions :Constants );
7 use constant AI_DEV => 0;
8 use constant AI_SUB => 0;
9 use constant AO_DEV => 0;
10 use constant AO_SUB => 1;
11 use constant N_SAMPLES => 100;
15 # create a channel list
17 @ch = ( CR_PACK(0, 0, AREF_GROUND));
19 $d = comedi_open($fn) || die "Can't open '$fn': " . comedi_error();
21 $freq = $opt_f || 1000;
23 # convert the requested frequency into a timer value
25 ($ret = comedi_get_timer($d, AI_SUB, $freq, $ticks, $actual_freq)) == 0 ||
26 die "Can't get timer: " . comedi_strerror($ret);
28 $buf = pack('d*', 100..(100+N_SAMPLES-1));
31 comedi_timed_1chan($d, AI_SUB, 0, 0, AREF_GROUND, 1000, N_SAMPLES, $buf)) == 0 ||
32 die "Analog input error ($ret): " . comedi_strerror(comedi_errno()) ;
34 foreach (unpack('d*', $buf)) {