Implementation of the basic functionallity

This commit is contained in:
2024-02-06 19:47:06 +01:00
parent a6c7828fbe
commit f31f6f94ff
42 changed files with 6875 additions and 11 deletions

View File

@@ -0,0 +1,18 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>netstandard2.0;net6.0;net8.0</TargetFrameworks>
<LangVersion>12.0</LangVersion>
<AssemblyName>amwd-modbus-serial</AssemblyName>
<RootNamespace>AMWD.Protocols.Modbus.Serial</RootNamespace>
<Product>Modbus RTU/ASCII Protocol</Product>
<Description>Implementation of the Modbus protocol communicating via serial line using RTU or ASCII encoding.</Description>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\AMWD.Protocols.Modbus.Common\AMWD.Protocols.Modbus.Common.csproj" />
</ItemGroup>
</Project>

View File

@@ -0,0 +1,40 @@
# 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.
```csharp
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 between L1 and N is: {voltage:N2}V");
```
## Sources
- Protocol Specification: [v1.1b3]
- Modbus Serial line: [v1.02]
---
Published under MIT License (see [**tl;dr**Legal])
[v1.1b3]: https://modbus.org/docs/Modbus_Application_Protocol_V1_1b3.pdf
[v1.02]: https://modbus.org/docs/Modbus_over_serial_line_V1_02.pdf
[**tl;dr**Legal]: https://www.tldrlegal.com/license/mit-license