
static
void
usage
(void)
{
cout
<<
"usage: demo <serial_number> "
<<
endl
;
cout
<<
" demo <logical_name>"
<<
endl
;
cout
<<
" demo any (use any discovered device)"
<<
endl
;
u64
now = yGetTickCount
()
;
while
(
yGetTickCount
()
- now <
3000
)
{
// wait 3 sec to show the message
}
exit
(
1
)
;
}
int
main
(
int
argc,
const
char
* argv
[])
{
string
errmsg, target;
YGps *gps;
if
(
argc <
2
)
{
usage
()
;
}
target =
(
string
)
argv
[
1
]
;
// Setup the API to use local USB devices
if
(
yRegisterHub
(
"usb"
, errmsg
)
!= YAPI_SUCCESS
)
{
cerr
<<
"RegisterHub error: "
<< errmsg <<
endl
;
return
1
;
}
if
(
target ==
"any"
)
{
gps = yFirstGps
()
;
if
(
gps ==
NULL
)
{
cout
<<
"No module connected (check USB cable)"
<<
endl
;
return
1
;
}
}
else
{
gps = yFindGps
(
".gps"
)
;
}
while
(
1
)
{
if
(
!gps->
isOnline
())
{
cout
<<
"Module not connected (check identification and USB cable)"
;
break
;
}
if
(
!gps->
get_isFixed
())
{
cout
<<
"Fixing.."
<<
endl
;
}
else
{
cout
<< gps->
get_latitude
()
<<
" "
<< gps->
get_longitude
()
<<
endl
;
}
cout
<<
" (press Ctrl-C to exit)"
<<
endl
;
ySleep
(
1000
, errmsg
)
;
}
yFreeAPI
()
;
return
0
;
}
9.2. Control of the module part
Each module can be controlled in a similar manner, you can find below a simple sample program
displaying the main parameters of the module and enabling you to activate the localization beacon.
#include <iostream>
#include <stdlib.h>
#include "yocto_api.h"
using
namespace
std;
static
void
usage
(const
char
*exe
)
{
cout
<<
"usage: "
<< exe <<
" <serial or logical name> [ON/OFF]"
<<
endl
;
exit
(
1
)
;
}
9. Using Yocto-GPS with C++
www.yoctopuce.com
61
Summary of Contents for Yocto-GPS
Page 1: ...Yocto GPS User s guide...
Page 2: ......
Page 6: ...22 Characteristics 557 Blueprint 559 Index 561...
Page 10: ...4 www yoctopuce com...
Page 14: ...8 www yoctopuce com...
Page 18: ...12 www yoctopuce com...
Page 22: ...16 www yoctopuce com...
Page 38: ...32 www yoctopuce com...
Page 42: ...36 www yoctopuce com...
Page 54: ...48 www yoctopuce com...
Page 72: ...66 www yoctopuce com...
Page 92: ...86 www yoctopuce com...
Page 122: ...116 www yoctopuce com...
Page 132: ...126 www yoctopuce com...
Page 564: ...22 Characteristics 558 www yoctopuce com...
Page 565: ......
Page 566: ......