Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
<HTML><HEAD><TITLE>Manpage of XBEE_GETPACKET</TITLE>
</HEAD><BODY>
<H1>XBEE_GETPACKET</H1>
Section: Linux Programmer's Manual (3)<BR>Updated: 2009-11-01<BR><A HREF="#index">Index</A>
<A HREF="../index.html">Return to Main Contents</A><HR>
<A NAME="lbAB"> </A>
<H2>NAME</H2>
xbee_hasanalog, xbee_getanalog
<A NAME="lbAC"> </A>
<H2>SYNOPSIS</H2>
<B>#include <<A HREF="file:/usr/include/xbee.h">xbee.h</A>></B>
<P>
<B>int xbee_hasanalog(xbee_pkt *</B><I>pkt</I><B>,int </B><I>sample</I><B>, int </B><I>input</I><B>);</B>
<P>
<B>double xbee_getanalog(xbee_pkt *</B><I>pkt</I><B>,int </B><I>sample</I><B>, int </B><I>input</I><B>, double </B><I>Vref</I><B>);</B>
<A NAME="lbAD"> </A>
<H2>DESCRIPTION</H2>
The
<B>xbee_hasanalog</B>()
function will check the packet for the presence of an analog sample on the specified input.
<P>
The
<B>xbee_getanalog</B>()
function will read the packet and return the sample value for the specified analog input.
<P>
They both take 3 arguments, with the same purposes.
<P>
The argument
<I>pkt</I>
points to a packet that was previously retrieved with
<B>xbee_getpacket</B>()
<P>
The argument
<I>sample</I>
selects the sample within the packet to use.
<P>
The argument
<I>input</I>
specifies which input you are interested in testing.
<P>
<B>xbee_getanalog</B>()
also takes a fourth argument that allows you to provide a
<I>Vref</I>
value. This allows the function to convert the raw ADC value into a voltage for you.
<A NAME="lbAE"> </A>
<H2>RETURN VALUE</H2>
The
<B>xbee_hasanalog</B>()
function will return
<B>1</B>
if the provided packet has sample data for the specified input, otherwise
<B>0</B>.
<P>
The
<B>xbee_getanalog</B>()
function will return the raw ADC value (0 - 1023) if the provided packet has sample data for the specified input and Vref was given as zero.
If Vref was non-zero, then the return value will be the voltage read.
A
<B>-1</B>
will be returned if the packet does not contain sample data.
<P>
<A NAME="lbAF"> </A>
<H2>EXAMPLE</H2>
To read sample data from previously made connection:
<PRE>
#include <<A HREF="file:/usr/include/xbee.h">xbee.h</A>>
xbee_pkt *pkt;
double Vref = 3.3;
if ((pkt = xbee_getpacket(con)) != NULL) {
if (xbee_hasanalog(pkt,0,0)) {
printf("A0 read %fv,xbee_getanalog(pkt,0,0,Vref));
} else {
printf("No A0 data);
}
free(pkt);
}
</PRE>
<A NAME="lbAG"> </A>
<H2>AUTHOR</H2>
Attie Grande <<A HREF="mailto:attie@attie.co.uk">attie@attie.co.uk</A>>
<A NAME="lbAH"> </A>
<H2>SEE ALSO</H2>
<B><A HREF="../man3/libxbee.3.html">libxbee</A></B>(3),
<B><A HREF="../man3/xbee_pkt.3.html">xbee_pkt</A></B>(3),
<B><A HREF="../man3/xbee_getpacket.3.html">xbee_getpacket</A></B>(3),
<B><A HREF="../man3/xbee_hasdigital.3.html">xbee_hasdigital</A></B>(3),
<B><A HREF="../man3/xbee_getdigital.3.html">xbee_getdigital</A></B>(3)
<P>
<HR>
<A NAME="index"> </A><H2>Index</H2>
<DL>
<DT><A HREF="#lbAB">NAME</A><DD>
<DT><A HREF="#lbAC">SYNOPSIS</A><DD>
<DT><A HREF="#lbAD">DESCRIPTION</A><DD>
<DT><A HREF="#lbAE">RETURN VALUE</A><DD>
<DT><A HREF="#lbAF">EXAMPLE</A><DD>
<DT><A HREF="#lbAG">AUTHOR</A><DD>
<DT><A HREF="#lbAH">SEE ALSO</A><DD>
</DL>
<HR>
This document was created by
<A HREF="http://localhost/cgi-bin/man/man2html">man2html</A>,
using the manual pages.<BR>
Time: 00:08:23 GMT, March 30, 2011
</BODY>
</HTML>