updated usbdux firmware from Bernd Porr:
[comedilib.git] / perl / info.perl
1
2 use Comedi qw( :SubdeviceTypes );
3 use Comedi::Lib;
4
5 sub help {
6     print STDERR "info </dev/comediN>\n";
7     exit(0);
8 }
9
10 %subdevice_types = (
11     COMEDI_SUBD_UNUSED,  'unused',
12     COMEDI_SUBD_AI,      'analog input',
13     COMEDI_SUBD_AO,      'analog output',
14     COMEDI_SUBD_DI,      'digital input',
15     COMEDI_SUBD_DO,      'digital output',
16     COMEDI_SUBD_DIO,     'digital I/O',
17     COMEDI_SUBD_COUNTER, 'counter',
18     COMEDI_SUBD_TIMER,   'timer',
19     COMEDI_SUBD_MEMORY,  'memory',
20     COMEDI_SUBD_CALIB,   'calibration',
21     COMEDI_SUBD_PROC,    'processor',
22 );
23
24 #
25 # Main Program
26 #
27
28 help() if (@ARGV != 1);
29
30 $it = comedi_open($ARGV[0]) || die "cannot open $ARGV[0]: $!";
31
32 printf("overall info:\n");
33 printf("  version code: %d.%d.%d (0x%06x)\n", comedi_get_version($it), comedi_get_version_code($it));
34 printf("  driver name: %s\n", comedi_get_driver_name($it));
35 printf("  board name: %s\n", comedi_get_board_name($it));
36 printf("  number of subdevices: %d\n", $n_subdevices = comedi_get_n_subdevices($it));
37
38 for ($i = 0; $i < $n_subdevices; $i++) {
39     printf("subdevice %d:\n", $i);
40     $type = comedi_get_subdevice_type($it, $i);
41     printf("  type: %d (%s)\n", $type, $subdevice_types{$type});
42     printf("  number of channels: %d\n", comedi_get_n_channels($it, $i));
43     printf("  max data value: %d\n", comedi_get_maxdata($it, $i, 0));
44 }