Table of Contents

Class ModbusFrame

Namespace
Pamoja.Modbus
Assembly
Pamoja.Modbus.dll

A received Modbus RTU frame whose CRC has been verified.

public sealed class ModbusFrame : IDisposable
Inheritance
ModbusFrame
Implements
Inherited Members

Examples

using var reply = Modbus.ParseFrame(received);
if (reply.Exception is null) Console.WriteLine(string.Join(", ", reply.Registers()));

Properties

Address

The unit address the frame is addressed to or came from.

public byte Address { get; }

Property Value

byte

Exception

The exception a device reported, or null when it served the request.

public byte? Exception { get; }

Property Value

byte?

FunctionCode

The function code. An exception response carries the request's code with its high bit set, as it appeared on the wire.

public byte FunctionCode { get; }

Property Value

byte

Pdu

The protocol data unit: the function code and its data.

public byte[] Pdu { get; }

Property Value

byte[]

Methods

Coils(ushort)

Reads the coils or discrete inputs out of a read-bits reply.

public bool[] Coils(ushort count)

Parameters

count ushort

How many bits to read, the quantity the request asked for.

Returns

bool[]

One state per coil, in order.

Exceptions

PamojaException

The reply does not carry that many bits.

Dispose()

Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.

public void Dispose()

Registers()

Reads the 16-bit registers out of a read-registers reply.

public ushort[] Registers()

Returns

ushort[]

The registers, in order.

Exceptions

PamojaException

This is not a well-formed read-registers reply.