AMWD.Protocols.Modbus.Serial 0.3.3-3
Modbus Protocol for .NET | Serial
The Modbus Serial protocol implementation.
Example
A simple example which reads the voltage between L1 and N of a Janitza device.
string serialPort = "COM5";
using var client = new ModbusSerialClient(serialPort);
await client.ConnectAsync(CancellationToken.None);
byte unitId = 5;
ushort startAddress = 19000;
ushort count = 2;
var registers = await client.ReadHoldingRegistersAsync(unitId, startAddress, count);
float voltage = registers.GetSingle();
Console.WriteLine($"The voltage of device #{unitId} between L1 and N is: {voltage:N2}V");
If you want to use the ASCII
protocol instead, you can do this on initialization:
// [...]
using var client = new ModbusSerialClient(serialPort)
{
Protocol = new AsciiProtocol();
};
// [...]
Sources
Published under MIT License (see tl;drLegal)
Showing the top 20 packages that depend on AMWD.Protocols.Modbus.Serial.
Packages | Downloads |
---|---|
AMWD.Protocols.Modbus.Proxy
Plugging Modbus Servers and Clients together to create Modbus Proxies.
|
27 |
AMWD.Protocols.Modbus.Proxy
Plugging Modbus Servers and Clients together to create Modbus Proxies.
|
17 |
AMWD.Protocols.Modbus.Proxy
Plugging Modbus Servers and Clients together to create Modbus Proxies.
|
9 |
.NET 6.0
- AMWD.Protocols.Modbus.Common (>= 0.3.3-3)
- System.IO.Ports (>= 6.0.0)
.NET 8.0
- AMWD.Protocols.Modbus.Common (>= 0.3.3-3)
- System.IO.Ports (>= 8.0.0)
.NET Standard 2.0
- AMWD.Protocols.Modbus.Common (>= 0.3.3-3)
- System.IO.Ports (>= 4.7.0)