You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
97 lines
2.8 KiB
97 lines
2.8 KiB
14 years ago
|
.\" libxbee - a C library to aid the use of Digi's Series 1 XBee modules
|
||
|
.\" running in API mode (AP=2).
|
||
|
.\"
|
||
|
.\" Copyright (C) 2009 Attie Grande (attie@attie.co.uk)
|
||
|
.\"
|
||
|
.\" This program is free software: you can redistribute it and/or modify
|
||
|
.\" it under the terms of the GNU General Public License as published by
|
||
|
.\" the Free Software Foundation, either version 3 of the License, or
|
||
|
.\" (at your option) any later version.
|
||
|
.\"
|
||
|
.\" This program is distributed in the hope that it will be useful,
|
||
|
.\" but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||
|
.\" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||
|
.\" GNU General Public License for more details.
|
||
|
.\"
|
||
|
.\" You should have received a copy of the GNU General Public License
|
||
|
.\" along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||
|
.TH XBEE_GETPACKET 3 2009-11-01 "GNU" "Linux Programmer's Manual"
|
||
|
.SH NAME
|
||
|
xbee_hasanalog, xbee_getanalog
|
||
|
.SH SYNOPSIS
|
||
|
.B #include <xbee.h>
|
||
|
.sp
|
||
|
.BI "int xbee_hasanalog(xbee_pkt *" pkt ", int " sample ", int " input ");"
|
||
|
.sp
|
||
|
.BI "double xbee_getanalog(xbee_pkt *" pkt ", int " sample ", int " input ", double " Vref ");"
|
||
|
.ad b
|
||
|
.SH DESCRIPTION
|
||
|
The
|
||
|
.BR xbee_hasanalog ()
|
||
|
function will check the packet for the presence of an analog sample on the specified input.
|
||
|
.sp
|
||
|
The
|
||
|
.BR xbee_getanalog ()
|
||
|
function will read the packet and return the sample value for the specified analog input.
|
||
|
.sp
|
||
|
They both take 3 arguments, with the same purposes.
|
||
|
.sp
|
||
|
The argument
|
||
|
.I pkt
|
||
|
points to a packet that was previously retrieved with
|
||
|
.BR xbee_getpacket ()
|
||
|
.sp
|
||
|
The argument
|
||
|
.I sample
|
||
|
selects the sample within the packet to use.
|
||
|
.sp
|
||
|
The argument
|
||
|
.I input
|
||
|
specifies which input you are interested in testing.
|
||
|
.sp
|
||
|
.BR xbee_getanalog ()
|
||
|
also takes a fourth argument that allows you to provide a
|
||
|
.I Vref
|
||
|
value. This allows the function to convert the raw ADC value into a voltage for you.
|
||
|
.SH "RETURN VALUE"
|
||
|
The
|
||
|
.BR xbee_hasanalog ()
|
||
|
function will return
|
||
|
.B 1
|
||
|
if the provided packet has sample data for the specified input, otherwise
|
||
|
.BR 0 .
|
||
|
.sp
|
||
|
The
|
||
|
.BR xbee_getanalog ()
|
||
|
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
|
||
|
will be returned if the packet does not contain sample data.
|
||
|
.sp
|
||
|
.SH EXAMPLE
|
||
|
To read sample data from previously made connection:
|
||
|
.in +4n
|
||
|
.nf
|
||
|
#include <xbee.h>
|
||
|
xbee_pkt *pkt;
|
||
|
double Vref = 3.3;
|
||
|
if ((pkt = xbee_getpacket(con)) != NULL) {
|
||
|
if (xbee_hasanalog(pkt,0,0)) {
|
||
|
printf("A0 read %fv\\n",xbee_getanalog(pkt,0,0,Vref));
|
||
|
} else {
|
||
|
printf("No A0 data\\n");
|
||
|
}
|
||
|
free(pkt);
|
||
|
}
|
||
|
.fi
|
||
|
.in
|
||
|
.SH AUTHOR
|
||
|
Attie Grande <attie@attie.co.uk>
|
||
|
.SH "SEE ALSO"
|
||
|
.BR libxbee (3),
|
||
|
.BR xbee_pkt (3),
|
||
|
.BR xbee_getpacket (3),
|
||
|
.BR xbee_hasdigital (3),
|
||
|
.BR xbee_getdigital (3)
|