14
last set of data received. It is important that you wait
long enough for the data to arrive and this will be
determined by the baud rate and the number of
channels that you are sampling. It may well be that the
processing takes longer than the time required to wait,
but if you don’t have much processing to do, then you
will have to include some sort of timed wait in order to
avoid looking for data that hasn’t arrived.
4.2 T
UTORIAL
FLYBOX
_
TEST
.
C
Perhaps the easiest way to understand how to use the
software is to study an example. In the
bg/FlyBox
directory, the source code in
flybox_test.c
is a fairly
simple program that samples the FlyBox and prints the
values to the terminal.
There is a
Makefile
in the directory, and you should be
able to type:
% make flybox
to compile and link the executable
flybox.
4.2.1 Setup
As you go through this example, look at the file
flybox_test.c
and make sure that it matches this
document.
The low level library routines use a data structure,
defined as
bglv
, that is defined in
lv3.h
. (Note that this
file is in the
bg
directory.) This data structure must be
declared in the main file.
#include “lv3.h”
bglv bgdata;
// Main BG data structure
$
Note the use of C++ style comments //
which are not in the actual code, but are
used here to help readability.
Only the following members need to be set.
int analog_in;
// Analog input selector
int dig_in;
// Digital input selector
int baud;
// Baud rate selected
$
The remaining members of the structure
are computed in open_lv() and init_lv().
The
bglv
structure is passed to most of the library
functions in the call sequence. In order to collect data
from the FlyBox, the serial port needs to be opened by
Содержание FlyBox
Страница 1: ...FLYBOX HARDWARE MANUAL...
Страница 2: ......
Страница 10: ...10...
Страница 18: ...18...
Страница 22: ...22...
Страница 24: ...BG Systems Inc Palo Alto California USA Tel 650 858 2628 Fax 650 858 2685 URL www bgsystems com...