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

DCP response block: Option(1) + SubOption(1) + Length(2) + Status(2) + payload. More...

#include <protocol.h>

+ Collaboration diagram for profinet::PNDCPBlock:

Public Member Functions

Bytes ToBytes () const
 Serialize this block back to raw bytes.
 
IPConfiguration ParseIp () const
 Interpret this block's payload as an IP configuration triple.
 

Static Public Member Functions

static PNDCPBlock Parse (const Bytes &data)
 Parse a DCP response block from raw bytes.
 

Public Attributes

std::uint8_t option = 0
 DCP option code.
 
std::uint8_t suboption = 0
 DCP suboption code.
 
std::uint16_t length = 0
 Length in bytes of Status plus Payload (see class.
 
std::uint16_t status = 0
 Per-block status/error code.
 
Bytes payload
 Block payload (excludes Status).
 

Static Public Attributes

static constexpr std::pair< std::uint8_t, std::uint8_t > IP_MAC {1, 1}
 Block option/suboption: IP/MAC address.
 
static constexpr std::pair< std::uint8_t, std::uint8_t > IP_ADDRESS {1, 2}
 Block option/suboption: IP address/netmask/gateway.
 
static constexpr std::pair< std::uint8_t, std::uint8_t > IP_FULL_SUITE {1, 3}
 Block option/suboption: full IP suite.
 
static constexpr std::pair< std::uint8_t, std::uint8_t > DEVICE_TYPE {2, 1}
 Block option/suboption: device type string.
 
static constexpr std::pair< std::uint8_t, std::uint8_t > NAME_OF_STATION {2, 2}
 Block option/suboption: station name.
 
static constexpr std::pair< std::uint8_t, std::uint8_t > DEVICE_ID {2, 3}
 Block option/suboption: vendor/device ID.
 
static constexpr std::pair< std::uint8_t, std::uint8_t > DEVICE_ROLE {2, 4}
 Block option/suboption: device role bitmask.
 
static constexpr std::pair< std::uint8_t, std::uint8_t > DEVICE_OPTIONS {2, 5}
 Block option/suboption: supported option list.
 
static constexpr std::pair< std::uint8_t, std::uint8_t > DEVICE_ALIAS {2, 6}
 Block option/suboption: device alias name.
 
static constexpr std::pair< std::uint8_t, std::uint8_t > DEVICE_INSTANCE {2, 7}
 Block option/suboption: device instance.
 
static constexpr std::pair< std::uint8_t, std::uint8_t > DEVICE_OEM_ID {2, 8}
 Block option/suboption: OEM vendor/device ID.
 
static constexpr std::pair< std::uint8_t, std::uint8_t > ALL {0xFF, 0xFF}
 Block option/suboption wildcard: all blocks.
 
static constexpr std::size_t kFixedSize = 6
 Size in bytes of the fixed portion of this block.
 

Detailed Description

DCP response block: Option(1) + SubOption(1) + Length(2) + Status(2) + payload.

Length counts the 2-byte Status field plus the payload

Definition at line 736 of file protocol.h.

Member Function Documentation

◆ Parse()

static PNDCPBlock profinet::PNDCPBlock::Parse ( const Bytes &  data)
inlinestatic

Parse a DCP response block from raw bytes.

Parameters
dataBytes starting at the Option field.
Returns
The parsed block.

Definition at line 797 of file protocol.h.

References kFixedSize, length, option, payload, profinet::wire::Reader::ReadBytes(), profinet::wire::Reader::Remaining(), status, suboption, profinet::wire::Reader::U16(), and profinet::wire::Reader::U8().

Referenced by TEST_F().

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

◆ ParseIp()

IPConfiguration profinet::PNDCPBlock::ParseIp ( ) const
inline

Interpret this block's payload as an IP configuration triple.

Returns
The decoded address/netmask/gateway.

Throws std::runtime_error if the payload is shorter than 12 bytes.

Definition at line 833 of file protocol.h.

References payload, and profinet::String2Ip().

Referenced by TEST_F().

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

◆ ToBytes()

Bytes profinet::PNDCPBlock::ToBytes ( ) const
inline

Serialize this block back to raw bytes.

Returns
The encoded bytes.

Definition at line 819 of file protocol.h.

References length, option, payload, profinet::wire::PutU16(), profinet::wire::PutU8(), status, and suboption.

+ Here is the call graph for this function:

Member Data Documentation

◆ ALL

constexpr std::pair<std::uint8_t, std::uint8_t> profinet::PNDCPBlock::ALL {0xFF, 0xFF}
staticconstexpr

Block option/suboption wildcard: all blocks.

Definition at line 788 of file protocol.h.

◆ DEVICE_ALIAS

constexpr std::pair<std::uint8_t, std::uint8_t> profinet::PNDCPBlock::DEVICE_ALIAS {2, 6}
staticconstexpr

Block option/suboption: device alias name.

Definition at line 779 of file protocol.h.

◆ DEVICE_ID

constexpr std::pair<std::uint8_t, std::uint8_t> profinet::PNDCPBlock::DEVICE_ID {2, 3}
staticconstexpr

Block option/suboption: vendor/device ID.

Definition at line 770 of file protocol.h.

◆ DEVICE_INSTANCE

constexpr std::pair<std::uint8_t, std::uint8_t> profinet::PNDCPBlock::DEVICE_INSTANCE {2, 7}
staticconstexpr

Block option/suboption: device instance.

Definition at line 782 of file protocol.h.

◆ DEVICE_OEM_ID

constexpr std::pair<std::uint8_t, std::uint8_t> profinet::PNDCPBlock::DEVICE_OEM_ID {2, 8}
staticconstexpr

Block option/suboption: OEM vendor/device ID.

Definition at line 785 of file protocol.h.

◆ DEVICE_OPTIONS

constexpr std::pair<std::uint8_t, std::uint8_t> profinet::PNDCPBlock::DEVICE_OPTIONS {2, 5}
staticconstexpr

Block option/suboption: supported option list.

Definition at line 776 of file protocol.h.

◆ DEVICE_ROLE

constexpr std::pair<std::uint8_t, std::uint8_t> profinet::PNDCPBlock::DEVICE_ROLE {2, 4}
staticconstexpr

Block option/suboption: device role bitmask.

Definition at line 773 of file protocol.h.

◆ DEVICE_TYPE

constexpr std::pair<std::uint8_t, std::uint8_t> profinet::PNDCPBlock::DEVICE_TYPE {2, 1}
staticconstexpr

Block option/suboption: device type string.

Definition at line 764 of file protocol.h.

◆ IP_ADDRESS

constexpr std::pair<std::uint8_t, std::uint8_t> profinet::PNDCPBlock::IP_ADDRESS {1, 2}
staticconstexpr

Block option/suboption: IP address/netmask/gateway.

Definition at line 758 of file protocol.h.

◆ IP_FULL_SUITE

constexpr std::pair<std::uint8_t, std::uint8_t> profinet::PNDCPBlock::IP_FULL_SUITE {1, 3}
staticconstexpr

Block option/suboption: full IP suite.

Definition at line 761 of file protocol.h.

◆ IP_MAC

constexpr std::pair<std::uint8_t, std::uint8_t> profinet::PNDCPBlock::IP_MAC {1, 1}
staticconstexpr

Block option/suboption: IP/MAC address.

Definition at line 755 of file protocol.h.

◆ kFixedSize

constexpr std::size_t profinet::PNDCPBlock::kFixedSize = 6
staticconstexpr

Size in bytes of the fixed portion of this block.

Definition at line 792 of file protocol.h.

Referenced by Parse(), and TEST_F().

◆ length

std::uint16_t profinet::PNDCPBlock::length = 0

Length in bytes of Status plus Payload (see class.

).

Definition at line 745 of file protocol.h.

Referenced by Parse(), and ToBytes().

◆ NAME_OF_STATION

constexpr std::pair<std::uint8_t, std::uint8_t> profinet::PNDCPBlock::NAME_OF_STATION {2, 2}
staticconstexpr

◆ option

std::uint8_t profinet::PNDCPBlock::option = 0

DCP option code.

Definition at line 739 of file protocol.h.

Referenced by Parse(), TEST_F(), and ToBytes().

◆ payload

Bytes profinet::PNDCPBlock::payload

Block payload (excludes Status).

Definition at line 751 of file protocol.h.

Referenced by Parse(), ParseIp(), TEST_F(), and ToBytes().

◆ status

std::uint16_t profinet::PNDCPBlock::status = 0

Per-block status/error code.

Definition at line 748 of file protocol.h.

Referenced by Parse(), and ToBytes().

◆ suboption

std::uint8_t profinet::PNDCPBlock::suboption = 0

DCP suboption code.

Definition at line 742 of file protocol.h.

Referenced by Parse(), TEST_F(), and ToBytes().


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