17. Utilisation du Yocto-IO en Delphi
Writeln('Channels 0..1 are configured as inputs and channels
Writeln('are configred as ouputs, you can connect some inputs
Writeln('ouputs and see what
outputdata := 0;
while (io.isOnline()) do
begin
inputdata := io.get_portState();
line:='';
// display value as binary
for
i :=
0
to
if
(inputdata
Writeln('port value = '
outputdata := (outputdata
io.set_portState(outputdata);
ysleep(1000,errmsg);
end;
yFreeAPI();
writeln('Device
end.
17.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.
program
modulecontrol;
{$APPTYPE CONSOLE}
uses
SysUtils,
yocto_api;
const
serial = 'YMINIIO0-123456';
procedure refresh(module:Tymodule)
begin
if (module.isOnline())
begin
Writeln('');
Writeln('Serial
Writeln('Logical name : '
Writeln('Luminosity
Write('Beacon
if
(module.get_beacon()=Y_BEACON_ON) then Writeln('on')
Writeln('uptime
Writeln('USB current
Writeln('Logs
Writeln(module.get_lastlogs());
Writeln('');
Writeln('r : refresh / b:beacon ON / space : beacon
end
else
Writeln('Module not connected (check identification and USB
end;
procedure
beacon(module:Tymodule;state:integer);
begin
module.set_beacon(state);
refresh(module);
end;
var
module : TYModule;
c
: char;
errmsg : string;
begin
// Setup the API to use local USB devices
if
yRegisterHub('usb', errmsg)<>YAPI_SUCCESS
134
happens');
// read port values
3
do
and
(8
shr
i))>0
+ line);
+1) mod
// We could have used set_bitState as well
disconnected');
// use serial number or logical name
;
then
: '
+ module.get_serialNumber());
+ module.get_logicalName());
: '
+ intToStr(module.get_luminosity()));
:');
: '
+
intToStr(module.get_upTime() div
: '
+ intToStr(module.get_usbCurrent())+'mA');
:
');
then
line:=line+'1'
else
4;
// cycle ouput 0..3
else
Writeln('off');
off');
then
2..3');
to');
line:=line+'0';
1000)+'s');
cable)');
www.yoctopuce.com