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;
if
([target
isEqualToString:@"any"]) {
tsensor
=
[YTemperature
if
(tsensor
NSLog(@"No module connected (check USB
return
1;
}
} else {
tsensor
=
[YTemperature
stringByAppendingString:@".temperature"]];
}
while(1) {
if(![tsensor
NSLog(@"Module not connected (check identification and USB
break;
}
NSLog(@"Current temperature: %f
NSLog(@"
(press Ctrl-C to
[YAPI
Sleep:1000:NULL];
}
[YAPI
FreeAPI];
}
return
0;
}
10.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) {
www.yoctopuce.com
");
<logical_name>");
const char
* argv[])
%@", [error localizedDescription]);
=
[NSString
stringWithUTF8String:argv[1]];
FirstTemperature];
== NULL) {
FindTemperature:[target
isOnline]) {
C\n", [tsensor get_currentValue]);
exit)\n");
*exe)
const char
* argv[])
10. Utilisation du Yocto-PT100 en Objective-C
(use any discovered
device)");
cable)");
[ON/OFF]\n", exe);
cable)\n");
67