|
PROFINET IO Controller Stack 1.0.0
Modern C++ implementation of a PROFINET IO Controller stack
|
PROFINET DCP discovery and device configuration interface. More...
#include <chrono>#include <cstdint>#include <functional>#include <map>#include <optional>#include <string>#include <utility>#include <vector>#include "profinet/IRawEthernetSocket.h"#include "profinet/protocol.h"#include "profinet/util.h"
Include dependency graph for dcp.h:
This graph shows which files directly or indirectly include this file:Go to the source code of this file.
Classes | |
| struct | profinet::dcp::DCPDHCPBlock |
| Parsed DHCP block from a DCP response. More... | |
| class | profinet::dcp::DCPDeviceDescription |
| Parsed PROFINET device information from a DCP response. More... | |
Namespaces | |
| namespace | profinet |
| namespace | profinet::dcp |
Typedefs | |
| using | profinet::dcp::BlockKey = DcpBlockKey |
| (option, suboption) key identifying a DCP block. | |
| using | profinet::dcp::ResponseMap = std::map< MacAddress, std::map< BlockKey, std::vector< std::uint8_t > > > |
| Result of ReadResponse(): MAC address -> parsed (option,suboption) -> payload blocks. | |
Functions | |
| std::vector< std::string > | profinet::dcp::DecodeDeviceRole (std::uint8_t roleByte) |
| Decode a device role bitmask into a list of role names. | |
| std::string | profinet::dcp::DeviceRoleName (DcpDeviceRole role) |
| Get the human-readable name of a DCP device role. | |
| std::string | profinet::dcp::GetBlockName (std::uint16_t option, std::uint8_t suboption) |
| Get the human-readable name for a (option, suboption) DCP block. | |
| std::string | profinet::dcp::GetBlockName (DcpOption option, std::uint8_t suboption) |
| Get the human-readable name for a (option, suboption) DCP block. | |
| std::string | profinet::dcp::GetBlockName (DcpOption option, DcpIpSuboption suboption) |
| Get the human-readable name for a (option, suboption) DCP block. | |
| std::string | profinet::dcp::GetBlockName (DcpOption option, DcpDeviceSuboption suboption) |
| Get the human-readable name for a (option, suboption) DCP block. | |
| std::string | profinet::dcp::GetBlockName (DcpOption option, DcpControlSuboption suboption) |
| Get the human-readable name for a (option, suboption) DCP block. | |
| std::string | profinet::dcp::GetBlockName (DcpOption option, DcpDhcpSuboption suboption) |
| Get the human-readable name for a (option, suboption) DCP block. | |
| std::string | profinet::dcp::GetBlockName (DcpOption option, DcpDeviceInitiativeSuboption suboption) |
| Get the human-readable name for a (option, suboption) DCP block. | |
| DcpBlockError | profinet::dcp::ParseSetResponse (const Bytes &data) |
| Parses the raw byte response payload received from a SET operation. | |
| DcpBlockError | profinet::dcp::RecvSetResponse (IRawEthernetSocket &sock, const MacAddress &srcMac, int timeoutSec) |
| Receive and parse a DCP SET response, filtering out unrelated frames. | |
| std::string | profinet::dcp::GetDeviceInitiativeName (DcpDeviceInitiative value) |
| std::string | profinet::dcp::GetDcpResponseCodeName (DcpResponseCode value) |
| Get the human-readable name for a device-response value. | |
| std::string | profinet::dcp::GetResetQualifierName (std::uint16_t qualifier) |
| Get the human-readable name for a reset qualifier value. | |
| std::string | profinet::dcp::GetResetQualifierName (DcpResetQualifier qualifier) |
| Get the human-readable name for a reset qualifier value. | |
| std::string | profinet::dcp::GetIPBlockInfoName (DcpIpBlockInfo info) |
| Get the human-readable name for an IP block info value. | |
| bool | profinet::dcp::HasConflict (DcpIpBlockInfo info) |
| Whether an address conflict was detected. | |
| bool | profinet::dcp::IsDhcp (DcpIpBlockInfo info) |
| Whether the address was assigned via DHCP. | |
| std::string | profinet::dcp::GetDcpBlockQualifierDescription (DcpBlockQualifier qualifier) |
| Get the human-readable description of a DCP block qualifier. | |
| std::string | profinet::dcp::GetDcpBlockErrorDescription (DcpBlockError error) |
| Get the human-readable name for a DCP SET block-level error code. | |
| constexpr DcpBlockKey | profinet::dcp::MakeBlockKey (std::uint16_t option, std::uint8_t suboption) |
| constexpr DcpBlockKey | profinet::dcp::MakeBlockKey (DcpOption option, std::uint8_t suboption) |
| constexpr DcpBlockKey | profinet::dcp::MakeBlockKey (DcpOption option, DcpIpSuboption suboption) |
| constexpr DcpBlockKey | profinet::dcp::MakeBlockKey (DcpOption option, DcpDeviceSuboption suboption) |
| constexpr DcpBlockKey | profinet::dcp::MakeBlockKey (DcpOption option, DcpControlSuboption suboption) |
| constexpr DcpBlockKey | profinet::dcp::MakeBlockKey (DcpOption option, DcpDhcpSuboption suboption) |
| constexpr DcpBlockKey | profinet::dcp::MakeBlockKey (DcpOption option, DcpDeviceInitiativeSuboption suboption) |
| Bytes | profinet::dcp::BuildSetParamRequest (const MacAddress &dst, const MacAddress &src, const std::string ¶m, const std::string &value, bool permanent) |
| Build a serialized DCP SET request for a named parameter. | |
| Bytes | profinet::dcp::BuildDcpSignalRequest (const MacAddress &dst, const MacAddress &src) |
| Build a serialized DCP Signal request. | |
| const std::map< std::string, BlockKey > & | profinet::dcp::Params () |
| Table of supported parameter names, mapping to their (option, suboption). | |
| std::optional< std::vector< std::uint8_t > > | profinet::dcp::GetParam (IRawEthernetSocket &sock, const MacAddress &src, const std::string &target, const std::string ¶m, int timeoutSec=DEFAULT_TIMEOUT) |
| Read a named parameter from a device. | |
| bool | profinet::dcp::SetParam (IRawEthernetSocket &sock, const MacAddress &src, const std::string &target, const std::string ¶m, const std::string &value, int timeoutSec=DEFAULT_TIMEOUT, bool permanent=false, int threadSleepMs=DEFAULT_THREAD_SLEEP_MS) |
| Write a named parameter to a device. | |
| bool | profinet::dcp::SetIp (IRawEthernetSocket &sock, const MacAddress &src, const std::string &target, const std::string &ip, const std::string &netmask, const std::string &gateway, bool permanent=false, int timeoutSec=DEFAULT_TIMEOUT, int threadSleepMs=DEFAULT_THREAD_SLEEP_MS) |
| Set a device's IP configuration via DCP. | |
| void | profinet::dcp::SendDiscover (IRawEthernetSocket &sock, const MacAddress &src, std::uint16_t responseDelay=DEFAULT_RESPONSE_DELAY_FACTOR) |
| Send a DCP Identify multicast request to discover all devices on the segment. | |
| void | profinet::dcp::SendRequest (IRawEthernetSocket &sock, const MacAddress &src, BlockKey blockType, const std::vector< std::uint8_t > &value) |
| Send a DCP Identify request filtered to a specific (option, suboption). | |
| ResponseMap | profinet::dcp::ReadResponse (IRawEthernetSocket &sock, const MacAddress &myMac, double timeoutSec=DEFAULT_RESPONSE_TIMEOUT, bool once=false, std::optional< std::uint32_t > expectedXid=std::nullopt) |
| Read and parse DCP Identify responses. | |
| void | profinet::dcp::SendHello (IRawEthernetSocket &sock, const MacAddress &src, const std::string &stationName, const std::string &ip="0.0.0.0", const std::string &netmask="0.0.0.0", const std::string &gateway="0.0.0.0", std::pair< std::uint16_t, std::uint16_t > deviceId={0, 0}, DcpDeviceRole deviceRole=DcpDeviceRole::IoDevice) |
| Send a DCP Hello multicast announcement (device self-announce after power-on). | |
| std::vector< DCPDeviceDescription > | profinet::dcp::ReceiveHello (IRawEthernetSocket &sock, const MacAddress &myMac, double timeoutSec=DEFAULT_HELLO_TIMEOUT, const std::function< void(const DCPDeviceDescription &)> &callback=nullptr) |
| Listen for DCP Hello announcements from other devices. | |
| bool | profinet::dcp::SignalDevice (IRawEthernetSocket &sock, const MacAddress &src, const std::string &target, int durationMs=FLASH_DURATION_MS, double timeoutSec=DEFAULT_TIMEOUT) |
| Flash a device's identification LEDs. | |
| bool | profinet::dcp::ResetToFactory (IRawEthernetSocket &sock, const MacAddress &src, const std::string &target, DcpResetMode mode=DcpResetMode::Communication, double timeoutSec=DEFAULT_TIMEOUT) |
| Reset a device to factory defaults. | |
Variables | |
| const std::string | profinet::dcp::DCP_MULTICAST_MAC = "01:0e:cf:00:00:00" |
| DCP Identify/Get/Set multicast destination MAC. | |
| const std::string | profinet::dcp::DCP_HELLO_MULTICAST_MAC = "01:0e:cf:00:00:01" |
| DCP Hello multicast destination MAC. | |
| constexpr std::size_t | profinet::dcp::DCP_MAX_NAME_LENGTH = 240 |
| Maximum allowed length in bytes for a station name. | |
| constexpr std::uint16_t | profinet::dcp::DEFAULT_TIMEOUT = 5 |
| Default timeout. | |
| constexpr std::uint16_t | profinet::dcp::DEFAULT_THREAD_SLEEP_MS = 2000 |
| constexpr std::uint16_t | profinet::dcp::DEFAULT_RESPONSE_TIMEOUT = 20 |
| Default response timeout. How long to keep listening for responses. | |
| constexpr std::uint16_t | profinet::dcp::DEFAULT_HELLO_TIMEOUT = 10 |
| Default HELLO timeout. | |
| constexpr std::uint16_t | profinet::dcp::DEFAULT_RESPONSE_DELAY_FACTOR = 0x0080 |
| Default dcp response delay factor. | |
| constexpr std::uint16_t | profinet::dcp::FLASH_DURATION_MS = 3000 |
| Default flash duration of the leds. | |
| constexpr std::uint16_t | profinet::dcp::blockNameVendorRangeMin = 0x80 |
| Default flash duration of the leds. | |
| constexpr std::uint16_t | profinet::dcp::blockNameVendorRangeMax = 0xFF |
| Default flash duration of the leds. | |
| constexpr std::uint16_t | profinet::dcp::DCP_IP_CONFLICT_BIT = 0x0080 |
| Bit mask indicating an IP address conflict. | |
| constexpr std::uint16_t | profinet::dcp::DCP_IP_DHCP_BIT = 0x0002 |
| Bit mask indicating DHCP bit is set. | |
PROFINET DCP discovery and device configuration interface.
Defines the data structures, constants, and operations required for PROFINET Discovery and Configuration Protocol (DCP) communication.
The interface provides support for:
DCPDeviceDescription stores the network and identification information obtained during discovery, including MAC address, station name, IP configuration, vendor and device identifiers, device role, supported DCP options, DHCP information, and device-initiative settings.
The interface operates directly on raw Ethernet frames and uses the PROFINET DCP wire-format definitions provided by protocol.h. Operations are designed to tolerate unrelated or malformed received frames where appropriate, allowing discovery and response processing to continue until the configured timeout expires.
Definition in file dcp.h.