Class ModbusUtility
Modbus utility methods.
Inheritance
Inherited Members
Namespace: NModbus.Utility
Assembly: NModbus.dll
Syntax
public static class ModbusUtility
Methods
| Improve this Doc View SourceCalculateCrc(Byte[])
Calculate Cyclical Redundancy Check.
Declaration
public static byte[] CalculateCrc(byte[] data)
Parameters
Type | Name | Description |
---|---|---|
System.Byte[] | data | The data used in CRC. |
Returns
Type | Description |
---|---|
System.Byte[] | CRC value. |
CalculateLrc(Byte[])
Calculate Longitudinal Redundancy Check.
Declaration
public static byte CalculateLrc(byte[] data)
Parameters
Type | Name | Description |
---|---|---|
System.Byte[] | data | The data used in LRC. |
Returns
Type | Description |
---|---|
System.Byte | LRC value. |
GetAsciiBytes(Byte[])
Converts an array of bytes to an ASCII byte array.
Declaration
public static byte[] GetAsciiBytes(params byte[] numbers)
Parameters
Type | Name | Description |
---|---|---|
System.Byte[] | numbers | The byte array. |
Returns
Type | Description |
---|---|
System.Byte[] | An array of ASCII byte values. |
GetAsciiBytes(UInt16[])
Converts an array of UInt16 to an ASCII byte array.
Declaration
public static byte[] GetAsciiBytes(params ushort[] numbers)
Parameters
Type | Name | Description |
---|---|---|
System.UInt16[] | numbers | The ushort array. |
Returns
Type | Description |
---|---|
System.Byte[] | An array of ASCII byte values. |
GetDouble(UInt16, UInt16, UInt16, UInt16)
Converts four UInt16 values into a IEEE 64 floating point format.
Declaration
public static double GetDouble(ushort b3, ushort b2, ushort b1, ushort b0)
Parameters
Type | Name | Description |
---|---|---|
System.UInt16 | b3 | Highest-order ushort value. |
System.UInt16 | b2 | Second-to-highest-order ushort value. |
System.UInt16 | b1 | Second-to-lowest-order ushort value. |
System.UInt16 | b0 | Lowest-order ushort value. |
Returns
Type | Description |
---|---|
System.Double | IEEE 64 floating point value. |
GetSingle(UInt16, UInt16)
Converts two UInt16 values into a IEEE 32 floating point format.
Declaration
public static float GetSingle(ushort highOrderValue, ushort lowOrderValue)
Parameters
Type | Name | Description |
---|---|---|
System.UInt16 | highOrderValue | High order ushort value. |
System.UInt16 | lowOrderValue | Low order ushort value. |
Returns
Type | Description |
---|---|
System.Single | IEEE 32 floating point value. |
GetUInt32(UInt16, UInt16)
Converts two UInt16 values into a UInt32.
Declaration
public static uint GetUInt32(ushort highOrderValue, ushort lowOrderValue)
Parameters
Type | Name | Description |
---|---|---|
System.UInt16 | highOrderValue | |
System.UInt16 | lowOrderValue |
Returns
Type | Description |
---|---|
System.UInt32 |
HexToBytes(String)
Converts a hex string to a byte array.
Declaration
public static byte[] HexToBytes(string hex)
Parameters
Type | Name | Description |
---|---|---|
System.String | hex | The hex string. |
Returns
Type | Description |
---|---|
System.Byte[] | Array of bytes. |
NetworkBytesToHostUInt16(Byte[])
Converts a network order byte array to an array of UInt16 values in host order.
Declaration
public static ushort[] NetworkBytesToHostUInt16(byte[] networkBytes)
Parameters
Type | Name | Description |
---|---|---|
System.Byte[] | networkBytes | The network order byte array. |
Returns
Type | Description |
---|---|
System.UInt16[] | The host order ushort array. |