IO::Modbus::PDU Struct Reference

Protocol Data Unit. More...

#include <PDU.h>

Collaboration diagram for IO::Modbus::PDU:

Classes

union  Data
 

Public Member Functions

Function function () const
 
void setFunction (Function function)
 
void setException (Exception exception)
 
bool exceptionFlag () const
 
Exception exception () const
 
Swap byte order of any 16-bit fields
void swapRequestByteOrder ()
 
void swapResponseByteOrder ()
 
Get PDU size based on content

Calculation uses byte count so doesn't access any 16-bit fields

size_t getRequestSize () const
 
size_t getResponseSize () const
 

Public Attributes

uint8_t functionCode
 
Data data
 

Detailed Description

Protocol Data Unit.

Content is independent of the communication layer. Structure does NOT represent over-the-wire format as packing issues make handling PDU::Data awkward. Therefore, the other fields are unaligned and adjusted as required when sent over the wire.

byteCount field

Some functions with a byteCount field are marked as calculated. This means it doesn't need to be set when constructing requests or responses, and will be filled in later based on the values of other fields.

In other cases, a setCount method is provided to help ensure the byteCount field is set correctly.

Member Function Documentation

◆ exception()

Exception IO::Modbus::PDU::exception ( ) const
inline

◆ exceptionFlag()

bool IO::Modbus::PDU::exceptionFlag ( ) const
inline

◆ function()

Function IO::Modbus::PDU::function ( ) const
inline

◆ getRequestSize()

size_t IO::Modbus::PDU::getRequestSize ( ) const
inline

◆ getResponseSize()

size_t IO::Modbus::PDU::getResponseSize ( ) const
inline

◆ setException()

void IO::Modbus::PDU::setException ( Exception  exception)
inline

◆ setFunction()

void IO::Modbus::PDU::setFunction ( Function  function)
inline

◆ swapRequestByteOrder()

void IO::Modbus::PDU::swapRequestByteOrder ( )

◆ swapResponseByteOrder()

void IO::Modbus::PDU::swapResponseByteOrder ( )

Member Data Documentation

◆ data

Data IO::Modbus::PDU::data

◆ functionCode

uint8_t IO::Modbus::PDU::functionCode

The documentation for this struct was generated from the following file: