]> rtime.felk.cvut.cz Git - mf6xx.git/blob - src/hudaqlib/samples/special/ProbeDevices.c
Changed some directory names for easier understanding.
[mf6xx.git] / src / hudaqlib / samples / special / ProbeDevices.c
1 /* DaWrite.c:
2  *   This demo demonstrates extract information from all available devices.  
3  */
4 #include <stdio.h>
5 #include "hudaqlib.h"
6
7
8 int main(void)
9 {
10         HUDAQHANDLE h;
11         const HudaqResourceInfo *HRI;
12         int i,j;
13         double value;
14         int NoAnalogIn,NoDigitalIn,NoEncoders;
15         int dev=1;
16
17         /* Open first device found of any name. */
18         h = HudaqOpenDevice("",1,0);
19         if(h==0)
20         {printf("No HUDAQ device found\n"); return -1;}
21
22         while(h!=0)
23         {
24                 HRI = HudaqGetDeviceResources(h);
25                 printf("\nBus number %d, Slot number %d.",HRI->BusNumber, HRI->SlotNumber);
26                 printf("\nVendorID %Xh, DeviceID %Xh.",HRI->VendorID,HRI->DeviceID);
27
28                 for(i=0;i<HRI->NumMemResources;i++)
29                 {
30                         printf("\n Memory resource %d: Base:%Xh, Length:%Xh",
31                                         i, HRI->MemResources[i].Base, HRI->MemResources[i].Length);
32                 }
33
34                 for(i=0;i<HRI->NumIOResources;i++)
35                 {
36                         printf("\n IO resource %d: Base:%Xh, Length:%Xh",
37                                         i, HRI->IOResources[i].Base, HRI->IOResources[i].Length);
38                 }
39
40                 NoAnalogIn = HudaqGetParameter(h,0,HudaqAINUMCHANNELS);
41                 printf("\nAnalog channels %d", NoAnalogIn);
42                 for (i=0; i<NoAnalogIn; i++)
43                 {
44                         value = HudaqAIRead(h,i);
45                         printf("\n  Analog channel %d, value read %fV.", i, value);
46                 }
47
48                 NoDigitalIn = HudaqGetParameter(h,0,HudaqDINUMCHANNELS);
49                 printf("\nDigital channels %d", NoDigitalIn);
50                 for (i=0; i<NoDigitalIn; i++)
51                 {
52                         printf("\n  Digital input %d: %d",i,HudaqDIRead(h,i));
53                 }
54
55                 NoEncoders = HudaqGetParameter(h,0,HudaqEncNUMCHANNELS);
56                 printf("\nEncoder channels %d", NoEncoders);
57                 for (i=0; i<NoEncoders; i++)
58                 {
59                         printf("\n  Encoder value %d: %d",i,HudaqEncRead(h,i));
60                 }
61
62
63                 printf("\nIRQ counter: %g (%g)  press any key to continue...",
64                                 HudaqGetParameter(h,0,HudaqIRQ), HudaqGetParameter(h, 0, HudaqIRQ+1));
65
66                 HudaqCloseDevice(h);
67                 h = HudaqOpenDevice("",++dev,0);
68         }
69
70         //  HudaqSetParameter(h, 0, HudaqIRQ, 1);
71         i = HudaqGetParameter(h, 0, HudaqIRQ);
72         printf("\n");
73         return 0;
74 }