Skip to main content

Class Extensions

Extension methods for Modbus functions

Assembly: Meadow.Modbus.dll​
View Source​
Declaration
public static class Extensions

Methods​

ConvertRegistersToInt32(ushort[])​

Converts a set of Modbus registers (ushort[]) to integers (int[]) assuming little-endina ordering

View Source​
Declaration
public static int[] ConvertRegistersToInt32(this ushort[] registers)
Returns​

System.Int32[]

Parameters​
TypeName
System.UInt16[]registers

ExtractInt32(ushort[], int, bool)​

Converts ushort registers to a single Int32, starting at a specific offset

View Source​
Declaration
public static int ExtractInt32(this ushort[] registers, int startOffset = 0, bool swappedWords = false)
Returns​

System.Int32

Parameters​
TypeNameDescription
System.UInt16[]registersThe registers
System.Int32startOffsetThe offset in the registers to begine extraction
System.BooleanswappedWordsTrue 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​
Declaration
public static int ExtractInt32(this Span<ushort> registers, int startOffset = 0, bool swappedWords = false)
Returns​

System.Int32

Parameters​
TypeNameDescription
System.Span<System.UInt16>registersThe registers
System.Int32startOffsetThe offset in the registers to begine extraction
System.BooleanswappedWordsTrue 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​
Declaration
public static uint ExtractUInt32(this Span<ushort> registers, int startOffset = 0, bool swappedWords = false)
Returns​

System.UInt32

Parameters​
TypeNameDescription
System.Span<System.UInt16>registersThe registers
System.Int32startOffsetThe offset in the registers to begine extraction
System.BooleanswappedWordsTrue 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​
Declaration
public static long ExtractInt64(this Span<ushort> registers, int startOffset = 0, bool swappedWords = false)
Returns​

System.Int64

Parameters​
TypeNameDescription
System.Span<System.UInt16>registersThe registers
System.Int32startOffsetThe offset in the registers to begine extraction
System.BooleanswappedWordsTrue 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​
Declaration
public static ulong ExtractUInt64(this Span<ushort> registers, int startOffset = 0, bool swappedWords = false)
Returns​

System.UInt64

Parameters​
TypeNameDescription
System.Span<System.UInt16>registersThe registers
System.Int32startOffsetThe offset in the registers to begine extraction
System.BooleanswappedWordsTrue 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​
Declaration
public static double ExtractDouble(this ushort[] registers, int startOffset = 0, bool swappedWords = false)
Returns​

System.Double

Parameters​
TypeNameDescription
System.UInt16[]registersThe registers
System.Int32startOffsetThe offset in the registers to begine extraction
System.BooleanswappedWordsTrue 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​
Declaration
public static double ExtractDouble(this Span<ushort> registers, int startOffset = 0, bool swappedWords = false)
Returns​

System.Double

Parameters​
TypeNameDescription
System.Span<System.UInt16>registersThe registers
System.Int32startOffsetThe offset in the registers to begine extraction
System.BooleanswappedWordsTrue 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​
Declaration
public static float ExtractSingle(this ushort[] registers, int startOffset = 0, bool swappedWords = false)
Returns​

System.Single

Parameters​
TypeNameDescription
System.UInt16[]registersThe registers
System.Int32startOffsetThe offset in the registers to begine extraction
System.BooleanswappedWordsTrue 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​
Declaration
public static float ExtractSingle(this Span<ushort> registers, int startOffset = 0, bool swappedWords = false)
Returns​

System.Single

Parameters​
TypeNameDescription
System.Span<System.UInt16>registersThe registers
System.Int32startOffsetThe offset in the registers to begine extraction
System.BooleanswappedWordsTrue 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​
Declaration
public static long ExtractMod10_48(this Span<ushort> registers)
Returns​

System.Int64

Parameters​
TypeNameDescription
System.Span<System.UInt16>registersThe registers

ExtractMod10_64(Span<ushort>)​

Converts four UInt16 values into an unsigned 48-bit Mod10 (modulo 10000) format (returned as an Int64).

View Source​
Declaration
public static long ExtractMod10_64(this Span<ushort> registers)
Returns​

System.Int64

Parameters​
TypeNameDescription
System.Span<System.UInt16>registersThe registers