![Yoctopuce Yocto-GPS Скачать руководство пользователя страница 107](http://html1.mh-extra.com/html/yoctopuce/yocto-gps/yocto-gps_user-manual_3415557107.webp)
gps = YGps.
FirstGps
()
;
if
(
gps ==
null
)
{
System
.
out
.
println
(
"No module connected (check USB cable)"
)
;
System
.
exit
(
1
)
;
}
}
else
{
gps = YGps.
FindGps
(
args
[
0
]
+
".temperature"
)
;
}
while
(
true
)
{
try
{
if
(
gps.
get_isFixed
()
!= YGps.
ISFIXED_TRUE
)
{
System
.
out
.
println
(
"fixing..."
)
;
}
else
{
System
.
out
.
println
(
gps.
get_latitude
()
+
" "
+ gps.
get_longitude
())
;
}
System
.
out
.
println
(
" (press Ctrl-C to exit)"
)
;
YAPI.
Sleep
(
1000
)
;
}
catch
(
YAPI_Exception ex
)
{
System
.
out
.
println
(
"Module not connected (check identification and USB
cable)"
)
;
break
;
}
}
YAPI.
FreeAPI
()
;
}
}
15.3. 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.
import
com.yoctopuce.YoctoAPI.*
;
import
java.util.logging.Level
;
import
java.util.logging.Logger
;
public
class
Demo
{
public
static
void
main
(
String
[]
args
)
{
try
{
// setup the API to use local VirtualHub
YAPI.
RegisterHub
(
"127.0.0.1"
)
;
}
catch
(
YAPI_Exception ex
)
{
System
.
out
.
println
(
"Cannot contact VirtualHub on 127.0.0.1 ("
+
ex.
getLocalizedMessage
()
+
")"
)
;
System
.
out
.
println
(
"Ensure that the VirtualHub application is running"
)
;
System
.
exit
(
1
)
;
}
System
.
out
.
println
(
"usage: demo [serial or logical name] [ON/OFF]"
)
;
YModule module;
if
(
args.
length
==
0
)
{
module = YModule.
FirstModule
()
;
if
(
module ==
null
)
{
System
.
out
.
println
(
"No module connected (check USB cable)"
)
;
System
.
exit
(
1
)
;
}
}
else
{
module = YModule.
FindModule
(
args
[
0
])
;
// use serial or logical name
}
try
{
if
(
args.
length
>
1
)
{
if
(
args
[
1
]
.
equalsIgnoreCase
(
"ON"
))
{
module.
setBeacon
(
YModule.
BEACON_ON
)
;
}
else
{
module.
setBeacon
(
YModule.
BEACON_OFF
)
;
}
}
15. Using the Yocto-GPS with Java
www.yoctopuce.com
101
Содержание 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: ......