PROFINET IO Controller Stack 1.0.0
Modern C++ implementation of a PROFINET IO Controller stack
Loading...
Searching...
No Matches
profinet::PNIOError Class Reference

PNIO application error with error codes. More...

#include <exceptions.h>

+ Inheritance diagram for profinet::PNIOError:
+ Collaboration diagram for profinet::PNIOError:

Public Member Functions

 PNIOError (const std::string &message, std::uint8_t errorCode, std::uint8_t errorDecode, std::uint8_t errorCode1, std::uint8_t errorCode2)
 Construct directly from the four raw error-status bytes.
 
bool IsCmError () const
 Whether this error came from the PNIO-CM (connection management) table.
 
std::string BlockName () const
 Human-readable name of the PNIO-CM block referenced by ErrorCode1.
 
- Public Member Functions inherited from profinet::RPCError
 RPCError (const std::string &message)
 Construct with a human-readable message.
 
- Public Member Functions inherited from profinet::ProfinetError
 ProfinetError (const std::string &message)
 Construct with a human-readable message.
 

Static Public Member Functions

static PNIOError FromBytes (std::span< const std::uint8_t, 4 > data)
 Create a PNIOError from a raw 4-byte error status.
 
static PNIOError FromArgsStatus (std::uint32_t argsStatus)
 Create a PNIOError from the little-endian ArgsStatus field carried in a DCE/RPC PDU.
 

Public Attributes

std::uint8_t errorCode = 0
 Raw ErrorCode byte (see class-level.
 
std::uint8_t errorDecode = 0
 Raw ErrorDecode byte; selects which ErrorCode1/ErrorCode2 table applies.
 
std::uint8_t errorCode1 = 0
 Raw ErrorCode1 byte (category / block type).
 
std::uint8_t errorCode2 = 0
 Raw ErrorCode2 byte (specific error within the category).
 

Static Private Member Functions

static std::string DecodePnioCmError (const std::uint8_t &errorCode1, const std::uint8_t &errorCode2)
 Decodes a PROFINET Communication Manager (CM) error.
 
static std::string DecodePnioError (const std::uint8_t &errorCode1, const std::uint8_t &errorCode2)
 Decodes a PROFINET IO (PNIO) error.
 
static std::string DecodePnioRWError (const std::uint8_t &errorCode1, const std::uint8_t &errorCode2)
 Decodes a PROFINET Read/Write (PNIO RW) error.
 
static PNIOError CreateFromCodes (std::uint8_t errorCode, std::uint8_t errorDecode, std::uint8_t errorCode1, std::uint8_t errorCode2)
 Shared implementation for FromBytes()/FromArgsStatus(): look up the error message and construct the PNIOError.
 

Friends

class PNIOErrorDirectTests
 Test fixture for PNIO error unit tests, directly calling the functions.
 

Detailed Description

PNIO application error with error codes.

Error code structure (4 bytes):

  • Byte 0: ErrorCode (0x01=App, 0xCF=RTA, 0xDA=AlarmAck, 0xDB=IODConn, etc.)
  • Byte 1: ErrorDecode (0x40=PNIO-CM, 0x80=PNIORW, 0x81=PNIO)
  • Byte 2: ErrorCode1 (category/block type)
  • Byte 3: ErrorCode2 (specific error)

Definition at line 691 of file exceptions.h.

Constructor & Destructor Documentation

◆ PNIOError()

profinet::PNIOError::PNIOError ( const std::string &  message,
std::uint8_t  errorCode,
std::uint8_t  errorDecode,
std::uint8_t  errorCode1,
std::uint8_t  errorCode2 
)
inline

Construct directly from the four raw error-status bytes.

Parameters
messageHuman-readable message describing the error.
errorCodeRaw ErrorCode byte.
errorDecodeRaw ErrorDecode byte.
errorCode1Raw ErrorCode1 byte.
errorCode2Raw ErrorCode2 byte.

Definition at line 712 of file exceptions.h.

Member Function Documentation

◆ BlockName()

std::string profinet::PNIOError::BlockName ( ) const

Human-readable name of the PNIO-CM block referenced by ErrorCode1.

Returns
The block name, or empty string if this isn't a PNIO-CM error.

Definition at line 651 of file exceptions.cpp.

References errorCode1, profinet::GetPnioCmErrorCode1Name(), and IsCmError().

+ Here is the call graph for this function:

◆ CreateFromCodes()

PNIOError profinet::PNIOError::CreateFromCodes ( std::uint8_t  errorCode,
std::uint8_t  errorDecode,
std::uint8_t  errorCode1,
std::uint8_t  errorCode2 
)
staticprivate

Shared implementation for FromBytes()/FromArgsStatus(): look up the error message and construct the PNIOError.

Parameters
errorCodeRaw ErrorCode byte.
errorDecodeRaw ErrorDecode byte.
errorCode1Raw ErrorCode1 byte.
errorCode2Raw ErrorCode2 byte.
Returns
A PNIOError with a message looked up from the appropriate error table.

Definition at line 621 of file exceptions.cpp.

References DecodePnioCmError(), DecodePnioError(), DecodePnioRWError(), errorCode, errorCode1, errorCode2, errorDecode, profinet::Hex2(), profinet::Pnio, profinet::PnioCm, and profinet::PnioRw.

Referenced by profinet::PNIOErrorDirectTests::CreateFromCodes(), FromArgsStatus(), and FromBytes().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ DecodePnioCmError()

std::string profinet::PNIOError::DecodePnioCmError ( const std::uint8_t &  errorCode1,
const std::uint8_t &  errorCode2 
)
staticprivate

Decodes a PROFINET Communication Manager (CM) error.

Interprets the first two PROFINET error-code bytes as a CM error and returns a human-readable description. The first error-code byte selects the CM error category, while the second byte is decoded using the corresponding category-specific error-code enumeration.

Response-specific CM error categories are identified by appending "(in response)" to the decoded error message. If the first error-code byte is not recognized, an "Unknown CM error" message is returned.

Parameters
errorCode1First PROFINET CM error code byte identifying the error category.
errorCode2Second PROFINET CM error code byte identifying the specific error within the selected category.
Returns
Human-readable description of the decoded PROFINET CM error.
See also
PnioCmErrorCode1
PnioCmArErrorCode2
PnioCmIocrErrorCode2
PnioCmAlarmCrErrorCode2
PnioCmExpectedSubmoduleErrorCode2
PnioCmDeviceErrorCode2
PnioCmFaultyBlockErrorCode2

Definition at line 542 of file exceptions.cpp.

References profinet::AlarmCr, profinet::AlarmCrResponse, profinet::Ar, profinet::ArResponse, profinet::CmDev, errorCode1, errorCode2, profinet::ExpectedSubmodule, profinet::FaultyBlock, profinet::GetPnioCmErrorCode1Name(), profinet::GetPnioCmErrorMessage(), profinet::Iocr, and profinet::IocrResponse.

Referenced by CreateFromCodes(), and profinet::PNIOErrorDirectTests::DecodePnioCm().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ DecodePnioError()

std::string profinet::PNIOError::DecodePnioError ( const std::uint8_t &  errorCode1,
const std::uint8_t &  errorCode2 
)
staticprivate

Decodes a PROFINET IO (PNIO) error.

Interprets the first two PROFINET error-code bytes as a PNIO error. The first error-code byte selects the PNIO error category, while the second byte is decoded using the corresponding category-specific error-code enumeration.

If the first error-code byte is not recognized, a generic "Unknown PNIO error" message is returned.

Parameters
errorCode1First PROFINET PNIO error code byte identifying the error category.
errorCode2Second PROFINET PNIO error code byte identifying the specific error within the selected category.
Returns
Human-readable description of the decoded PROFINET IO error.
See also
PnioErrorCode1
PnioRmpmErrorCode2
PnioPrmServerErrorCode2

Definition at line 579 of file exceptions.cpp.

References errorCode1, errorCode2, profinet::GetPnioErrorMessage(), profinet::PrmServer, and profinet::Rmpm.

Referenced by CreateFromCodes(), and profinet::PNIOErrorDirectTests::DecodePnio().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ DecodePnioRWError()

std::string profinet::PNIOError::DecodePnioRWError ( const std::uint8_t &  errorCode1,
const std::uint8_t &  errorCode2 
)
staticprivate

Decodes a PROFINET Read/Write (PNIO RW) error.

Interprets the first two PROFINET error-code bytes as a PNIO Read/Write error. The first error-code byte selects the error category, while the second byte is decoded using the corresponding category-specific error-code enumeration.

If the first error-code byte is not recognized, a generic "Unknown PNIORW error" message is returned.

Parameters
errorCode1First PROFINET PNIO RW error code byte identifying the error category.
errorCode2Second PROFINET PNIO RW error code byte identifying the specific error within the selected category.
Returns
Human-readable description of the decoded PROFINET Read/Write error.
See also
PnioRwErrorCode1
PnioRwInvalidIndexErrorCode2
PnioRwWriteLengthErrorCode2
PnioRwResourceErrorCode2
PnioRwAccessErrorCode2
PnioRwApplicationErrorCode2

Definition at line 595 of file exceptions.cpp.

References profinet::Access, profinet::Application, errorCode1, errorCode2, profinet::GetPnioRwErrorMessage(), profinet::InvalidIndex, profinet::Resource, and profinet::WriteLength.

Referenced by CreateFromCodes(), and profinet::PNIOErrorDirectTests::DecodePnioRw().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ FromArgsStatus()

PNIOError profinet::PNIOError::FromArgsStatus ( std::uint32_t  argsStatus)
static

Create a PNIOError from the little-endian ArgsStatus field carried in a DCE/RPC PDU.

Parameters
argsStatusRaw args status field as read from the wire (little-endian).
Returns
A PNIOError with a message looked up from the appropriate error table.

Definition at line 522 of file exceptions.cpp.

References profinet::ByteAt(), profinet::ByteSwap(), CreateFromCodes(), errorCode, errorCode1, errorCode2, and errorDecode.

Referenced by profinet::rpc::RPCCon::Connect(), profinet::rpc::RPCCon::Read(), profinet::rpc::RPCCon::ReadImplicit(), profinet::rpc::RPCCon::SendControl(), profinet::TEST(), profinet::TEST(), profinet::TEST(), profinet::TEST(), profinet::TEST(), profinet::TEST(), profinet::TEST(), profinet::TEST(), profinet::rpc::RPCCon::Write(), and profinet::rpc::RPCCon::WriteMultiple().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ FromBytes()

PNIOError profinet::PNIOError::FromBytes ( std::span< const std::uint8_t, 4 >  data)
static

Create a PNIOError from a raw 4-byte error status.

Parameters
dataSpan view containing exactly 4 bytes: ErrorCode, ErrorDecode, ErrorCode1, ErrorCode2.
Returns
A PNIOError with a message looked up from the appropriate error table.

Definition at line 506 of file exceptions.cpp.

References CreateFromCodes().

Referenced by profinet::TEST(), profinet::TEST(), profinet::TEST(), profinet::TEST(), profinet::TEST(), profinet::TEST(), profinet::TEST(), profinet::TEST(), profinet::TEST(), profinet::TEST(), profinet::TEST(), profinet::TEST(), profinet::TEST(), profinet::TEST(), profinet::TEST(), profinet::TEST(), profinet::TEST(), profinet::TEST(), profinet::TEST(), profinet::TEST(), profinet::TEST(), profinet::TEST(), profinet::TEST(), profinet::TEST(), profinet::TEST(), profinet::TEST(), profinet::TEST(), profinet::TEST(), profinet::TEST(), profinet::TEST(), profinet::TEST(), profinet::TEST(), and profinet::TEST().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ IsCmError()

bool profinet::PNIOError::IsCmError ( ) const
inline

Whether this error came from the PNIO-CM (connection management) table.

Returns
True if ErrorDecode == DECODE_PNIO_CM.

Definition at line 737 of file exceptions.h.

References errorDecode, and profinet::PnioCm.

Referenced by BlockName().

+ Here is the caller graph for this function:

Friends And Related Symbol Documentation

◆ PNIOErrorDirectTests

friend class PNIOErrorDirectTests
friend

Test fixture for PNIO error unit tests, directly calling the functions.

Definition at line 748 of file exceptions.h.

Member Data Documentation

◆ errorCode

std::uint8_t profinet::PNIOError::errorCode = 0

Raw ErrorCode byte (see class-level.

).

Definition at line 695 of file exceptions.h.

Referenced by CreateFromCodes(), and FromArgsStatus().

◆ errorCode1

std::uint8_t profinet::PNIOError::errorCode1 = 0

Raw ErrorCode1 byte (category / block type).

Definition at line 701 of file exceptions.h.

Referenced by BlockName(), CreateFromCodes(), DecodePnioCmError(), DecodePnioError(), DecodePnioRWError(), profinet::rpc::RPCCon::EnumerateIndices(), and FromArgsStatus().

◆ errorCode2

std::uint8_t profinet::PNIOError::errorCode2 = 0

Raw ErrorCode2 byte (specific error within the category).

Definition at line 704 of file exceptions.h.

Referenced by CreateFromCodes(), DecodePnioCmError(), DecodePnioError(), DecodePnioRWError(), profinet::rpc::RPCCon::EnumerateIndices(), and FromArgsStatus().

◆ errorDecode

std::uint8_t profinet::PNIOError::errorDecode = 0

Raw ErrorDecode byte; selects which ErrorCode1/ErrorCode2 table applies.

Definition at line 698 of file exceptions.h.

Referenced by CreateFromCodes(), FromArgsStatus(), and IsCmError().


The documentation for this class was generated from the following files: