From f8cab16c4d5faae69d37d5916d1ff75b48852784 Mon Sep 17 00:00:00 2001 From: David Schleef Date: Tue, 10 Jul 2001 22:28:06 +0000 Subject: [PATCH] Perl demos moved from perl/ directory --- demo/perl/info.perl | 45 +++++++++++++++++++++++++++++++++++++++++++++ demo/perl/inp.pl | 2 ++ 2 files changed, 47 insertions(+) create mode 100755 demo/perl/info.perl create mode 100755 demo/perl/inp.pl diff --git a/demo/perl/info.perl b/demo/perl/info.perl new file mode 100755 index 0000000..093ae32 --- /dev/null +++ b/demo/perl/info.perl @@ -0,0 +1,45 @@ +#!/usr/bin/perl + +use Comedi qw( :SubdeviceTypes ); +use Comedi::Lib; + +sub help { + print STDERR "info \n"; + exit(0); +} + +%subdevice_types = ( + COMEDI_SUBD_UNUSED, 'unused', + COMEDI_SUBD_AI, 'analog input', + COMEDI_SUBD_AO, 'analog output', + COMEDI_SUBD_DI, 'digital input', + COMEDI_SUBD_DO, 'digital output', + COMEDI_SUBD_DIO, 'digital I/O', + COMEDI_SUBD_COUNTER, 'counter', + COMEDI_SUBD_TIMER, 'timer', + COMEDI_SUBD_MEMORY, 'memory', + COMEDI_SUBD_CALIB, 'calibration', + COMEDI_SUBD_PROC, 'processor', +); + +# +# Main Program +# + +help() if (@ARGV != 1); + +$it = comedi_open($ARGV[0]) || die "cannot open $ARGV[0]: $!"; + +printf("overall info:\n"); +printf(" version code: %d.%d.%d (0x%06x)\n", comedi_get_version($it), comedi_get_version_code($it)); +printf(" driver name: %s\n", comedi_get_driver_name($it)); +printf(" board name: %s\n", comedi_get_board_name($it)); +printf(" number of subdevices: %d\n", $n_subdevices = comedi_get_n_subdevices($it)); + +for ($i = 0; $i < $n_subdevices; $i++) { + printf("subdevice %d:\n", $i); + $type = comedi_get_subdevice_type($it, $i); + printf(" type: %d (%s)\n", $type, $subdevice_types{$type}); + printf(" number of channels: %d\n", comedi_get_n_channels($it, $i)); + printf(" max data value: %d\n", comedi_get_maxdata($it, $i, 0)); +} diff --git a/demo/perl/inp.pl b/demo/perl/inp.pl new file mode 100755 index 0000000..d838a0b --- /dev/null +++ b/demo/perl/inp.pl @@ -0,0 +1,2 @@ +#!/usr/bin/perl + -- 2.26.2