HEUREKA !!!!!!!! it works fine
I can communicate without any problem with an ASCON J1 type indicator
of temperature
www.ascon.it .
This library is a spectacle.
This is my simple code and for the moment THANKS TO ALL .
// MainWindow.cs created with MonoDevelop
// User: franaria at 11:21 15/05/2008
//
// To change standard headers go to Edit->Preferences->Coding-
>Standard Headers
//
using System;
using System.Diagnostics;
using System.IO.Ports;
using System.Net;
using System.Net.Sockets;
using System.Threading;
using Gtk;
using Modbus.Device;
public partial class MainWindow: Gtk.Window
{
public MainWindow (): base (Gtk.WindowType.Toplevel)
{
Build ();
}
protected void OnDeleteEvent (object sender, DeleteEventArgs a)
{
Application.Quit ();
a.RetVal = true;
}
protected virtual void Butt1Start (object sender, System.EventArgs e)
{
try
{
using (SerialPort port = new SerialPort("/dev/ttyS0"))
{
Console.WriteLine("I am in the procedure");
//configure serial port
port.BaudRate = 9600;
port.DataBits = 8;
port.Parity = Parity.None;
port.StopBits = StopBits.One;
Console.WriteLine("Port configured");
port.Open();
Console.WriteLine("Port opened");
// create modbus master
IModbusSerialMaster master = ModbusSerialMaster.CreateRtu(port);
byte slaveID = 1;
ushort startAddress = 1;
ushort numRegisters = 5;
// read registers
ushort[] registers =
master.ReadHoldingRegisters(slaveID,startAddress,numRegisters);
Console.WriteLine("==================================================");
Console.WriteLine("Serial test");
Console.WriteLine("==================================================");
for (int i = 0;i < numRegisters;i++)
Console.WriteLine("Register {0}={1}",startAddress +
i,registers[i]);
Console.WriteLine("==================================================");
}
}
catch (Exception ec)
{
Console.WriteLine(ec.Message);
Console.WriteLine("Test by ARWEN");
> > - Mostra testo tra virgolette -- Nascondi testo tra virgolette -