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 void extracted (const std::uint8_t &errorCode1, const std::uint8_t &errorCode2, std::string &message)
 Shared implementation for FromBytes()/FromArgsStatus(): look up the error message and construct the PNIOError.
 
static PNIOError CreateFromCodes (std::uint8_t errorCode, std::uint8_t errorDecode, std::uint8_t errorCode1, std::uint8_t errorCode2)
 

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 647 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

Definition at line 617 of file exceptions.cpp.

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

Referenced by FromArgsStatus(), and FromBytes().

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

◆ extracted()

static void profinet::PNIOError::extracted ( const std::uint8_t &  errorCode1,
const std::uint8_t &  errorCode2,
std::string &  message 
)
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.

◆ 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.

See Python's PNIOError.from_args_status for the byte swap rationale.

Definition at line 522 of file exceptions.cpp.

References CreateFromCodes(), errorCode, errorCode1, errorCode2, errorDecode, profinet::LowByteMask, profinet::OneOctetShift, profinet::ThreeOctetsShift, and profinet::TwoOctetsShift.

Referenced by profinet::rpc::RPCCon::Connect(), profinet::rpc::RPCCon::Read(), profinet::rpc::RPCCon::ReadImplicit(), profinet::rpc::RPCCon::SendControl(), 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().

+ Here is the call 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 738 of file exceptions.h.

References errorDecode, and profinet::PnioCm.

Referenced by BlockName().

+ Here is the caller graph for this function:

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(), 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(), 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: