NSLog(@"usage: demo <serial_number>
NSLog(@"
demo
NSLog(@"
demo any
exit(1);
}
int main(int
argc,
{
NSError
*error;
if
(argc <
2) {
usage();
}
@autoreleasepool {
// Setup the API to use local USB devices
if([YAPI
RegisterHub:@"usb": &error] != YAPI_SUCCESS) {
NSLog(@"RegisterHub error:
return
1;
}
NSString
*target
YVoc
*vocsensor;
if
([target
isEqualToString:@"any"]) {
vocsensor
=
if
(vocsensor
NSLog(@"No module connected (check USB
return
1;
}
} else {
vocsensor
=
}
while(1) {
if(![vocsensor
NSLog(@"Module not connected (check identification and USB
break;
}
NSLog(@"VOC: %f
NSLog(@"
(press Ctrl-C to
[YAPI
Sleep:1000:NULL];
}
[YAPI
FreeAPI];
}
return
0;
}
19.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.
#import <Foundation/Foundation.h>
#import "yocto_api.h"
static void usage(const char
{
NSLog(@"usage: %s <serial or logical name>
exit(1);
}
int
main
(int
argc,
{
NSError
*error;
@autoreleasepool {
// Setup the API to use local USB devices
if([YAPI
RegisterHub:@"usb": &error] != YAPI_SUCCESS) {
NSLog(@"RegisterHub error:
return
1;
}
www.yoctopuce.com
");
<logical_name>");
const char
* argv[])
%@", [error localizedDescription]);
=
[NSString
stringWithUTF8String:argv[1]];
[YVoc
FirstVoc];
== NULL) {
[YVoc
FindVoc:[target stringByAppendingString:@".voc"]];
isOnline]) {
ppm\n", [vocsensor currentValue]);
exit)\n");
*exe)
const char
* argv[])
%@", [error localizedDescription]);
19. Utilisation du Yocto-VOC-V3 en Objective-C
(use any discovered
device)");
cable)");
[ON/OFF]\n", exe);
cable)\n");
151