Contrôle De La Partie Module - Yoctopuce Yocto-4-20mA-Tx Mode D'emploi

Table des Matières

Publicité

9. Utilisation du Yocto-4-20mA-Tx en C++
}
if
(loopPower
cout
<<
"Insufficient voltage on current loop"
return 1;
}
cout
<<
"current loop set to "
} else {
cout
<<
"Module not connected (check identification and USB cable)"
}
YAPI::FreeAPI();
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 char
{
cout
<<
"usage: "
exit(1);
}
int main(int
argc,
{
string
errmsg;
// Setup the API to use local USB devices
if(YAPI::RegisterHub("usb",
cerr
<<
"RegisterHub error: "
return 1;
}
if(argc
< 2)
usage(argv[0]);
YModule
*module
if (module->isOnline()) {
if
(argc
> 2) {
if (string(argv[2]) == "ON")
module->set_beacon(Y_BEACON_ON);
else
module->set_beacon(Y_BEACON_OFF);
}
cout
<<
"serial:
cout
<<
"logical name: "
cout
<<
"luminosity:
cout
<<
"beacon:
if (module->get_beacon() == Y_BEACON_ON)
cout
<<
"ON"
else
cout
<<
"OFF"
cout
<<
"upTime:
cout
<<
"USB current:
cout
<<
"Logs:"
} else {
cout
<< argv[1] <<
<< endl;
}
YAPI::FreeAPI();
return 0;
56
== Y_LOOPPOWER_LOWPWR) {
<<
value
*exe)
<<
exe
<<
" <serial or logical name> [ON/OFF]"
const char
* argv[])
errmsg) != YAPI::SUCCESS) {
<<
errmsg
= YModule::FindModule(argv[1]);
"
<< module->get_serialNumber() << endl;
<< module->get_logicalName() << endl;
"
<< module->get_luminosity() << endl;
";
<< endl;
<< endl;
"
<< module->get_upTime() /
"
<< module->get_usbCurrent() <<
<<
endl
<< module->get_lastLogs() << endl;
" not connected (check identification and USB cable)"
<< endl;
<<
" mA"
<< endl;
<< endl;
// use serial or logical name
1000
<<
" sec"
" mA"
<< endl;
<< endl;
<< endl;
<< endl;
www.yoctopuce.com

Publicité

Table des Matières
loading

Table des Matières