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

Table des Matières

Publicité

11. Utilisation du Yocto-RS485-V2 en C#
val
=
serialPort.modbusReadInputRegisters(slave, reg
} else if
val
=
serialPort.modbusReadInputBits(slave, reg
} else {
val
=
serialPort.modbusReadBits(slave, reg
}
Console.WriteLine("Current value: "
Console.Write("Press ENTER to read again, Q to
if
((reg
% 30000) < 10000) {
Console.Write(" or enter a new
}
Console.Write(":
cmd
= Console.ReadLine();
if
(cmd
==
if
(cmd
!=
val
= Convert.ToInt32(cmd);
if
(reg
serialPort.modbusWriteRegister(slave, reg
} else {
serialPort.modbusWriteBit(slave, reg
}
}
}
YAPI.FreeAPI();
}
}
}
11.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.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace
ConsoleApplication1
{
class
Program
{
static
void
usage()
{
string
execname
Console.WriteLine("Usage:");
Console.WriteLine(execname
System.Threading.Thread.Sleep(2500);
Environment.Exit(0);
}
static
void
Main(string[] args)
{
YModule
m;
string
errmsg
if
(YAPI.RegisterHub("usb",
Console.WriteLine("RegisterHub error: "
Environment.Exit(0);
}
if
(args.Length
m
= YModule.FindModule(args[0]);
if (m.isOnline()) {
if
(args.Length
if (args[1].ToUpper() == "ON") {
m.set_beacon(YModule.BEACON_ON);
}
70
(reg
>= 10001) {
");
"q"
||
cmd
== "Q") break;
""
&&
(reg
% 30000) < 10000) {
>= 30001) {
= System.AppDomain.CurrentDomain.FriendlyName;
+
" <serial or logical name>
= "";
ref errmsg) !=
< 1)
usage();
>= 2) {
-
-
1,
1)[0];
+ val.ToString());
quit");
value");
-
30001,
-
1,
val);
YAPI.SUCCESS) {
+ errmsg);
// use serial or logical name
-
30001,
1)[0];
10001,
1)[0];
val);
[ON/OFF]");
www.yoctopuce.com

Publicité

Table des Matières
loading

Ce manuel est également adapté pour:

Yocto-rs232

Table des Matières