Télécharger Imprimer la page

Contrôle De La Partie Module - Yoctopuce Yocto-Temperature-IR Mode D'emploi

Publicité

#import <Foundation/Foundation.h>
#import "yocto_api.h"
#import "yocto_temperature.h"
static void
usage(void)
{
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
YTemperature
*tsensor, *tsensor2;
if
([target
isEqualToString:@"any"]) {
tsensor
=
[YTemperature
if
(tsensor
NSLog(@"No module connected (check USB
return
1;
}
target
=
[[tsensor
}
tsensor
=
[YTemperature
@".temperature1"]];
tsensor2
=
[YTemperature
@".temperature2"]];
while(1) {
if(![tsensor
NSLog(@"Module not connected (check identification and USB
break;
}
NSLog(@"Ambiant temperature
NSLog(@"Infrared temperature : %f
NSLog(@"
(press Ctrl-C to
[YAPI
Sleep:1000:NULL];
}
[YAPI
FreeAPI];
}
return
0;
}
20.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);
}
www.yoctopuce.com
");
<logical_name>");
const char
* argv[])
%@", [error localizedDescription]);
=
[NSString
stringWithUTF8String:argv[1]];
FirstTemperature];
== NULL) {
get_module]
get_serialNumber];
FindTemperature:[target
FindTemperature:[target
isOnline]) {
: %f
exit)\n");
*exe)
20. Utilisation du Yocto-Temperature-IR en Objective-C
(use any discovered
cable)");
stringByAppendingString:
stringByAppendingString:
C\n", [tsensor get_currentValue]);
C\n", [tsensor2 get_currentValue]);
[ON/OFF]\n", exe);
device)");
cable)\n");
153

Publicité

loading