Class Extensions
Extension methods for Modbus functions
Assembly: Meadow.Modbus.dll
View Source
public static class Extensions
Methods
ConvertRegistersToInt32(ushort[])
Converts a set of Modbus registers (ushort[]) to integers (int[]) assuming little-endina ordering
View Source
public static int[] ConvertRegistersToInt32(this ushort[] registers)
Returns
System.Int32[]
Parameters
| Type | Name |
|---|---|
System.UInt16[] | registers |
ExtractInt32(ushort[], int, bool)
Converts ushort registers to a single Int32, starting at a specific offset
View Source
public static int ExtractInt32(this ushort[] registers, int startOffset = 0, bool swappedWords = false)
Returns
System.Int32
Parameters
| Type | Name | Description |
|---|---|---|
System.UInt16[] | registers | The registers |
System.Int32 | startOffset | The offset in the registers to begine extraction |
System.Boolean | swappedWords | True to convert from big-endian words |
ExtractInt32(Span<ushort>, int, bool)
Converts ushort registers to a single Int32, starting at a specific offset
View Source
public static int ExtractInt32(this Span<ushort> registers, int startOffset = 0, bool swappedWords = false)
Returns
System.Int32
Parameters
| Type | Name | Description |
|---|---|---|
System.Span<System.UInt16> | registers | The registers |
System.Int32 | startOffset | The offset in the registers to begine extraction |
System.Boolean | swappedWords | True to convert from big-endian words |
ExtractUInt32(Span<ushort>, int, bool)
Converts ushort registers to a single UInt32, starting at a specific offset
View Source
public static uint ExtractUInt32(this Span<ushort> registers, int startOffset = 0, bool swappedWords = false)
Returns
System.UInt32
Parameters
| Type | Name | Description |
|---|---|---|
System.Span<System.UInt16> | registers | The registers |
System.Int32 | startOffset | The offset in the registers to begine extraction |
System.Boolean | swappedWords | True to convert from big-endian words |
ExtractInt64(Span<ushort>, int, bool)
Converts ushort registers to a single Int64, starting at a specific offset
View Source
public static long ExtractInt64(this Span<ushort> registers, int startOffset = 0, bool swappedWords = false)
Returns
System.Int64
Parameters
| Type | Name | Description |
|---|---|---|
System.Span<System.UInt16> | registers | The registers |
System.Int32 | startOffset | The offset in the registers to begine extraction |
System.Boolean | swappedWords | True to convert from big-endian words |
ExtractUInt64(Span<ushort>, int, bool)
Converts ushort registers to a single UInt64, starting at a specific offset
View Source
public static ulong ExtractUInt64(this Span<ushort> registers, int startOffset = 0, bool swappedWords = false)
Returns
System.UInt64
Parameters
| Type | Name | Description |
|---|---|---|
System.Span<System.UInt16> | registers | The registers |
System.Int32 | startOffset | The offset in the registers to begine extraction |
System.Boolean | swappedWords | True to convert from big-endian words |
ExtractDouble(ushort[], int, bool)
Converts 4 ushort registers to a IEEE 64 floating point, starting at a specific offset
View Source
public static double ExtractDouble(this ushort[] registers, int startOffset = 0, bool swappedWords = false)
Returns
System.Double
Parameters
| Type | Name | Description |
|---|---|---|
System.UInt16[] | registers | The registers |
System.Int32 | startOffset | The offset in the registers to begine extraction |
System.Boolean | swappedWords | True to convert from big-endian words |
ExtractDouble(Span<ushort>, int, bool)
Converts 4 ushort registers to a IEEE 64 floating point, starting at a specific offset
View Source
public static double ExtractDouble(this Span<ushort> registers, int startOffset = 0, bool swappedWords = false)
Returns
System.Double
Parameters
| Type | Name | Description |
|---|---|---|
System.Span<System.UInt16> | registers | The registers |
System.Int32 | startOffset | The offset in the registers to begine extraction |
System.Boolean | swappedWords | True to convert from big-endian words |
ExtractSingle(ushort[], int, bool)
Converts 2 ushort registers to a IEEE 32 floating point, starting at a specific offset
View Source
public static float ExtractSingle(this ushort[] registers, int startOffset = 0, bool swappedWords = false)
Returns
System.Single
Parameters
| Type | Name | Description |
|---|---|---|
System.UInt16[] | registers | The registers |
System.Int32 | startOffset | The offset in the registers to begine extraction |
System.Boolean | swappedWords | True to convert from big-endian words |
ExtractSingle(Span<ushort>, int, bool)
Converts 2 ushort registers to a IEEE 32 floating point, starting at a specific offset
View Source
public static float ExtractSingle(this Span<ushort> registers, int startOffset = 0, bool swappedWords = false)
Returns
System.Single
Parameters
| Type | Name | Description |
|---|---|---|
System.Span<System.UInt16> | registers | The registers |
System.Int32 | startOffset | The offset in the registers to begine extraction |
System.Boolean | swappedWords | True to convert from big-endian words |
ExtractMod10_48(Span<ushort>)
Converts three UInt16 values into an unsigned 48-bit Mod10 (modulo 10000) format (returned as an Int64).
View Source
public static long ExtractMod10_48(this Span<ushort> registers)
Returns
System.Int64
Parameters
| Type | Name | Description |
|---|---|---|
System.Span<System.UInt16> | registers | The registers |
ExtractMod10_64(Span<ushort>)
Converts four UInt16 values into an unsigned 48-bit Mod10 (modulo 10000) format (returned as an Int64).
View Source
public static long ExtractMod10_64(this Span<ushort> registers)
Returns
System.Int64
Parameters
| Type | Name | Description |
|---|---|---|
System.Span<System.UInt16> | registers | The registers |