|
PROFINET IO Controller Stack 1.0.0
Modern C++ implementation of a PROFINET IO Controller stack
|
Classes | |
| struct | BlockQualifier |
| Block qualifier: whether a Set operation is temporary or permanent. More... | |
| class | DCPDeviceDescription |
| Parsed PROFINET device information from a DCP response. More... | |
| struct | DCPDHCPBlock |
| Parsed DHCP block from a DCP response. More... | |
| struct | DCPResponseCode |
| DCP GET/SET response codes. More... | |
| struct | DeviceInitiative |
| Device-initiative (Hello-after-power-on) setting values. More... | |
| struct | IPBlockInfo |
| IP block status flags (IEC 61158-6-10 IPBlockInfo). More... | |
| struct | ResetQualifier |
| Reset qualifier values for ResetToFactory(). More... | |
Typedefs | |
| using | BlockKey = std::pair< std::uint8_t, std::uint8_t > |
| (option, suboption) key identifying a DCP block. | |
| using | 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 > | DecodeDeviceRole (std::uint8_t roleByte) |
| Decode a device role bitmask into a list of role names. | |
| std::string | GetBlockName (std::uint8_t option, std::uint8_t suboption) |
| Get the human-readable name for a (option, suboption) DCP block. | |
| std::uint8_t | ParseSetResponse (const Bytes &data) |
| Parses the raw byte response payload received from a SET operation. | |
| std::uint8_t | RecvSetResponse (const IRawEthernetSocket &sock, const MacAddress &srcMac, int timeoutSec) |
| Receive and parse a DCP SET response, filtering out unrelated frames. | |
| std::string | DcpBlockErrorName (std::uint8_t code) |
| Get the human-readable name for a DCP SET block-level error code. | |
| Bytes | 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 | BuildDcpSignalRequest (const MacAddress &dst, const MacAddress &src) |
| Build a serialized DCP Signal request. | |
| const std::map< std::string, BlockKey > & | Params () |
| Table of supported parameter names, mapping to their (option, suboption). | |
| std::optional< std::vector< std::uint8_t > > | 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 | 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 | 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 | 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 | SendRequest (const EthernetSocket &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 | 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 | 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 > | 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 | 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 | 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. | |
| void | SendRequest (const EthernetSocket &sock, const MacAddress &src, BlockKey blockType, const Bytes &value) |
| Send a DCP Identify request filtered to a specific (option, suboption). | |
Variables | |
| const std::string | DCP_MULTICAST_MAC = "01:0e:cf:00:00:00" |
| DCP Identify/Get/Set multicast destination MAC. | |
| const std::string | DCP_HELLO_MULTICAST_MAC = "01:0e:cf:00:00:01" |
| DCP Hello multicast destination MAC. | |
| constexpr std::uint16_t | DCP_IDENTIFY_REQUEST_FRAME_ID = 0xFEFE |
| Frame ID for DCP Identify requests. | |
| constexpr std::uint16_t | DCP_IDENTIFY_RESPONSE_FRAME_ID = 0xFEFF |
| Frame ID for DCP Identify responses. | |
| constexpr std::uint16_t | DCP_GET_SET_FRAME_ID = 0xFEFD |
| Frame ID for DCP Get/Set requests and responses. | |
| constexpr std::uint16_t | DCP_HELLO_FRAME_ID = 0xFEFC |
| Frame ID for DCP Hello announcements. | |
| constexpr std::uint8_t | DCP_SERVICE_ID_GET = 0x03 |
| DCP service ID: GET. | |
| constexpr std::uint8_t | DCP_SERVICE_ID_SET = 0x04 |
| DCP service ID: SET. | |
| constexpr std::uint8_t | DCP_SERVICE_ID_IDENTIFY = 0x05 |
| DCP service ID: IDENTIFY. | |
| constexpr std::uint8_t | DCP_SERVICE_ID_HELLO = 0x06 |
| DCP service ID: HELLO. | |
| constexpr std::uint8_t | DCP_SERVICE_TYPE_REQUEST = 0x00 |
| DCP service type: REQUEST. | |
| constexpr std::uint8_t | DCP_SERVICE_TYPE_RESPONSE_SUCCESS = 0x01 |
| DCP service type: RESPONSE (success). | |
| constexpr std::uint8_t | DCP_SERVICE_TYPE_RESPONSE_UNSUPPORTED = 0x05 |
| DCP service type: RESPONSE (service unsupported). | |
| constexpr std::size_t | DCP_MAX_NAME_LENGTH = 240 |
| Maximum allowed length in bytes for a station name. | |
| constexpr std::uint8_t | DCP_OPTION_IP = 0x01 |
| DCP option: IP configuration. | |
| constexpr std::uint8_t | DCP_OPTION_DEVICE = 0x02 |
| DCP option: device identification. | |
| constexpr std::uint8_t | DCP_OPTION_DHCP = 0x03 |
| DCP option: DHCP. | |
| constexpr std::uint8_t | DCP_OPTION_RESERVED = 0x04 |
| DCP option: reserved. | |
| constexpr std::uint8_t | DCP_OPTION_CONTROL = 0x05 |
| DCP option: control (start/stop/signal/reset). | |
| constexpr std::uint8_t | DCP_OPTION_DEVICE_INITIATIVE = 0x06 |
| DCP option: device-initiative (Hello) configuration. | |
| constexpr std::uint8_t | DCP_OPTION_NME = 0x07 |
| DCP option: Network Management (NME). | |
| constexpr std::uint8_t | DCP_OPTION_ALL = 0xFF |
| DCP option wildcard: all options. | |
| constexpr std::uint8_t | DCP_SUBOPTION_IP_MAC = 0x01 |
| DCP suboption (IP): MAC address. | |
| constexpr std::uint8_t | DCP_SUBOPTION_IP_PARAMETER = 0x02 |
| DCP suboption (IP): IP/netmask/gateway parameter. | |
| constexpr std::uint8_t | DCP_SUBOPTION_IP_FULL_SUITE = 0x03 |
| DCP suboption (IP): full IP suite. | |
| constexpr std::uint8_t | DCP_SUBOPTION_DEVICE_TYPE = 0x01 |
| DCP suboption (Device): device type string. | |
| constexpr std::uint8_t | DCP_SUBOPTION_DEVICE_NAME = 0x02 |
| DCP suboption (Device): station name. | |
| constexpr std::uint8_t | DCP_SUBOPTION_DEVICE_ID = 0x03 |
| DCP suboption (Device): vendor/device ID. | |
| constexpr std::uint8_t | DCP_SUBOPTION_DEVICE_ROLE = 0x04 |
| DCP suboption (Device): device role bitmask. | |
| constexpr std::uint8_t | DCP_SUBOPTION_DEVICE_OPTIONS = 0x05 |
| DCP suboption (Device): supported options list. | |
| constexpr std::uint8_t | DCP_SUBOPTION_DEVICE_ALIAS = 0x06 |
| DCP suboption (Device): alias name. | |
| constexpr std::uint8_t | DCP_SUBOPTION_DEVICE_INSTANCE = 0x07 |
| DCP suboption (Device): device instance. | |
| constexpr std::uint8_t | DCP_SUBOPTION_DEVICE_OEM_ID = 0x08 |
| DCP suboption (Device): OEM vendor/device ID. | |
| constexpr std::uint8_t | DCP_SUBOPTION_DEVICE_RSI = 0x0A |
| DCP suboption (Device): RSI (reverse status indication). | |
| constexpr std::uint8_t | DCP_SUBOPTION_CONTROL_START = 0x01 |
| DCP suboption (Control): start. | |
| constexpr std::uint8_t | DCP_SUBOPTION_CONTROL_STOP = 0x02 |
| DCP suboption (Control): stop. | |
| constexpr std::uint8_t | DCP_SUBOPTION_CONTROL_SIGNAL = 0x03 |
| DCP suboption (Control): signal (flash LEDs). | |
| constexpr std::uint8_t | DCP_SUBOPTION_CONTROL_RESPONSE = 0x04 |
| DCP suboption (Control): response. | |
| constexpr std::uint8_t | DCP_SUBOPTION_CONTROL_RESET_FACTORY = 0x05 |
| DCP suboption (Control): factory reset. | |
| constexpr std::uint8_t | DCP_SUBOPTION_CONTROL_RESET_TO_FACTORY = 0x06 |
| DCP suboption (Control): reset to factory. | |
| constexpr std::uint8_t | DCP_SUBOPTION_DHCP_HOSTNAME = 0x0C |
| DCP suboption (DHCP): hostname option. | |
| constexpr std::uint8_t | DCP_SUBOPTION_DHCP_VENDOR_SPEC = 0x2B |
| DCP suboption (DHCP): vendor-specific option. | |
| constexpr std::uint8_t | DCP_SUBOPTION_DHCP_SERVER_ID = 0x36 |
| DCP suboption (DHCP): server identifier option. | |
| constexpr std::uint8_t | DCP_SUBOPTION_DHCP_PARAM_REQ = 0x37 |
| DCP suboption (DHCP): parameter request list. | |
| constexpr std::uint8_t | DCP_SUBOPTION_DHCP_CLASS_ID = 0x3C |
| DCP suboption (DHCP): class identifier option. | |
| constexpr std::uint8_t | DCP_SUBOPTION_DHCP_CLIENT_ID = 0x3D |
| DCP suboption (DHCP): client identifier option. | |
| constexpr std::uint8_t | DCP_SUBOPTION_DHCP_FQDN = 0x51 |
| DCP suboption (DHCP): fully qualified domain name option. | |
| constexpr std::uint8_t | DCP_SUBOPTION_DHCP_UUID = 0x61 |
| DCP suboption (DHCP): client UUID option. | |
| constexpr std::uint8_t | DCP_SUBOPTION_DHCP_CONTROL = 0xFF |
| DCP suboption (DHCP): DHCP control. | |
| constexpr std::uint8_t | DCP_SUBOPTION_DEVICE_INITIATIVE = 0x01 |
| DCP suboption (DeviceInitiative): the only suboption. | |
| constexpr std::uint8_t | DEVICE_ROLE_IO_DEVICE = 0x01 |
| Device role bit: IO-Device. | |
| constexpr std::uint8_t | DEVICE_ROLE_IO_CONTROLLER = 0x02 |
| Device role bit: IO-Controller. | |
| constexpr std::uint8_t | DEVICE_ROLE_IO_MULTIDEVICE = 0x04 |
| Device role bit: IO-Multidevice. | |
| constexpr std::uint8_t | DEVICE_ROLE_PN_SUPERVISOR = 0x08 |
| Device role bit: PN-Supervisor. | |
| constexpr std::uint16_t | RESET_MODE_COMMUNICATION = 0x0002 |
| Reset mode bit: reset communication parameters. | |
| constexpr std::uint16_t | RESET_MODE_APPLICATION = 0x0004 |
| Reset mode bit: reset application data. | |
| constexpr std::uint16_t | RESET_MODE_ENGINEERING = 0x0008 |
| Reset mode bit: reset engineering parameters. | |
| constexpr std::uint16_t | RESET_MODE_ALL_DATA = 0x0010 |
| Reset mode bit: reset all stored data. | |
| constexpr std::uint16_t | RESET_MODE_DEVICE = 0x0020 |
| Reset mode bit: reset device. | |
| constexpr std::uint16_t | RESET_MODE_FACTORY = 0x0040 |
| Reset mode bit: reset to factory defaults. | |
| constexpr std::uint16_t | DEFAULT_TIMEOUT = 5 |
| Default timeout. | |
| constexpr std::uint16_t | DEFAULT_RESPONSE_TIMEOUT = 20 |
| Default response timeout. How long to keep listening for responses. | |
| constexpr std::uint16_t | DEFAULT_HELLO_TIMEOUT = 10 |
| Default HELLO timeout. | |
| constexpr std::uint16_t | DEFAULT_RESPONSE_DELAY_FACTOR = 0x0080 |
| Default dcp response delay factor. | |
| constexpr std::uint16_t | FLASH_DURATION_MS = 3000 |
| Default flash duration of the leds. | |
| constexpr std::uint8_t | DCP_BLOCK_ERROR_OK = 0x00 |
| DCP SET block-level result: OK. | |
| constexpr std::uint8_t | DCP_BLOCK_ERROR_OPTION_UNSUPPORTED = 0x01 |
| DCP SET block-level result: option not supported. | |
| constexpr std::uint8_t | DCP_BLOCK_ERROR_SUBOPTION_UNSUPPORTED = 0x02 |
| DCP SET block-level result: suboption not supported. | |
| constexpr std::uint8_t | DCP_BLOCK_ERROR_SUBOPTION_NOT_SET = 0x03 |
| DCP SET block-level result: suboption not set. | |
| constexpr std::uint8_t | DCP_BLOCK_ERROR_RESOURCE = 0x04 |
| DCP SET block-level result: resource error. | |
| constexpr std::uint8_t | DCP_BLOCK_ERROR_SET_NOT_POSSIBLE = 0x05 |
| DCP SET block-level result: set not possible locally. | |
| constexpr std::uint8_t | DCP_BLOCK_ERROR_IN_OPERATION = 0x06 |
| DCP SET block-level result: set not possible, device in operation. | |
| using profinet::dcp::BlockKey = typedef std::pair<std::uint8_t, std::uint8_t> |
| using profinet::dcp::ResponseMap = typedef std::map<MacAddress, std::map<BlockKey, std::vector<std::uint8_t> >> |
Result of ReadResponse(): MAC address -> parsed (option,suboption) -> payload blocks.
| Bytes profinet::dcp::BuildDcpSignalRequest | ( | const MacAddress & | dst, |
| const MacAddress & | src | ||
| ) |
Build a serialized DCP Signal request.
Creates the complete Ethernet frame used to request the device's identification LEDs to flash once.
The serialized Control/Signal block contains:
| dst | Destination device MAC address. |
| src | Source/controller MAC address. |
Definition at line 812 of file dcp.cpp.
References BuildDcpSignalRequest(), DCP_GET_SET_FRAME_ID, DCP_OPTION_CONTROL, DCP_SUBOPTION_CONTROL_SIGNAL, profinet::PNDCPHeader::frameId, profinet::PNDCPHeader::length, profinet::PNDCPBlockRequest::length, profinet::PNDCPBlockRequest::option, profinet::PNDCPHeader::payload, profinet::PNDCPBlockRequest::payload, profinet::PNDCPHeader::respDelay, profinet::PNDCPHeader::serviceId, profinet::PNDCPHeader::serviceType, profinet::PNDCPBlockRequest::suboption, profinet::PNDCPBlockRequest::ToBytes(), and profinet::PNDCPHeader::xId.
Referenced by BuildDcpSignalRequest(), and SignalDevice().
Here is the call graph for this function:
Here is the caller graph for this function:| Bytes profinet::dcp::BuildSetParamRequest | ( | const MacAddress & | dst, |
| const MacAddress & | src, | ||
| const std::string & | param, | ||
| const std::string & | value, | ||
| bool | permanent | ||
| ) |
Build a serialized DCP SET request for a named parameter.
Creates the complete Ethernet frame containing a DCP SET request.
For the NameOfStation parameter, the generated block contains the BlockQualifier followed by the station name. Odd-length values receive one zero padding byte on the wire while the DCP BlockLength excludes that alignment byte.
IP configuration requires the binary IP suite representation (IP address + subnet mask + gateway). The string-valued SET API intentionally rejects IP configuration and callers must use SetIp().
| dst | Destination device MAC address. |
| src | Source/controller MAC address. |
| param | Parameter name, such as "name". |
| value | Parameter value. |
| permanent | Whether the requested value should be stored permanently. |
| DCPError | If the parameter name is unknown. |
| ValidationError | If the parameter value violates DCP constraints. |
Definition at line 756 of file dcp.cpp.
References BuildSetParamRequest(), DCP_GET_SET_FRAME_ID, DCP_MAX_NAME_LENGTH, profinet::PNDCPHeader::frameId, profinet::PNDCPHeader::length, profinet::PNDCPBlockRequest::length, profinet::PNDCPBlockRequest::option, Params(), profinet::PNDCPHeader::payload, profinet::PNDCPBlockRequest::payload, profinet::PNDCPHeader::respDelay, profinet::PNDCPHeader::serviceId, profinet::PNDCPHeader::serviceType, profinet::PNDCPBlockRequest::suboption, profinet::PNDCPBlockRequest::ToBytes(), profinet::ToVec(), and profinet::PNDCPHeader::xId.
Referenced by BuildSetParamRequest(), and SetParam().
Here is the call graph for this function:
Here is the caller graph for this function:| std::string profinet::dcp::DcpBlockErrorName | ( | std::uint8_t | code | ) |
Get the human-readable name for a DCP SET block-level error code.
| code | Raw block error code. |
Definition at line 430 of file dcp.cpp.
References DcpBlockErrorName(), and profinet::Hex2().
Referenced by DcpBlockErrorName(), ResetToFactory(), SetIp(), SetParam(), and SignalDevice().
Here is the call graph for this function:
Here is the caller graph for this function:| std::vector< std::string > profinet::dcp::DecodeDeviceRole | ( | std::uint8_t | roleByte | ) |
Decode a device role bitmask into a list of role names.
| roleByte | Raw device role bitmask byte. |
Definition at line 146 of file dcp.cpp.
Referenced by profinet::dcp::DCPDeviceDescription::DCPDeviceDescription().
Here is the caller graph for this function:| std::string profinet::dcp::GetBlockName | ( | std::uint8_t | option, |
| std::uint8_t | suboption | ||
| ) |
Get the human-readable name for a (option, suboption) DCP block.
| option | DCP option code. |
| suboption | DCP suboption code. |
Definition at line 163 of file dcp.cpp.
References profinet::Hex2().
Referenced by profinet::dcp::DCPDeviceDescription::ToString().
Here is the call graph for this function:
Here is the caller graph for this function:| std::optional< Bytes > profinet::dcp::GetParam | ( | const EthernetSocket & | sock, |
| const MacAddress & | src, | ||
| const std::string & | target, | ||
| const std::string & | param, | ||
| int | timeoutSec = DEFAULT_TIMEOUT |
||
| ) |
Read a named parameter from a device.
| sock | Bound Ethernet socket to send/receive on. |
| src | Source MAC address to send from. |
| target | Destination device's MAC address, as a string. |
| param | Parameter name ("name" or "ip"); see Params(). |
| timeoutSec | How long to wait for a response. |
Throws DCPError for an unknown parameter name.
Definition at line 880 of file dcp.cpp.
References DCP_GET_SET_FRAME_ID, profinet::PNDCPHeader::frameId, GetParam(), profinet::PNDCPHeader::length, profinet::PNDCPBlockRequest::length, profinet::PNDCPBlockRequest::option, Params(), profinet::PNDCPHeader::payload, ReadResponse(), profinet::PNDCPHeader::respDelay, profinet::EthernetSocket::Send(), profinet::PNDCPHeader::serviceId, profinet::PNDCPHeader::serviceType, profinet::String2Mac(), profinet::PNDCPBlockRequest::suboption, profinet::PNDCPBlockRequest::ToBytes(), and profinet::PNDCPHeader::xId.
Referenced by GetParam().
Here is the call graph for this function:
Here is the caller graph for this function:| const std::map< std::string, BlockKey > & profinet::dcp::Params | ( | ) |
Table of supported parameter names, mapping to their (option, suboption).
Definition at line 480 of file dcp.cpp.
References Params().
Referenced by BuildSetParamRequest(), GetParam(), and Params().
Here is the call graph for this function:
Here is the caller graph for this function:| std::uint8_t profinet::dcp::ParseSetResponse | ( | const Bytes & | data | ) |
Parses the raw byte response payload received from a SET operation.
| data | Reference to the byte container containing the response payload. |
Parse a DCP SET response and extract the block error code. Throws DCPError on malformed/unexpected frames.
Definition at line 258 of file dcp.cpp.
References DCP_BLOCK_ERROR_OK, DCP_OPTION_CONTROL, DCP_SERVICE_TYPE_RESPONSE_SUCCESS, DCP_SERVICE_TYPE_RESPONSE_UNSUPPORTED, DCP_SUBOPTION_CONTROL_RESPONSE, profinet::Hex2(), profinet::Hex4(), profinet::OneOctetShift, profinet::EthernetHeader::Parse(), profinet::PNDCPHeader::Parse(), profinet::EthernetHeader::payload, profinet::PNDCPHeader::payload, payload, profinet::PROFINET_ETHERTYPE, profinet::PNDCPHeader::serviceType, profinet::EthernetHeader::type, and profinet::VLAN_ETHERTYPE.
Referenced by RecvSetResponse().
Here is the call graph for this function:
Here is the caller graph for this function:| 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.
| sock | Bound Ethernet socket to receive on. |
| myMac | This host's MAC address, used to filter responses addressed to us. |
| timeoutSec | How long to keep listening for responses. |
| once | If true, return after the first response. |
| expectedXid | If set, only accept responses matching this transaction ID. |
Definition at line 1048 of file dcp.cpp.
References profinet::EthernetHeader::dst, profinet::PNDCPHeader::length, profinet::EthernetHeader::payload, profinet::PNDCPHeader::payload, payload, profinet::PROFINET_ETHERTYPE, ReadResponse(), profinet::EthernetSocket::Recv(), profinet::PNDCPHeader::serviceType, profinet::EthernetSocket::SetTimeout(), profinet::EthernetHeader::src, profinet::EthernetHeader::type, profinet::VLAN_ETHERTYPE, and profinet::PNDCPHeader::xId.
Referenced by profinet::device::ProfinetDevice::Discover(), profinet::device::ProfinetDevice::FromIp(), GetParam(), profinet::rpc::GetStationInfo(), ReadResponse(), and profinet::device::Scan().
Here is the call graph for this function:
Here is the caller graph for this function:| 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.
| sock | Bound Ethernet socket to receive on. |
| myMac | This host's MAC address (currently unused for filtering; Hello is multicast). |
| timeoutSec | How long to keep listening. |
| callback | Optional callback invoked for each device as it's discovered. |
Definition at line 1214 of file dcp.cpp.
References profinet::EthernetHeader::payload, profinet::PNDCPHeader::payload, payload, profinet::PROFINET_ETHERTYPE, ReceiveHello(), profinet::EthernetSocket::Recv(), profinet::PNDCPHeader::serviceId, profinet::PNDCPHeader::serviceType, profinet::EthernetSocket::SetTimeout(), profinet::EthernetHeader::src, profinet::EthernetHeader::type, and profinet::VLAN_ETHERTYPE.
Referenced by ReceiveHello().
Here is the call graph for this function:
Here is the caller graph for this function:| 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.
| sock | Raw Ethernet socket used to receive frames. |
| srcMac | Destination MAC address expected in the received response. |
| timeoutSec | Maximum time in seconds to wait for a valid response. |
| DCPTimeoutError | If no valid DCP SET response is received before the timeout. |
| DCPError | If a matching frame contains an invalid DCP SET response. |
Definition at line 195 of file dcp.cpp.
References profinet::EthernetHeader::dst, profinet::OneOctetShift, profinet::EthernetHeader::Parse(), ParseSetResponse(), profinet::EthernetHeader::payload, payload, profinet::PROFINET_ETHERTYPE, profinet::IRawEthernetSocket::Recv(), profinet::IRawEthernetSocket::SetTimeout(), profinet::EthernetHeader::type, and profinet::VLAN_ETHERTYPE.
Referenced by ResetToFactory(), SetIp(), SetParam(), and SignalDevice().
Here is the call graph for this function:
Here is the caller graph for this function:| 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.
| sock | Bound Ethernet socket to send/receive on. |
| src | Source MAC address to send from. |
| target | Destination device's MAC address, as a string. |
| mode | Reset mode bitmask (see RESET_MODE_* constants). |
| timeoutSec | How long to wait for a response. |
WARNING: destructive. This erases device configuration.
Definition at line 1328 of file dcp.cpp.
References DCP_BLOCK_ERROR_OK, DCP_GET_SET_FRAME_ID, DCP_OPTION_CONTROL, DCP_SUBOPTION_CONTROL_RESET_TO_FACTORY, DcpBlockErrorName(), profinet::PNDCPHeader::frameId, profinet::PNDCPHeader::length, profinet::PNDCPBlockRequest::length, profinet::PNDCPBlockRequest::option, profinet::PNDCPHeader::payload, profinet::PNDCPBlockRequest::payload, RecvSetResponse(), ResetToFactory(), profinet::PNDCPHeader::respDelay, profinet::EthernetSocket::Send(), profinet::PNDCPHeader::serviceId, profinet::PNDCPHeader::serviceType, profinet::String2Mac(), profinet::PNDCPBlockRequest::suboption, profinet::PNDCPBlockRequest::ToBytes(), and profinet::PNDCPHeader::xId.
Referenced by ResetToFactory().
Here is the call graph for this function:
Here is the caller graph for this function:| 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.
| sock | Bound Ethernet socket to send on. |
| src | Source MAC address to send from. |
| responseDelay | Response delay factor controlling how devices stagger their replies. |
Definition at line 1003 of file dcp.cpp.
References DCP_IDENTIFY_REQUEST_FRAME_ID, DCP_MULTICAST_MAC, profinet::PNDCPHeader::frameId, profinet::PNDCPHeader::length, profinet::PNDCPBlockRequest::length, profinet::PNDCPBlockRequest::option, profinet::PNDCPHeader::payload, profinet::PNDCPHeader::respDelay, profinet::EthernetSocket::Send(), SendDiscover(), profinet::PNDCPHeader::serviceId, profinet::PNDCPHeader::serviceType, profinet::String2Mac(), profinet::PNDCPBlockRequest::suboption, profinet::PNDCPBlockRequest::ToBytes(), and profinet::PNDCPHeader::xId.
Referenced by profinet::device::ProfinetDevice::Discover(), profinet::device::ProfinetDevice::FromIp(), profinet::rpc::GetStationInfo(), profinet::device::Scan(), and SendDiscover().
Here is the call graph for this function:
Here is the caller graph for this function:| 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).
| sock | Bound Ethernet socket to send on. |
| src | Source MAC address to send from. |
| stationName | Station name to announce. |
| ip | IPv4 address to announce. |
| netmask | IPv4 subnet mask to announce. |
| gateway | IPv4 default gateway to announce. |
| deviceId | (vendor_id, device_id) pair to announce. |
| deviceRole | Device role bitmask to announce. |
Definition at line 1135 of file dcp.cpp.
References DCP_HELLO_FRAME_ID, DCP_HELLO_MULTICAST_MAC, DCP_OPTION_DEVICE, DCP_OPTION_DEVICE_INITIATIVE, DCP_OPTION_IP, DCP_SUBOPTION_DEVICE_ID, DCP_SUBOPTION_DEVICE_INITIATIVE, DCP_SUBOPTION_DEVICE_NAME, DCP_SUBOPTION_DEVICE_ROLE, DCP_SUBOPTION_IP_PARAMETER, profinet::PNDCPHeader::frameId, profinet::Ip2String(), profinet::PNDCPHeader::length, profinet::PNDCPBlockRequest::length, profinet::PNDCPBlockRequest::option, profinet::PNDCPHeader::payload, profinet::PNDCPBlockRequest::payload, profinet::PNDCPHeader::respDelay, profinet::EthernetSocket::Send(), SendHello(), profinet::PNDCPHeader::serviceId, profinet::PNDCPHeader::serviceType, profinet::String2Mac(), profinet::PNDCPBlockRequest::suboption, profinet::PNDCPBlockRequest::ToBytes(), profinet::ToVec(), and profinet::PNDCPHeader::xId.
Referenced by SendHello().
Here is the call graph for this function:
Here is the caller graph for this function:| void profinet::dcp::SendRequest | ( | const EthernetSocket & | sock, |
| const MacAddress & | src, | ||
| BlockKey | blockType, | ||
| const std::vector< std::uint8_t > & | value | ||
| ) |
Send a DCP Identify request filtered to a specific (option, suboption).
| sock | Bound Ethernet socket to send on. |
| src | Source MAC address to send from. |
| blockType | (option, suboption) pair to filter by. |
| value | Filter value to match. |
Definition at line 1025 of file dcp.cpp.
References DCP_IDENTIFY_REQUEST_FRAME_ID, DCP_MULTICAST_MAC, profinet::PNDCPHeader::frameId, profinet::PNDCPHeader::length, profinet::PNDCPBlockRequest::length, profinet::PNDCPBlockRequest::option, profinet::PNDCPHeader::payload, profinet::PNDCPBlockRequest::payload, profinet::PNDCPHeader::respDelay, profinet::EthernetSocket::Send(), SendRequest(), profinet::PNDCPHeader::serviceId, profinet::PNDCPHeader::serviceType, profinet::String2Mac(), profinet::PNDCPBlockRequest::suboption, profinet::PNDCPBlockRequest::ToBytes(), and profinet::PNDCPHeader::xId.
Referenced by profinet::rpc::GetStationInfo(), and SendRequest().
Here is the call graph for this function:
Here is the caller graph for this function:| void profinet::dcp::SendRequest | ( | const EthernetSocket & | sock, |
| const MacAddress & | src, | ||
| BlockKey | blockType, | ||
| const std::vector< std::uint8_t > & | value | ||
| ) |
Send a DCP Identify request filtered to a specific (option, suboption).
| sock | Bound Ethernet socket to send on. |
| src | Source MAC address to send from. |
| blockType | (option, suboption) pair to filter by. |
| value | Filter value to match. |
Definition at line 1025 of file dcp.cpp.
References DCP_IDENTIFY_REQUEST_FRAME_ID, DCP_MULTICAST_MAC, profinet::PNDCPHeader::frameId, profinet::PNDCPHeader::length, profinet::PNDCPBlockRequest::length, profinet::PNDCPBlockRequest::option, profinet::PNDCPHeader::payload, profinet::PNDCPBlockRequest::payload, profinet::PNDCPHeader::respDelay, profinet::EthernetSocket::Send(), SendRequest(), profinet::PNDCPHeader::serviceId, profinet::PNDCPHeader::serviceType, profinet::String2Mac(), profinet::PNDCPBlockRequest::suboption, profinet::PNDCPBlockRequest::ToBytes(), and profinet::PNDCPHeader::xId.
Referenced by profinet::rpc::GetStationInfo(), and SendRequest().
Here is the call graph for this function:
Here is the caller graph for this function:| 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.
| sock | Bound Ethernet socket to send/receive on. |
| src | Source MAC address to send from. |
| target | Destination device's MAC address, as a string. |
| ip | New IPv4 address. |
| netmask | New IPv4 subnet mask. |
| gateway | New IPv4 default gateway. |
| permanent | Whether the change should persist across power cycles. |
| timeoutSec | How long to wait for a response. |
Definition at line 950 of file dcp.cpp.
References DCP_BLOCK_ERROR_OK, DCP_GET_SET_FRAME_ID, DcpBlockErrorName(), profinet::PNDCPHeader::frameId, profinet::Ip2String(), profinet::PNDCPHeader::length, profinet::PNDCPBlockRequest::length, profinet::PNDCPBlockRequest::option, profinet::PNDCPHeader::payload, profinet::PNDCPBlockRequest::payload, RecvSetResponse(), profinet::PNDCPHeader::respDelay, profinet::EthernetSocket::Send(), profinet::PNDCPHeader::serviceId, profinet::PNDCPHeader::serviceType, SetIp(), profinet::String2Mac(), profinet::PNDCPBlockRequest::suboption, profinet::PNDCPBlockRequest::ToBytes(), and profinet::PNDCPHeader::xId.
Referenced by SetIp().
Here is the call graph for this function:
Here is the caller graph for this function:| bool profinet::dcp::SetParam | ( | const EthernetSocket & | sock, |
| const MacAddress & | src, | ||
| const std::string & | target, | ||
| const std::string & | param, | ||
| const std::string & | value, | ||
| int | timeoutSec = DEFAULT_TIMEOUT, |
||
| bool | permanent = false |
||
| ) |
Write a named parameter to a device.
| sock | Bound Ethernet socket to send/receive on. |
| src | Source MAC address to send from. |
| target | Destination device's MAC address, as a string. |
| param | Parameter name ("name" or "ip"); see Params(). |
| value | New value to write. |
| timeoutSec | How long to wait for a response. |
| permanent | If true, request permanent storage (survives power cycle); default writes a temporary value |
Throws DCPError on an unknown parameter, or if the device rejects the value; throws ValidationError if a station name exceeds DCP_MAX_NAME_LENGTH.
Definition at line 922 of file dcp.cpp.
References BuildSetParamRequest(), DCP_BLOCK_ERROR_OK, DcpBlockErrorName(), RecvSetResponse(), profinet::EthernetSocket::Send(), SetParam(), and profinet::String2Mac().
Referenced by SetParam().
Here is the call graph for this function:
Here is the caller graph for this function:| 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.
| sock | Bound Ethernet socket to send/receive on. |
| src | Source MAC address to send from. |
| target | Destination device's MAC address, as a string. |
| durationMs | How long the device should flash its LEDs, in milliseconds. |
| timeoutSec | How long to wait for a response. – Ignored; the spec defines only "flash once" and the device controls the blink pattern. Kept for API compatibility |
Definition at line 1307 of file dcp.cpp.
References BuildDcpSignalRequest(), DCP_BLOCK_ERROR_OK, DcpBlockErrorName(), RecvSetResponse(), profinet::EthernetSocket::Send(), SignalDevice(), and profinet::String2Mac().
Referenced by SignalDevice().
Here is the call graph for this function:
Here is the caller graph for this function:
|
inlineconstexpr |
|
inlineconstexpr |
DCP SET block-level result: OK.
Definition at line 366 of file dcp.h.
Referenced by ParseSetResponse(), ResetToFactory(), SetIp(), SetParam(), and SignalDevice().
|
inlineconstexpr |
|
inlineconstexpr |
|
inlineconstexpr |
|
inlineconstexpr |
|
inlineconstexpr |
|
inlineconstexpr |
Frame ID for DCP Get/Set requests and responses.
Definition at line 64 of file dcp.h.
Referenced by BuildDcpSignalRequest(), BuildSetParamRequest(), GetParam(), ResetToFactory(), and SetIp().
|
inlineconstexpr |
Frame ID for DCP Hello announcements.
Definition at line 66 of file dcp.h.
Referenced by SendHello().
|
inline |
DCP Hello multicast destination MAC.
Definition at line 57 of file dcp.h.
Referenced by SendHello().
|
inlineconstexpr |
Frame ID for DCP Identify requests.
Definition at line 60 of file dcp.h.
Referenced by SendDiscover(), and SendRequest().
|
inlineconstexpr |
|
inlineconstexpr |
Maximum allowed length in bytes for a station name.
Definition at line 85 of file dcp.h.
Referenced by BuildSetParamRequest().
|
inline |
DCP Identify/Get/Set multicast destination MAC.
Definition at line 55 of file dcp.h.
Referenced by SendDiscover(), and SendRequest().
|
inlineconstexpr |
|
inlineconstexpr |
DCP option: control (start/stop/signal/reset).
Definition at line 96 of file dcp.h.
Referenced by BuildDcpSignalRequest(), ParseSetResponse(), and ResetToFactory().
|
inlineconstexpr |
DCP option: device identification.
Definition at line 90 of file dcp.h.
Referenced by profinet::dcp::DCPDeviceDescription::DCPDeviceDescription(), and SendHello().
|
inlineconstexpr |
DCP option: device-initiative (Hello) configuration.
Definition at line 98 of file dcp.h.
Referenced by profinet::dcp::DCPDeviceDescription::DCPDeviceDescription(), and SendHello().
|
inlineconstexpr |
DCP option: DHCP.
Definition at line 92 of file dcp.h.
Referenced by profinet::dcp::DCPDeviceDescription::DCPDeviceDescription(), and profinet::dcp::DCPDHCPBlock::Parse().
|
inlineconstexpr |
|
inlineconstexpr |
|
inlineconstexpr |
|
inlineconstexpr |
|
inlineconstexpr |
|
inlineconstexpr |
|
inlineconstexpr |
|
inlineconstexpr |
|
inlineconstexpr |
DCP service type: RESPONSE (success).
Definition at line 80 of file dcp.h.
Referenced by ParseSetResponse().
|
inlineconstexpr |
DCP service type: RESPONSE (service unsupported).
Definition at line 82 of file dcp.h.
Referenced by ParseSetResponse().
|
inlineconstexpr |
|
inlineconstexpr |
DCP suboption (Control): reset to factory.
Definition at line 141 of file dcp.h.
Referenced by ResetToFactory().
|
inlineconstexpr |
DCP suboption (Control): response.
Definition at line 137 of file dcp.h.
Referenced by ParseSetResponse().
|
inlineconstexpr |
DCP suboption (Control): signal (flash LEDs).
Definition at line 135 of file dcp.h.
Referenced by BuildDcpSignalRequest().
|
inlineconstexpr |
|
inlineconstexpr |
|
inlineconstexpr |
DCP suboption (Device): alias name.
Definition at line 122 of file dcp.h.
Referenced by profinet::dcp::DCPDeviceDescription::DCPDeviceDescription().
|
inlineconstexpr |
DCP suboption (Device): vendor/device ID.
Definition at line 116 of file dcp.h.
Referenced by SendHello().
|
inlineconstexpr |
DCP suboption (DeviceInitiative): the only suboption.
Definition at line 163 of file dcp.h.
Referenced by profinet::dcp::DCPDeviceDescription::DCPDeviceDescription(), and SendHello().
|
inlineconstexpr |
DCP suboption (Device): device instance.
Definition at line 124 of file dcp.h.
Referenced by profinet::dcp::DCPDeviceDescription::DCPDeviceDescription().
|
inlineconstexpr |
DCP suboption (Device): station name.
Definition at line 114 of file dcp.h.
Referenced by SendHello().
|
inlineconstexpr |
|
inlineconstexpr |
|
inlineconstexpr |
DCP suboption (Device): device role bitmask.
Definition at line 118 of file dcp.h.
Referenced by SendHello().
|
inlineconstexpr |
|
inlineconstexpr |
|
inlineconstexpr |
|
inlineconstexpr |
DCP suboption (DHCP): client identifier option.
Definition at line 154 of file dcp.h.
Referenced by profinet::dcp::DCPDHCPBlock::Parse().
|
inlineconstexpr |
|
inlineconstexpr |
DCP suboption (DHCP): fully qualified domain name option.
Definition at line 156 of file dcp.h.
Referenced by profinet::dcp::DCPDHCPBlock::Parse().
|
inlineconstexpr |
DCP suboption (DHCP): hostname option.
Definition at line 144 of file dcp.h.
Referenced by profinet::dcp::DCPDHCPBlock::Parse().
|
inlineconstexpr |
|
inlineconstexpr |
|
inlineconstexpr |
DCP suboption (DHCP): client UUID option.
Definition at line 158 of file dcp.h.
Referenced by profinet::dcp::DCPDHCPBlock::Parse().
|
inlineconstexpr |
DCP suboption (DHCP): vendor-specific option.
Definition at line 146 of file dcp.h.
Referenced by profinet::dcp::DCPDHCPBlock::Parse().
|
inlineconstexpr |
|
inlineconstexpr |
|
inlineconstexpr |
DCP suboption (IP): IP/netmask/gateway parameter.
Definition at line 107 of file dcp.h.
Referenced by SendHello().
|
inlineconstexpr |
|
inlineconstexpr |
|
inlineconstexpr |
|
inlineconstexpr |
|
inlineconstexpr |
|
inlineconstexpr |
|
inlineconstexpr |
|
inlineconstexpr |
|
inlineconstexpr |
|
inlineconstexpr |
|
inlineconstexpr |
|
inlineconstexpr |
|
inlineconstexpr |
|
inlineconstexpr |