#include <iostream>
#include <stdlib.h>
using namespace
std;
static void usage(void)
{
cout
<<
"usage: demo <serial_number>
cout
<<
"
cout
<<
"
endl;
u64
now = yGetTickCount();
while
(yGetTickCount()-now<3000);
exit(1);
}
int main(int
argc,
{
string
errmsg;
string
target;
YLed
*led;
string
on_off;
if(argc <
3) {
usage();
}
target
=
(string)
on_off =
(string)
// Setup the API to use local USB devices
if(yRegisterHub("usb",
cerr
<<
"RegisterHub error: "
return
1;
}
if(target ==
"any"){
led =
yFirstLed();
}else{
led =
yFindLed(target + ".led");
}
if
(led &&
led->isOnline()) {
led->set_power(on_off ==
} else {
cout
<<
"Module not connected (check identification and USB cable)"
}
return
0;
}
9.2. Contrôle de la partie module
Chaque module peut-être contrôlé d'une manière similaire, vous trouverez ci dessous un simple
programme d'exemple affichant les principaux paramètres d'un module et permettant d'activer la
balise de localisation.
#include <iostream>
#include <stdlib.h>
#include "yocto_api.h"
using namespace
std;
static void usage(const
{
cout
<<
"usage: "
exit(1);
}
int main(int
argc,
{
string
errmsg;
www.yoctopuce.com
demo <logical_name> [ on | off ]"
demo any [ on | off ]
// dirty active wait loop
const
char
*
argv[])
argv[1];
argv[2];
errmsg)
!=
YAPI_SUCCESS) {
<< errmsg << endl;
"on"
? Y_POWER_ON : Y_POWER_OFF);
char
*exe)
<< exe <<
" <serial or logical name> [ON/OFF]"
const
char
*
argv[])
[ on | off ]"
<< endl;
<< endl;
(use any discovered device)"
9. Utilisation du Yocto-Demo en C++
<<
<< endl;
<< endl;
45