]> rtime.felk.cvut.cz Git - mf6xx.git/blob - src/HuLinux-2.4.3/samples/test.c
da3b1716ccb3e8f779814b41222e4e47fa3cd81d
[mf6xx.git] / src / HuLinux-2.4.3 / samples / test.c
1 #include <stdio.h>
2 #include "hudaqlib.h"
3
4
5 int main(void)
6 {
7         HUDAQHANDLE h;
8         const HudaqResourceInfo *HRI;
9         int i,j;
10         double value;
11         int NoAnalogIn,NoDigitalIn;
12
13         //  h = HudaqOpenDevice("PCI1753",1,0);
14         //  h = HudaqOpenDevice("PCD7004",1,0);
15         //  h = HudaqOpenDevice("PCT7303B",1,0);
16         h = HudaqOpenDevice("MF614",1,0);
17         if(h==0)
18         {
19                 h = HudaqOpenDevice("MF624",1,0);
20                 if(h==0)
21                 {printf("No HUDAQ device found\n"); return -1;}
22         }  
23
24         HRI = HudaqGetDeviceResources(h);
25         for(i=0;i<HRI->NumMemResources;i++)
26         {
27                 printf("\n Memory resource %d: Base:%Xh, Length:%Xh",
28                                 i, HRI->MemResources[i].Base, HRI->MemResources[i].Length);
29         }
30         for(i=0;i<HRI->NumIOResources;i++)
31         {
32                 printf("\n IO resource %d: Base:%Xh, Length:%Xh",
33                                 i, HRI->IOResources[i].Base, HRI->IOResources[i].Length);
34         }
35
36
37         NoAnalogIn = HudaqGetParameter(h,0,HudaqAINUMCHANNELS);
38         printf("\nAnalog channels %d", NoAnalogIn);
39         for (i=0; i<NoAnalogIn; i++)
40         {
41                 value = HudaqAIRead(h,i);
42                 printf("\n Analog channel %d, value read %fV.", i, value);
43         }
44
45         NoDigitalIn = HudaqGetParameter(h,0,HudaqDINUMCHANNELS);
46         printf("\nDigital channels %d", NoDigitalIn);
47         for (i=0; i<NoDigitalIn; i++)
48         {
49                 printf("\n Digital input %d: %d",i,HudaqDIRead(h,i));
50         }
51
52         HudaqCloseDevice(h);
53         printf("\n");
54         return 0;
55 }