![Yoctopuce Yocto-GPS Скачать руководство пользователя страница 66](http://html1.mh-extra.com/html/yoctopuce/yocto-gps/yocto-gps_user-manual_3415557066.webp)
// Hot-plug is easy: just check that the device is online
if(
latitude->
isOnline
())
{
// Use latitude->get_currentValue(), ...
}
Let's look at these lines in more details.
yocto_api.h et yocto_latitude.h
These two include files provide access to the functions allowing you to manage Yoctopuce modules.
yocto_api.h
must always be used,
yocto_latitude.h
is necessary to manage modules
containing a latitude sensor, such as Yocto-GPS.
yRegisterHub
The
yRegisterHub
function initializes the Yoctopuce API and indicates where the modules should
be looked for. When used with the parameter
"usb"
, it will use the modules locally connected to the
computer running the library. If the initialization does not succeed, this function returns a value
different from
YAPI_SUCCESS
and
errmsg
contains the error message.
yFindLatitude
The
yFindLatitude
function allows you to find a latitude sensor from the serial number of the
module on which it resides and from its function name. You can use logical names as well, as long
as you have initialized them. Let us imagine a Yocto-GPS module with serial number
YGNSSMK1-123456
which you have named "
MyModule
", and for which you have given the
latitude
function the name "
MyFunction
". The following five calls are strictly equivalent, as long as
"
MyFunction
" is defined only once.
YLatitude *latitude = yFindLatitude
(
"YGNSSMK1-123456.latitude"
)
;
YLatitude *latitude = yFindLatitude
(
"YGNSSMK1-123456.MyFunction"
)
;
YLatitude *latitude = yFindLatitude
(
"MyModule.latitude"
)
;
YLatitude *latitude = yFindLatitude
(
"MyModule.MyFunction"
)
;
YLatitude *latitude = yFindLatitude
(
"MyFunction"
)
;
yFindLatitude
returns an object which you can then use at will to control the latitude sensor.
isOnline
The
isOnline()
method of the object returned by
yFindLatitude
allows you to know if the
corresponding module is present and in working order.
get_latitude
The
get_latitude()
method of the object returned by
yFindGps
provides the latitude currently
measured by the Yocto-GPS. The value returned is a string, the format will vary according to the
Yocto-GPS configuration. To get a floating point value, no matter the configuartion, use the YLatitude
Class.
A real example
Launch your C++ environment and open the corresponding sample project provided in the directory
Examples/Doc-GettingStarted-Yocto-GPS
of the Yoctopuce library. If you prefer to work with your
favorite text editor, open the file
main.cpp
, and type
make
to build the example when you are
done.
In this example, you will recognize the functions explained above, but this time used with all side
materials needed to make it work nicely as a small demo.
#include "yocto_api.h"
#include "yocto_gps.h"
#include <iostream>
#include <stdlib.h>
using
namespace
std;
9. Using Yocto-GPS with C++
60
www.yoctopuce.com
Содержание Yocto-GPS
Страница 1: ...Yocto GPS User s guide...
Страница 2: ......
Страница 6: ...22 Characteristics 557 Blueprint 559 Index 561...
Страница 10: ...4 www yoctopuce com...
Страница 14: ...8 www yoctopuce com...
Страница 18: ...12 www yoctopuce com...
Страница 22: ...16 www yoctopuce com...
Страница 38: ...32 www yoctopuce com...
Страница 42: ...36 www yoctopuce com...
Страница 54: ...48 www yoctopuce com...
Страница 72: ...66 www yoctopuce com...
Страница 92: ...86 www yoctopuce com...
Страница 122: ...116 www yoctopuce com...
Страница 132: ...126 www yoctopuce com...
Страница 159: ...20 High level API Reference On failure throws an exception or returns a negative error code www yoctopuce com 153...
Страница 564: ...22 Characteristics 558 www yoctopuce com...
Страница 565: ......
Страница 566: ......