|
1 #include <stdio.h> |
|
2 #include <string.h> |
|
3 |
|
4 #include <dbDefs.h> |
|
5 #include <registryFunction.h> |
|
6 #include <subRecord.h> |
|
7 #include <aSubRecord.h> |
|
8 #include <epicsExport.h> |
|
9 |
|
10 #include "pi_2_dht_read.h" |
|
11 |
|
12 int dbSubReadDHTDebug = 1; |
|
13 |
|
14 static long dbSubReadDHTInit(subRecord *precord) |
|
15 { |
|
16 if (dbSubReadDHTDebug) |
|
17 printf("Record %s called dbSubReadDHTInit(%p)\n", |
|
18 precord->name, (void*) precord); |
|
19 return 0; |
|
20 } |
|
21 |
|
22 static long dbSubReadDHTProcess(subRecord *precord) |
|
23 { |
|
24 float humidity, temperature; |
|
25 int type = 22; |
|
26 int ret; |
|
27 int pin = 7; |
|
28 |
|
29 if (dbSubReadDHTDebug) |
|
30 printf("Record %s called dbSubRreadHTProcess(%p)\n", |
|
31 precord->name, (void*) precord); |
|
32 |
|
33 ret = pi_2_dht_read(type, pin, &humidity, &temperature); |
|
34 printf(" ret : %d, humidity = %f, temperature = %f\n", ret, humidity, temperature); |
|
35 precord->val = (double)temperature; |
|
36 printf(" val = %lf\n", precord->val ); |
|
37 |
|
38 return 0; |
|
39 } |
|
40 |
|
41 /* Register these symbols for use by IOC code: */ |
|
42 |
|
43 epicsExportAddress(int, dbSubReadDHTDebug); |
|
44 epicsRegisterFunction(dbSubReadDHTInit); |
|
45 epicsRegisterFunction(dbSubReadDHTProcess); |
|
46 |