Contrôle De La Partie Module - Yoctopuce Yocto-PowerRelay-V2 Mode D'emploi

Table des Matières

Publicité

static void
usage(void)
{
NSLog(@"usage: demo <serial_number>
NSLog(@"
demo <logical_name> [ A | B
NSLog(@"
demo any [ A | B ]
exit(1);
}
int main(int
argc,
{
NSError
*error;
if
(argc <
3) {
usage();
}
@autoreleasepool {
// Setup the API to use local USB devices
if([YAPI
RegisterHub:@"usb": &error] != YAPI_SUCCESS) {
NSLog(@"RegisterHub error:
return
1;
}
NSString
*target
NSString
*state
YRelay
*relay;
if
([target
isEqualToString:@"any"]) {
relay
=
[YRelay
if
(relay
== NULL) {
NSLog(@"No module connected (check USB
return
1;
}
} else {
relay
=
[YRelay
}
if
([relay
isOnline]) {
if
([state
isEqualToString:@"A"])
[relay set_state:Y_STATE_A];
else
[relay set_state:Y_STATE_B];
} else {
NSLog(@"Module not connected (check identification and USB
}
[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
[ A | B
const char
* argv[])
%@", [error localizedDescription]);
=
[NSString
stringWithUTF8String:argv[1]];
=
[NSString
stringWithUTF8String:argv[2]];
FirstRelay];
FindRelay:target];
*exe)
const char
* argv[])
%@", [error localizedDescription]);
19. Utilisation du Yocto-PowerRelay-V2 en Objective-C
]");
]");
(use any discovered
cable)");
cable)\n");
[ON/OFF]\n", exe);
device)");
145

Publicité

Table des Matières
loading

Table des Matières