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

Classes

struct  AnyChannelDiagnosis
 Any diagnosis entry (USI 0x8000, 0x8002, or 0x8003). More...
 
struct  ChannelDiagnosis
 ChannelDiagnosis entry (USI 0x8000). More...
 
struct  ChannelProperties
 Parsed ChannelProperties word (16 bits). More...
 
struct  DiagnosisData
 Complete diagnosis data for one slot/subslot. More...
 
struct  ExtChannelDiagnosis
 ExtChannelDiagnosis entry (USI 0x8002). More...
 
struct  QualifiedChannelDiagnosis
 QualifiedChannelDiagnosis entry (USI 0x8003). More...
 

Enumerations

enum class  ChannelType : std::uint8_t { Reserved = 0 , Specific = 1 , All = 2 , Submodule = 3 }
 Channel type, packed into ChannelProperties bits 0-1. More...
 
enum class  ChannelAccumulative : std::uint8_t { No = 0 , MainFault = 1 , AdditionalFault = 2 }
 Accumulative info, packed into ChannelProperties bits 2-4. More...
 
enum class  ChannelSpecifier : std::uint8_t { AllDisappears = 0 , Appears = 1 , Disappears = 2 , DisappearsOther = 3 }
 Diagnosis specifier, packed into ChannelProperties bits 8-10. More...
 
enum class  ChannelDirection : std::uint8_t { Manufacturer = 0 , Input = 1 , Output = 2 , Bidirectional = 3 }
 Data direction, packed into ChannelProperties bits 11-12. More...
 

Functions

std::string DecodeChannelErrorType (std::uint16_t errorType)
 Decode a ChannelErrorType to a human-readable string.
 
std::string DecodeExtChannelErrorType (std::uint16_t channelErrorType, std::uint16_t extErrorType)
 Decode an ExtChannelErrorType given its ChannelErrorType context.
 
DiagnosisData ParseDiagnosisBlock (const Bytes &data, std::uint32_t api=0, std::uint16_t slot=0, std::uint16_t subslot=0)
 Parse a full DiagnosisData block from raw bytes.
 
DiagnosisData ParseDiagnosisSimple (const Bytes &data, std::uint32_t api=0, std::uint16_t slot=0, std::uint16_t subslot=0)
 Parse a simple, fixed-format diagnosis block.
 

Enumeration Type Documentation

◆ ChannelAccumulative

enum class profinet::diagnosis::ChannelAccumulative : std::uint8_t
strong

Accumulative info, packed into ChannelProperties bits 2-4.

Enumerator
No 

Not accumulative.

MainFault 

Main fault.

AdditionalFault 

Additional fault.

Definition at line 58 of file diagnosis.h.

◆ ChannelDirection

enum class profinet::diagnosis::ChannelDirection : std::uint8_t
strong

Data direction, packed into ChannelProperties bits 11-12.

Enumerator
Manufacturer 

Manufacturer-specific direction.

Input 

Input direction.

Output 

Output direction.

Bidirectional 

Bidirectional.

Definition at line 82 of file diagnosis.h.

◆ ChannelSpecifier

enum class profinet::diagnosis::ChannelSpecifier : std::uint8_t
strong

Diagnosis specifier, packed into ChannelProperties bits 8-10.

Enumerator
AllDisappears 

All diagnosis of the submodule disappears.

Appears 

Diagnosis appears.

Disappears 

Diagnosis disappears.

DisappearsOther 

Diagnosis disappears but others remain.

Definition at line 69 of file diagnosis.h.

◆ ChannelType

enum class profinet::diagnosis::ChannelType : std::uint8_t
strong

Channel type, packed into ChannelProperties bits 0-1.

Enumerator
Reserved 

Reserved value.

Specific 

A specific, individually addressed channel.

All 

All channels of the submodule.

Submodule 

The whole submodule.

Definition at line 45 of file diagnosis.h.

Function Documentation

◆ DecodeChannelErrorType()

std::string profinet::diagnosis::DecodeChannelErrorType ( std::uint16_t  errorType)

Decode a ChannelErrorType to a human-readable string.

Parameters
errorTypeRaw channel error type value.
Returns
A description of the error.

Covers standard types (0x0001-0x001F), network/system types (0x8000+), IO-Link (0x9500+) and range-based fallbacks for manufacturer-specific, reserved, and profile-specific ranges.

Definition at line 183 of file diagnosis.cpp.

References profinet::Hex4().

Referenced by ParseDiagnosisBlock(), and ParseDiagnosisSimple().

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

◆ DecodeExtChannelErrorType()

std::string profinet::diagnosis::DecodeExtChannelErrorType ( std::uint16_t  channelErrorType,
std::uint16_t  extErrorType 
)

Decode an ExtChannelErrorType given its ChannelErrorType context.

Parameters
channelErrorTypeThe channel error type this ext error type belongs to.
extErrorTypeRaw extended channel error type value.
Returns
A description of the extended error.

Different ChannelErrorTypes have different ExtChannelErrorType tables (e.g. 0x8001 "Remote mismatch" has "Peer name of station mismatch" at ExtErrorType 0x8000, while 0x8000 "Data transmission impossible" has "Link state mismatch" at 0x8000). Falls through to a general table for error types without a dedicated ext-type map.

Definition at line 217 of file diagnosis.cpp.

References profinet::Hex4().

Referenced by ParseDiagnosisBlock().

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

◆ ParseDiagnosisBlock()

DiagnosisData profinet::diagnosis::ParseDiagnosisBlock ( const Bytes data,
std::uint32_t  api = 0,
std::uint16_t  slot = 0,
std::uint16_t  subslot = 0 
)

Parse a full DiagnosisData block from raw bytes.

Parameters
dataBuffer containing the diagnosis data.
apiDefault API number, used unless a location header overrides it.
slotDefault slot number, used unless a location header overrides it.
subslotDefault subslot number, used unless a location header overrides it.
Returns
The parsed diagnosis data.

Handles three cases:

  1. Response starts with a diagnosis BlockHeader (types 0x0010, 0x0011, 0x8010, 0x8011, 0x8012) – skips the 6-byte header before parsing.
  2. Response starts with API(4)+Slot(2)+Subslot(2) location info, optionally repeated per-entry – updates api/slot/subslot as it goes.
  3. Raw channel entries with no header or location prefix.

Stops (without throwing) when data is exhausted, an entry would be truncated, or a sanity check fails – matching diagnosis.py's loop which catches ValueError and breaks.

Definition at line 248 of file diagnosis.cpp.

References profinet::diagnosis::ChannelDiagnosis::api, profinet::diagnosis::DiagnosisData::api, profinet::diagnosis::AnyChannelDiagnosis::base, profinet::diagnosis::ChannelDiagnosis::channelNumber, DecodeChannelErrorType(), DecodeExtChannelErrorType(), profinet::diagnosis::DiagnosisData::entries, profinet::diagnosis::ChannelDiagnosis::errorType, profinet::diagnosis::ChannelDiagnosis::errorTypeName, profinet::diagnosis::AnyChannelDiagnosis::ext, profinet::diagnosis::ExtChannelDiagnosis::extAddValue, profinet::diagnosis::ExtChannelDiagnosis::extErrorType, profinet::diagnosis::ExtChannelDiagnosis::extErrorTypeName, profinet::diagnosis::ChannelProperties::FromUint16(), profinet::OneOctetShift, profinet::diagnosis::ChannelDiagnosis::properties, profinet::diagnosis::AnyChannelDiagnosis::qualified, profinet::diagnosis::QualifiedChannelDiagnosis::qualifier, profinet::diagnosis::DiagnosisData::rawData, profinet::diagnosis::ChannelDiagnosis::slot, profinet::diagnosis::DiagnosisData::slot, profinet::diagnosis::ChannelDiagnosis::subslot, profinet::diagnosis::DiagnosisData::subslot, profinet::ThreeOctetsShift, profinet::TwoOctetsShift, and profinet::diagnosis::AnyChannelDiagnosis::usi.

Referenced by profinet::rpc::RPCCon::ReadDiagnosis().

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

◆ ParseDiagnosisSimple()

DiagnosisData profinet::diagnosis::ParseDiagnosisSimple ( const Bytes data,
std::uint32_t  api = 0,
std::uint16_t  slot = 0,
std::uint16_t  subslot = 0 
)

Parse a simple, fixed-format diagnosis block.

Parameters
dataBuffer containing the diagnosis data.
apiAPI number to attach to every parsed entry.
slotSlot number to attach to every parsed entry.
subslotSubslot number to attach to every parsed entry.
Returns
The parsed diagnosis data.

Skips a 6-byte block header unconditionally, then parses raw ChannelNumber(2)+ChannelProperties(2)+ChannelErrorType(2) entries (no USI, no location sub-header) until data is exhausted or a zero-filled entry is found. Treats all entries as ChannelDiagnosis (USI 0x8000 format without the USI field itself).

Definition at line 396 of file diagnosis.cpp.

References profinet::diagnosis::ChannelDiagnosis::api, profinet::diagnosis::DiagnosisData::api, profinet::diagnosis::AnyChannelDiagnosis::base, profinet::diagnosis::ChannelDiagnosis::channelNumber, DecodeChannelErrorType(), profinet::diagnosis::DiagnosisData::entries, profinet::diagnosis::ChannelDiagnosis::errorType, profinet::diagnosis::ChannelDiagnosis::errorTypeName, profinet::diagnosis::ChannelProperties::FromUint16(), profinet::OneOctetShift, profinet::diagnosis::ChannelDiagnosis::properties, profinet::diagnosis::DiagnosisData::rawData, profinet::diagnosis::ChannelDiagnosis::slot, profinet::diagnosis::DiagnosisData::slot, profinet::diagnosis::ChannelDiagnosis::subslot, profinet::diagnosis::DiagnosisData::subslot, and profinet::diagnosis::AnyChannelDiagnosis::usi.

Referenced by profinet::rpc::RPCCon::ReadDiagnosis().

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