Implemented the Serial Server
This commit is contained in:
@@ -14,7 +14,7 @@ If you want to speak a custom type of protocol with the clients, you can impleme
|
|||||||
|
|
||||||
**ModbusBaseClient**
|
**ModbusBaseClient**
|
||||||
This abstract base client contains all the basic methods and handlings required to communicate via Modbus Protocol.
|
This abstract base client contains all the basic methods and handlings required to communicate via Modbus Protocol.
|
||||||
The packages `AMWD.Protocols.Modbus.Serial` _(in progress)_ and `AMWD.Protocols.Modbus.Tcp` have specific derived implementations to match the communication types.
|
The packages `AMWD.Protocols.Modbus.Serial` and `AMWD.Protocols.Modbus.Tcp` have specific derived implementations to match the communication types.
|
||||||
|
|
||||||
|
|
||||||
### Enums
|
### Enums
|
||||||
@@ -63,8 +63,8 @@ Here you have the specific default implementations for the Modbus Protocol.
|
|||||||
- TCP
|
- TCP
|
||||||
|
|
||||||
**NOTE:**
|
**NOTE:**
|
||||||
The implementations over serial line (RTU and ASCII) have a minimum unit ID of one (1) referring to the specification.
|
The implementations over serial line (RTU and ASCII) have a minimum unit ID of one (1) and maximum unit ID of 247 referring to the specification.
|
||||||
This validation is _not_ implemented here due to real world experience, that some manufactures do not care about it.
|
This validation is _not_ implemented here due to real world experience, that some manufactures don't care about it.
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
|
|||||||
@@ -90,7 +90,13 @@ namespace AMWD.Protocols.Modbus.Serial
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets or sets a wait-time between requests.
|
/// Gets or sets a wait-time between requests.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public virtual TimeSpan InterRequestDelay { get; set; } = TimeSpan.Zero;
|
/// <remarks>
|
||||||
|
/// The specification says:
|
||||||
|
/// <br/>
|
||||||
|
/// For baud rates greater than 19.2k Bps, fixed values for the two timers should be used:
|
||||||
|
/// [...] a value of 1.750ms for inter-frame delay (t_3.5).
|
||||||
|
/// </remarks>
|
||||||
|
public virtual TimeSpan InterRequestDelay { get; set; } = TimeSpan.FromMilliseconds(1.75);
|
||||||
|
|
||||||
#region SerialPort Properties
|
#region SerialPort Properties
|
||||||
|
|
||||||
|
|||||||
1174
AMWD.Protocols.Modbus.Serial/ModbusSerialServer.cs
Normal file
1174
AMWD.Protocols.Modbus.Serial/ModbusSerialServer.cs
Normal file
File diff suppressed because it is too large
Load Diff
@@ -19,7 +19,7 @@ ushort count = 2;
|
|||||||
var registers = await client.ReadHoldingRegistersAsync(unitId, startAddress, count);
|
var registers = await client.ReadHoldingRegistersAsync(unitId, startAddress, count);
|
||||||
float voltage = registers.GetSingle();
|
float voltage = registers.GetSingle();
|
||||||
|
|
||||||
Console.WriteLine($"The voltage between L1 and N is: {voltage:N2}V");
|
Console.WriteLine($"The voltage of device #{unitId} between L1 and N is: {voltage:N2}V");
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ ushort count = 2;
|
|||||||
var registers = await client.ReadHoldingRegistersAsync(unitId, startAddress, count);
|
var registers = await client.ReadHoldingRegistersAsync(unitId, startAddress, count);
|
||||||
float voltage = registers.GetSingle();
|
float voltage = registers.GetSingle();
|
||||||
|
|
||||||
Console.WriteLine($"The voltage between L1 and N is: {voltage:N2}V");
|
Console.WriteLine($"The voltage of device #{unitId} between L1 and N is: {voltage:N2}V");
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user