|
PROFINET IO Controller Stack 1.0.0
Modern C++ implementation of a PROFINET IO Controller stack
|
Implements PROFINET DCP discovery and device configuration operations. More...
#include "profinet/dcp.h"#include <algorithm>#include <cstdio>#include <cstring>#include <map>#include <random>#include <thread>#include "profinet/exceptions.h"#include "profinet/protocol.h"#include "profinet/vendors.h"
Include dependency graph for dcp.cpp:Go to the source code of this file.
Namespaces | |
| namespace | profinet |
| namespace | profinet::dcp |
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::GetBlockName (std::uint8_t option, std::uint8_t suboption) |
| Get the human-readable name for a (option, suboption) DCP block. | |
| std::uint8_t | profinet::dcp::RecvSetResponse (const IRawEthernetSocket &sock, const MacAddress &srcMac, int timeoutSec) |
| Receive and parse a DCP SET response, filtering out unrelated frames. | |
| std::uint8_t | profinet::dcp::ParseSetResponse (const Bytes &data) |
| Parses the raw byte response payload received from a SET operation. | |
| std::string | profinet::dcp::DcpBlockErrorName (std::uint8_t code) |
| Get the human-readable name for a DCP SET block-level error code. | |
| const std::map< std::string, BlockKey > & | profinet::dcp::Params () |
| Table of supported parameter names, mapping to their (option, 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. | |
| std::optional< std::vector< std::uint8_t > > | profinet::dcp::GetParam (const EthernetSocket &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 (const EthernetSocket &sock, const MacAddress &src, const std::string &target, const std::string ¶m, const std::string &value, int timeoutSec=DEFAULT_TIMEOUT, bool permanent=false) |
| Write a named parameter to a device. | |
| bool | profinet::dcp::SetIp (const EthernetSocket &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) |
| Set a device's IP configuration via DCP. | |
| void | profinet::dcp::SendDiscover (const EthernetSocket &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 (const EthernetSocket &sock, const MacAddress &src, BlockKey blockType, const Bytes &value) |
| Send a DCP Identify request filtered to a specific (option, suboption). | |
| ResponseMap | profinet::dcp::ReadResponse (const EthernetSocket &sock, const MacAddress &myMac, int 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 (const EthernetSocket &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}, std::uint8_t deviceRole=DEVICE_ROLE_IO_DEVICE) |
| Send a DCP Hello multicast announcement (device self-announce after power-on). | |
| std::vector< DCPDeviceDescription > | profinet::dcp::ReceiveHello (const EthernetSocket &sock, const MacAddress &myMac, int timeoutSec=DEFAULT_HELLO_TIMEOUT, const std::function< void(const DCPDeviceDescription &)> &callback=nullptr) |
| Listen for DCP Hello announcements from other devices. | |
| bool | profinet::dcp::SignalDevice (const EthernetSocket &sock, const MacAddress &src, const std::string &target, int durationMs=FLASH_DURATION_MS, int timeoutSec=DEFAULT_TIMEOUT) |
| Flash a device's identification LEDs. | |
| bool | profinet::dcp::ResetToFactory (const EthernetSocket &sock, const MacAddress &src, const std::string &target, std::uint16_t mode=RESET_MODE_COMMUNICATION, int timeoutSec=DEFAULT_TIMEOUT) |
| Reset a device to factory defaults. | |
Implements PROFINET DCP discovery and device configuration operations.
Implements the PROFINET Discovery and Configuration Protocol (DCP) functionality declared in dcp.h. The implementation provides construction, transmission, reception, parsing, and interpretation of DCP Ethernet frames for device discovery and configuration.
The implementation covers:
Transaction identifiers are generated for DCP requests, while received frames are validated and filtered by destination, EtherType, service type, and, where applicable, transaction identifier. Malformed or unrelated frames are ignored where appropriate so that discovery and response processing can continue until the configured timeout expires.
Definition in file dcp.cpp.