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

Table des Matières

Publicité

<HTML>
<HEAD>
<TITLE>Hello World</TITLE>
</HEAD>
<BODY>
<FORM method='get'>
<?php
include('yocto_api.php');
include('yocto_led.php');
// Use explicit error handling rather than exceptions
yDisableExceptions();
// Setup the API to use the VirtualHub on local machine
if(yRegisterHub('http://127.0.0.1:4444/',$errmsg)
die("Cannot contact VirtualHub on
}
@$serial = $_GET['serial'];
if
($serial !=
'') {
// Check if a specified module is available online
$led = yFindLed("$serial.led");
if (!$led->isOnline()) {
die("Module not connected (check serial and USB
}
} else {
// or use any connected module suitable for the demo
$led = yFirstLed();
if(is_null($led)) {
die("No module connected (check USB
} else {
$serial = $led->module()->get_serialnumber();
}
}
Print("Module to use: <input name='serial'
// Drive the selected module
if (isset($_GET['state'])) {
$state = $_GET['state'];
if ($state=='OFF')
if ($state=='ON')
}
?>
<input type='radio' name='state' value='ON'>Turn led ON
<input type='radio' name='state' value='OFF'>Turn led OFF
<br><input type='submit'>
</FORM>
</BODY>
</HTML>
8.3. 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.
<HTML>
<HEAD>
<TITLE>Module Control</TITLE>
</HEAD>
<BODY>
<FORM method='get'>
<?php
include('yocto_api.php');
// Use explicit error handling rather than exceptions
yDisableExceptions();
// Setup the API to use the VirtualHub on local machine
if(yRegisterHub('http://127.0.0.1:4444/',$errmsg)
die("Cannot contact VirtualHub on 127.0.0.1 :
}
www.yoctopuce.com
127.0.0.1");
value='$serial'><br>");
$led->set_power(Y_POWER_OFF);
$led->set_power(Y_POWER_ON);
8. Utilisation du Yocto-Demo en PHP
!=
YAPI_SUCCESS) {
cable)");
cable)");
!=
YAPI_SUCCESS) {
".$errmsg);
35

Publicité

Table des Matières
loading

Table des Matières