16. Utilisation du Yocto-IO en VisualBasic .NET
io.set_portPolarity(0)
io.set_portOpenDrain(0) REM
Console.WriteLine("Channels 0..1 are configured as outputs and channels
Console.WriteLine("are configred as inputs, you can connect some inputs
Console.WriteLine("ouputs and see what
While (io.isOnline())
inputdata
= io.get_portState() REM
line
=
""
REM
For
i
As
Integer
If
CBool((inputdata
line
=
line
Else
line
=
line
End If
Next
Console.WriteLine("port value = "
outputdata
=
io.set_portState(outputdata) REM
YAPI.Sleep(1000,
End While
Console.WriteLine("Module
YAPI.FreeAPI()
End Sub
End Module
16.4. 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.
Imports
System.IO
Imports
System.Environment
Module
Module1
Sub usage()
Console.WriteLine("usage: demo <serial or logical name>
End
End Sub
Sub Main()
Dim argv() As
Dim
errmsg
As
Dim
m
As
ymodule
If
(YAPI.RegisterHub("usb",
Console.WriteLine("RegisterHub error:"
End
End If
If
argv.Length
m
= YModule.FindModule(argv(1)) REM
If (m.isOnline()) Then
If
argv.Length
If argv(2) =
If argv(2) =
End If
Console.WriteLine("serial:
Console.WriteLine("logical name: "
Console.WriteLine("luminosity:
Console.Write("beacon:
If (m.get_beacon() = Y_BEACON_ON) Then
Console.WriteLine("ON")
Else
Console.WriteLine("OFF")
End If
Console.WriteLine("upTime:
126
REM
polarity
No open drain
display part state value
=
0
To
3
Step
1
And
(8
>> i))) Then
+
"1"
+
"0"
(outputdata
+ 1) Mod
errmsg)
disconnected")
String
= System.Environment.GetCommandLineArgs()
String
=
""
errmsg) <> YAPI_SUCCESS) Then
<
2
Then usage()
>
2
Then
"ON"
Then m.set_beacon(Y_BEACON_ON)
"OFF"
Then m.set_beacon(Y_BEACON_OFF)
")
set to
regular
happens")
read port values
as
binary
+ line)
4
REM
cycle ouput
0..3
We could have used set_bitState
+ errmsg)
use serial
or
logical name
"
+ m.get_serialNumber())
+ m.get_logicalName())
"
+ Str(m.get_luminosity()))
"
+ Str(m.get_upTime() / 1000) +
2..3")
to")
as
well
[ON/OFF]")
"
sec")
www.yoctopuce.com