update the module. The application is responsible for downloading and installing the new firmware
while preserving the module parameters.
Please note: while the firmware is being updated, the module restarts several times. Android
interprets a USB device reboot as a disconnection and reconnection of the USB device and asks the
authorization to use the USB port again. The user must click on
OK
for the update process to end
successfully.
19.4. Updating the firmware with the programming library
If you need to integrate firmware updates in your application, the libraries offer you an API to update
your modules.
1
Saving and restoring parameters
The
get_allSettings()
method returns a binary buffer enabling you to save a module
persistent parameters. This function is very useful to save the network configuration of a YoctoHub
for example.
YWireless wireless = YWireless.
FindWireless
(
"reference"
)
;
YModule m = wireless.
get_module
()
;
byte
[]
default_config = m.
get_allSettings
()
;
saveFile
(
"default.bin"
, default_config
)
;
...
You can then apply these parameters to other modules with the
set_allSettings()
method.
byte
[]
default_config = loadFile
(
"default.bin"
)
;
YModule m = YModule.
FirstModule
()
;
while
(
m !=
null
)
{
if
(
m.
get_productName
()
==
"YoctoHub-Wireless"
)
{
m.
set_allSettings
(
default_config
)
;
}
m = m.
next
()
;
}
Finding the correct firmware
The first step to update a Yoctopuce module is to find which firmware you must use. The
checkFirmware(path, onlynew)
method of the YModule object does exactly this. The
method checks that the firmware given as argument (
path
) is compatible with the module. If the
onlynew
parameter is set, this method checks that the firmware is more recent than the version
currently used by the module. When the file is not compatible (or if the file is older than the installed
version), this method returns an empty string. In the opposite, if the file is valid, the method returns a
file access path.
The following piece of code checks that the
c:\tmp\METEOMK1.17328.byn
is compatible with
the module stored in the
m
variable .
YModule m = YModule.
FirstModule
()
;
...
...
string
path =
"c:
\\
tmp
\M
ETEOMK1.17328.byn"
;
string
newfirm = m.
checkFirmware
(
path,
false
)
;
if
(
newfirm !=
""
)
{
Console
.
WriteLine
(
"firmware "
+ n
" is compatible"
)
;
}
...
1
The JavaScript, Node.js, and PHP libraries do not yet allow you to update the modules. These functions will be available in
a next build.
19. Firmware Update
126
www.yoctopuce.com
Содержание Yocto-RangeFinder
Страница 1: ...Yocto RangeFinder User s guide...
Страница 2: ......
Страница 18: ...12 www yoctopuce com...
Страница 26: ...20 www yoctopuce com...
Страница 42: ...36 www yoctopuce com...
Страница 70: ...gcc lyocto lm lpthread lusb 1 0 lstdc 10 Using Yocto RangeFinder with C 64 www yoctopuce com...
Страница 90: ...84 www yoctopuce com...
Страница 120: ...114 www yoctopuce com...
Страница 130: ...124 www yoctopuce com...
Страница 158: ...21 High level API Reference On failure throws an exception or returns a negative error code 152 www yoctopuce com...
Страница 484: ...478 www yoctopuce com...
Страница 488: ...482 www yoctopuce com...
Страница 490: ...23 Characteristics 484 www yoctopuce com...
Страница 491: ......
Страница 492: ......