]> rtime.felk.cvut.cz Git - mf6xx.git/blob - src/HuLinux-2.4.3/samples/test.c
731cf555b9215273565ae39225ae7b7fa3d092eb
[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                 //printf("h = %d\n", h);
21                 if (h == 0) {
22                         printf("No HUDAQ device found\n");
23                         return -1;
24                 }
25         }  
26
27         HRI = HudaqGetDeviceResources(h);
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         for(i = 0; i < HRI->NumIOResources; i ++)
34         {
35                 printf("\n IO resource %d: Base: %Xh, Length: %Xh",
36                                 i, HRI->IOResources[i].Base, HRI->IOResources[i].Length);
37         }
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         HudaqCloseDevice(h);
56         printf("\n");
57         return 0;
58 }