36#define MAGIC_ENUM_RANGE_MIN 0
37#define MAGIC_ENUM_RANGE_MAX 255
42#include <magic_enum.hpp>
55using Bytes = std::vector<std::uint8_t>;
279 return static_cast<DcpDeviceRole>(
static_cast<std::uint8_t
>(lhs) |
static_cast<std::uint8_t
>(rhs));
284 return static_cast<DcpDeviceRole>(
static_cast<std::uint8_t
>(lhs) &
static_cast<std::uint8_t
>(rhs));
311 return static_cast<DcpResetMode>(
static_cast<std::uint16_t
>(lhs) |
static_cast<std::uint16_t
>(rhs));
316 return static_cast<DcpResetMode>(
static_cast<std::uint16_t
>(lhs) &
static_cast<std::uint16_t
>(rhs));
497 const int expectedEthernetHeaderSize = 14;
498 if (data.size() < expectedEthernetHeaderSize)
500 throw std::runtime_error(
"EthernetHeader: insufficient data");
550 const int expectedEthernetVLANHeaderSize = 18;
552 if (data.size() < expectedEthernetVLANHeaderSize)
554 throw std::runtime_error(
"EthernetVLANHeader: insufficient data");
621 throw std::runtime_error(
"PNDCPHeader: insufficient data");
690 throw std::runtime_error(
"PNDCPBlockRequest: insufficient data");
719 const int defaultIPConfigurationBlockLength = 12;
720 if (
payload.size() < defaultIPConfigurationBlockLength)
722 throw std::runtime_error(
"PNDCPBlockRequest: short IP payload");
724 const int ipAddressIndex = 0;
725 const int netmaskIndex = 4;
726 const int gatewayIndex = 8;
755 static constexpr std::pair<std::uint8_t, std::uint8_t>
IP_MAC{1, 1};
758 static constexpr std::pair<std::uint8_t, std::uint8_t>
IP_ADDRESS{1, 2};
764 static constexpr std::pair<std::uint8_t, std::uint8_t>
DEVICE_TYPE{2, 1};
770 static constexpr std::pair<std::uint8_t, std::uint8_t>
DEVICE_ID{2, 3};
773 static constexpr std::pair<std::uint8_t, std::uint8_t>
DEVICE_ROLE{2, 4};
779 static constexpr std::pair<std::uint8_t, std::uint8_t>
DEVICE_ALIAS{2, 6};
788 static constexpr std::pair<std::uint8_t, std::uint8_t>
ALL{0xFF, 0xFF};
801 throw std::runtime_error(
"PNDCPBlock: insufficient data");
811 std::size_t plSize = b.
length >= 2 ?
static_cast<std::size_t
>(b.
length - 2) : 0;
835 const int defaultIPConfigurationBlockLength = 12;
836 if (
payload.size() < defaultIPConfigurationBlockLength)
838 throw std::runtime_error(
"PNDCPBlock: short IP payload");
840 const int ipAddressIndex = 0;
841 const int netmaskIndex = 4;
842 const int gatewayIndex = 8;
856 0x6C, 0x97, 0x11, 0xD1, 0x82, 0x71, 0x00, 0xA0, 0x24, 0x42, 0xDF, 0x7D};
866 static constexpr std::uint8_t
PING = 0x01;
872 static constexpr std::uint8_t
FAULT = 0x03;
878 static constexpr std::uint8_t
PONG = 0x05;
881 static constexpr std::uint8_t
REJECT = 0x06;
884 static constexpr std::uint8_t
ACK = 0x07;
887 static constexpr std::uint8_t
CANCEL = 0x08;
896 static constexpr std::uint16_t
CONNECT = 0x00;
899 static constexpr std::uint16_t
RELEASE = 0x01;
902 static constexpr std::uint16_t
READ = 0x02;
905 static constexpr std::uint16_t
WRITE = 0x03;
908 static constexpr std::uint16_t
CONTROL = 0x04;
1016 throw std::runtime_error(
"PNRPCHeader: insufficient data");
1112 static std::array<std::uint8_t, uuidLenght>
PrefixedUuid(std::uint8_t b2, std::uint8_t b3)
1114 std::array<std::uint8_t, uuidLenght> u{};
1157 throw std::runtime_error(
"PNNRDData: insufficient data");
1202 std::array<std::uint8_t, uuidLenght>
arUuid{};
1241 throw std::runtime_error(
"PNIODHeader: insufficient data");
1292 static constexpr std::uint16_t
InM0 = 0x0020;
1323 static constexpr std::size_t
kSize =
sizeof(std::uint16_t) +
sizeof(std::uint16_t) + (2 *
sizeof(std::uint8_t));
1330 if (data.size() <
kSize)
1332 throw std::runtime_error(
"PNBlockHeader: insufficient data");
1368 std::array<std::uint8_t, uuidLenght>
arUuid{};
1407 throw std::runtime_error(
"PNARBlockRequest: insufficient data");
1457 std::array<std::uint8_t, uuidLenght>
arUuid{};
1472 static constexpr std::size_t
kSize = 32;
1479 if (data.size() <
kSize)
1481 throw std::runtime_error(
"PNIODReleaseBlock: insufficient data");
1520 static constexpr std::uint16_t
IDX = 0xAFF0;
1572 static constexpr std::size_t
kSize = 60;
1586 if (data.size() <
kSize)
1588 throw std::runtime_error(
"PNInM0: insufficient data");
1627 static constexpr std::uint16_t
IDX = 0xAFF1;
1640 static constexpr std::size_t
kSize = 60;
1647 if (data.size() <
kSize)
1649 throw std::runtime_error(
"PNInM1: insufficient data");
1671 static constexpr std::uint16_t
IDX = 0xAFF2;
1681 static constexpr std::size_t
kSize = 22;
1688 if (data.size() <
kSize)
1690 throw std::runtime_error(
"PNInM2: insufficient data");
1712 static constexpr std::uint16_t
IDX = 0xAFF3;
1722 static constexpr std::size_t
kSize = 60;
1729 if (data.size() <
kSize)
1731 throw std::runtime_error(
"PNInM3: insufficient data");
1752 static constexpr std::uint16_t
IDX = 0xAFF4;
1762 static constexpr std::size_t
kSize = 60;
1769 if (data.size() <
kSize)
1771 throw std::runtime_error(
"PNInM4: insufficient data");
1792 static constexpr std::uint16_t
IDX = 0xAFF5;
1802 static constexpr std::size_t
kSize = 70;
1809 if (data.size() <
kSize)
1811 throw std::runtime_error(
"PNInM5: insufficient data");
1831template <std::u
int16_t Idx>
1836 static constexpr std::uint16_t
IDX = Idx;
1850 if (data.size() < 6)
1852 throw std::runtime_error(
"PNInMReserved: insufficient data");
1914 if (data.size() <
kSize)
1916 throw std::runtime_error(
"IOCRAPIObject: insufficient data");
1959 static constexpr std::size_t
kSize = 12;
1966 if (data.size() <
kSize)
1968 throw std::runtime_error(
"PNIOCRBlockRes: insufficient data");
2042 static constexpr std::size_t
kSize = 46;
2050 if (data.size() <
kSize)
2052 throw std::runtime_error(
2053 "IOCRBlockReq too short, insufficient data: " +
2054 std::to_string(data.size()) +
2055 " bytes, expected at least " +
2056 std::to_string(
kSize));
2167 static constexpr std::size_t
kSize = 26;
2174 if (data.size() <
kSize)
2176 throw std::runtime_error(
"PNAlarmCRBlockReq: insufficient data");
2235 static constexpr std::size_t
kSize = 12;
2242 if (data.size() <
kSize)
2244 throw std::runtime_error(
"PNAlarmCRBlockRes: insufficient data");
2328 throw std::runtime_error(
"PNAlarmNotificationPDU: insufficient data");
2370 static constexpr std::size_t
kSize = 22;
2452 throw std::runtime_error(
"PNRTAHeader: insufficient data");
2656 [[nodiscard]] std::string
ReasonName()
const;
2682 const auto rtaType =
static_cast<std::uint8_t
>(header.
pduType & 0x0FU);
2686 throw std::invalid_argument(
"RTA PDU is not ERR-RTA");
2691 throw std::invalid_argument(
"RTA ERR-PDU variable part must be 4 bytes");
2696 throw std::invalid_argument(
"Truncated RTA ERR-PDU payload");
2708 (
static_cast<std::uint32_t
>(result.
errorCode) << 24U) |
2709 (
static_cast<std::uint32_t
>(result.
errorDecode) << 16U) |
2710 (
static_cast<std::uint32_t
>(result.
errorCode1) << 8U) |
2711 static_cast<std::uint32_t
>(result.
errorCode2);
2781 std::array<std::uint8_t, uuidLenght>
arUuid{};
2845 std::array<std::uint8_t, uuidLenght>
arUuid{};
2878 static constexpr std::size_t
kSize = 64;
2885 if (data.size() <
kSize)
2887 throw std::runtime_error(
"PNIODWriteRes: insufficient data");
Lightweight cursor for parsing a big-endian byte buffer without copies.
std::uint8_t U8()
Read and consume one byte.
std::uint32_t U32()
Read and consume a big-endian 32-bit value.
std::size_t Remaining() const
Number of bytes not yet consumed.
std::array< std::uint8_t, N > Fixed()
Read and consume a fixed-size byte array.
void SkipTo(std::size_t offset)
Move the read position to an absolute byte offset.
std::vector< std::uint8_t > ReadBytes(std::size_t n)
Read and consume a variable-length byte range.
std::uint16_t U16()
Read and consume a big-endian 16-bit value.
PROFINET record-data indices, block types, and protocol enumerations.
void PutFixed(std::vector< std::uint8_t > &out, const std::array< std::uint8_t, N > &data)
Append a fixed-size byte array to a buffer.
void PutU8(std::vector< std::uint8_t > &out, std::uint8_t value)
Append a single byte to a buffer.
void PutU16(std::vector< std::uint8_t > &out, std::uint16_t value)
Append a 16-bit value to a buffer in big-endian order.
void PutU32(std::vector< std::uint8_t > &out, std::uint32_t value)
Append a 32-bit value to a buffer in big-endian order.
constexpr AlarmNotificationBitmask operator&(AlarmNotificationBitmask lhs, AlarmNotificationBitmask rhs) noexcept
Bitwise AND operator for intersecting two AlarmNotificationBitmask values.
DcpBlockQualifier
DCP block qualifier values.
@ Temporary
Change applies until the next power cycle only.
@ Permanent
Change is persisted permanently.
DcpIpSuboption
DCP IP suboptions.
@ FullIpSuite
Full IP suite.
@ IpParameter
IP address, subnet mask and gateway.
BlockType
PROFINET block types.
@ IoCrRequest
IOCR block request.
@ AlarmCrRequest
AlarmCR block request.
@ IoDataReadRequest
IOD read request block.
DcpDeviceInitiativeSuboption
DCP DeviceInitiative suboptions.
@ Initiative
Device-initiative setting.
DcpDhcpSuboption
DCP DHCP suboptions.
@ Fqdn
Fully qualified domain name.
@ ClassId
Class identifier.
@ ParamReq
Parameter request list.
@ ServerId
Server identifier.
@ ClientId
Client identifier.
@ VendorSpec
Vendor-specific option.
constexpr int uuidLenght
Constant lenght of a UUID.
DcpControlSuboption
DCP Control suboptions.
@ Signal
Signal / flash LEDs.
@ Response
Control response.
@ FactoryReset
Factory reset.
@ ResetToFactory
Reset to factory.
constexpr int blockHeaderLength
Constant lenght of a blockHeader.
DcpBlockError
DCP block-level SET response errors.
@ SetNotPossible
SET not possible for local reasons.
@ OptionUnsupported
Option not supported.
@ SuboptionUnsupported
Suboption not supported or no dataset available.
@ SuboptionNotSet
Suboption not set.
@ InOperation
SET not possible because the device is in operation.
std::string String2Ip(std::span< const std::uint8_t > ipBytes)
Format raw IPv4 address bytes as a dotted string.
std::array< std::uint8_t, macAddressLength > MacAddress
A 6-byte Ethernet MAC address.
AlarmType
PROFINET Alarm Types used in AlarmNotification blocks.
DcpResetMode
Reset mode bitmask.
@ Communication
Reset communication parameters.
@ Factory
Reset to factory defaults.
@ AllData
Reset all stored data.
@ Engineering
Reset engineering parameters.
RtaErrorReason
Exact current PROFINET RTA ErrorCode2 values.
@ PdevPlugPortWithoutCombinedObjectContainer
@ ArAddProviderConsumerFailed
@ ArRpcClientCallConfirmationNegative
@ PdevNoRequiredSpeedDuplexity
@ IocarSrRedundantInterfaceLost
@ IocarSrPdevParameterizationImpossible
@ RemoteApplicationReadyTimeout
@ ObsoletedNmeNoConfiguration
@ ArAlarmSendConfirmationNegative
@ ArConsumerDhtWdtExpired
@ CompanionAr8ippSubmodule
@ DcpResetToFactorySettings
@ IocarSrArProtocolViolation
@ ArAlarmAckSendConfirmationNegative
@ ArMulticastMacRegistrationFailed
constexpr AlarmNotificationBitmask operator|(AlarmNotificationBitmask lhs, AlarmNotificationBitmask rhs) noexcept
Bitwise OR operator for combining two AlarmNotificationBitmask values.
RtaError ParseRtaError(const PNRTAHeader &header)
Parse an RTA ERR-PDU from an already parsed RTA header.
ControlCommand
PROFINET IOD control command values.
constexpr int macAddressLength
Constant lenght of a mac address.
DcpFrameId
PROFINET DCP frame identifiers.
@ IdentifyResponse
DCP Identify response.
@ IdentifyRequest
DCP Identify request.
@ GetSet
DCP GET/SET request or response.
@ Unknown
Not set / initialize value.
@ Hello
DCP Hello announcement.
@ Unknown
Not set / initialize value.
@ All
Wildcard: all options.
@ DeviceInitiative
Device initiative.
@ Device
Device identification.
constexpr std::uint16_t PROFINET_ETHERTYPE
EtherType value identifying PROFINET frames (0x8892).
DcpDeviceSuboption
DCP Device suboptions.
@ Rsi
Reverse Status Indication.
@ OemId
OEM vendor/device ID.
@ DeviceId
Vendor and device ID.
@ Instance
Device instance.
@ Options
Supported options.
DcpDeviceInitiative
DCP device-initiative values.
@ NoHello
Device does not issue DCP-Hello after power-on.
@ IssueHello
Device issues DCP-Hello after power-on.
RtaErrorClass
Classification of an RTA protocol error reason.
@ UserSpecific
User-specific RTA abort.
@ SequenceNumber
Error coordinating RTA sequence numbers.
@ Abort
RTA error that aborts the application relation.
@ Obsoleted
Obsoleted reason code.
@ Extended
Additional AR/IOCARSR/PDEV RTA reason defined by PROFINET.
std::vector< std::uint8_t > Bytes
Generic byte buffer alias used throughout the library for raw wire data.
DcpResetQualifier
Reset qualifier values for ResetToFactory().
@ ToFactory
Reset to factory defaults.
@ Restore
Reset and restore from backup.
@ ApplicationData
Reset application data.
@ EngineeringParameterAlternate
Alternative engineering-parameter reset qualifier.
@ RestoreAlternate
Alternative reset-and-restore qualifier.
@ EngineeringParameter
Reset engineering parameters.
@ CommunicationParameterAlternate
Alternative communication-parameter reset qualifier.
@ EngineeringParameterExtendedAlternate
Alternative reset qualifier associated with engineering parameters.
@ ToFactoryAlternate
Alternative reset-to-factory qualifier.
@ AllStoredData
Reset all stored data.
@ CommunicationParameter
Reset communication parameters.
@ ApplicationDataAlternate
Alternative application-data reset qualifier.
@ AllStoredDataAlternate
Alternative all-stored-data reset qualifier.
@ EngineeringParameterExtended
Alternative reset qualifier associated with engineering parameters.
DcpServiceId
DCP service identifiers.
@ Unknown
Not set / initialize value.
@ Identify
IDENTIFY service.
DcpServiceType
DCP service types.
@ ResponseUnsupported
Service unsupported response.
@ ResponseSuccess
Successful response.
DcpIpBlockInfo
PROFINET DCP IP block status values. IP block status flags (IEC 61158-6-10 IPBlockInfo).
@ NotSetConflict
IP address not set; address conflict detected.
@ SetByDhcp
IP address set via DHCP.
@ SetConflict
IP address set statically; address conflict detected.
@ SetByDhcpConflict
IP address set via DHCP; address conflict detected.
@ NotSet
IP address not set.
@ Resource
Resource error.
@ Application
Application error.
constexpr std::array< std::uint8_t, 12 > kPnUuidSuffix
PROFINET UUID suffix, shared by all interface/object UUIDs.
DcpDeviceRole
Device role bitmask.
@ PnSupervisor
PN-Supervisor.
@ IoController
IO-Controller.
@ IoMultidevice
IO-Multidevice.
std::string DecodeBytes(const std::uint8_t *data, std::size_t len)
Decode bytes to a UTF-8 string, stripping trailing NUL bytes.
DcpResponseCode
DCP GET/SET response codes.
@ InOperationSetNotPossible
SET not possible while device is in operation.
@ ResourceError
Resource error.
@ SuboptionNotSupported
Suboption not supported or no dataset available.
@ OptionNotSupported
Option not supported.
Identifies a PROFINET DCP block by option and suboption.
constexpr auto operator<=>(const DcpBlockKey &) const =default
Compares DCP block keys lexicographically.
std::uint8_t suboption
DCP suboption code.
DcpOption option
DCP option.
One slot/subslot's placement within an IOCR's cyclic data frame.
std::uint16_t frameOffset
Byte offset of this object's data within the cyclic frame.
std::uint16_t subslotNumber
Subslot number.
static constexpr std::size_t kSize
Size in bytes of this object.
Bytes ToBytes() const
Serialize this object back to raw bytes.
std::uint16_t slotNumber
Slot number.
static IOCRAPIObject Parse(const Bytes &data)
Parse an IOCR API object from raw bytes.
Decoded IPv4 address/netmask/gateway triple.
std::string gateway
IPv4 default gateway.
std::string netmask
IPv4 subnet mask, e.g. "255.255.255.0".
std::string address
IPv4 address, e.g. "192.168.1.1".
ARBlockReq: establishes an Application Relationship (sent in the CONNECT request).
static PNARBlockRequest Parse(const Bytes &data)
Parse an ARBlockReq from raw bytes.
std::uint32_t arProperties
AR property flags (supervisor takeover, device access, etc.).
std::uint16_t cmInitiatorActivityTimeoutFactor
Activity timeout factor for the initiator.
MacAddress cmInitiatorMacAddress
MAC address of the initiating controller.
std::uint16_t sessionKey
Session key chosen by the initiator.
std::array< std::uint8_t, uuidLenght > arUuid
Unique AR UUID chosen by the initiator (controller).
Bytes cmInitiatorStationName
Station name of the initiating controller (variable length).
Bytes ToBytes() const
Serialize this block back to raw bytes.
Bytes payload
Additional blocks following this one (IOCR/AlarmCR/ExpectedSubmodule).
std::uint16_t arType
AR type (e.g. IOCARSingle, IOSAR).
std::uint16_t initiatorUdpRtport
UDP port the initiator uses for real-time data.
static constexpr std::size_t kFixedSize
Size in bytes of the fixed portion of this block.
std::array< std::uint8_t, blockHeaderLength > blockHeader
Nested 6-byte block header.
std::array< std::uint8_t, uuidLenght > cmInitiatorObjectUuid
Object UUID of the initiating controller.
std::uint16_t stationNameLength
Length in bytes of CmInitiatorStationName.
AlarmAck-PDU: acknowledges receipt of an AlarmNotification-PDU.
std::uint16_t alarmSpecifier
Alarm specifier flags echoed from the notification.
AlarmType alarmType
Alarm type being acknowledged.
std::uint16_t slotNumber
Slot number being acknowledged.
std::array< std::uint8_t, blockHeaderLength > blockHeader
Nested 6-byte block header.
std::uint32_t statusPNIO
PNIO status code (0 = acknowledged OK).
std::uint16_t subslotNumber
Subslot number being acknowledged.
static constexpr std::size_t kSize
Size in bytes of this PDU.
std::uint32_t api
API number.
Bytes ToBytes() const
Serialize this PDU back to raw bytes.
AlarmCRBlockReq: requests establishment of the alarm connection (part of the CONNECT request).
static constexpr std::uint16_t DEFAULT_MAX_ALARM_DATA_LENGTH
Default maximum alarm data length in bytes.
static constexpr std::uint16_t DEFAULT_TAG_HEADER_LOW
Default low word of the alarm VLAN tag header.
static constexpr BlockType BLOCK_TYPE
Block type identifier for AlarmCRBlockReq.
static PNAlarmCRBlockReq Parse(const Bytes &data)
Parse an AlarmCRBlockReq from raw bytes.
Bytes ToBytes() const
Serialize this block back to raw bytes.
static constexpr std::uint16_t DEFAULT_TAG_HEADER_HIGH
Default high word of the alarm VLAN tag header.
std::uint16_t alarmCrType
Alarm CR type (always 1: Alarm).
std::uint16_t etherTypeLT
EtherType used for alarm frames (0x8892).
std::uint32_t alarmCrProperties
Alarm CR property flags (transport, priority).
static constexpr std::size_t kSize
Size in bytes of this block.
static constexpr std::uint16_t DEFAULT_RTA_RETRIES
Default number of RTA retries.
std::uint16_t localAlarmReference
Local alarm reference chosen by the controller.
std::uint16_t alarmCrTagHeaderHigh
High word of the alarm VLAN tag header.
std::array< std::uint8_t, blockHeaderLength > blockHeader
Nested 6-byte block header.
std::uint16_t maxAlarmDataLength
Maximum alarm data length in bytes.
std::uint16_t alarmCrTagHeaderLow
Low word of the alarm VLAN tag header.
std::uint16_t rtaRetries
Number of RTA retransmission attempts.
std::uint16_t rtaTimeoutFactor
RTA (real-time acyclic) retransmission timeout factor.
static constexpr std::uint16_t DEFAULT_RTA_TIMEOUT_FACTOR
Default RTA timeout factor.
AlarmCRBlockRes: device's response confirming the alarm connection (part of the CONNECT response).
Bytes ToBytes() const
Serialize this block back to raw bytes.
std::uint16_t alarmCrType
Alarm CR type (always 1: Alarm).
std::array< std::uint8_t, blockHeaderLength > blockHeader
Nested 6-byte block header.
static constexpr std::uint16_t BLOCK_TYPE
Block type identifier for AlarmCRBlockRes.
std::uint16_t maxAlarmDataLength
Maximum alarm data length in bytes accepted by the device.
static constexpr std::size_t kSize
Size in bytes of this block.
std::uint16_t localAlarmReference
Local alarm reference assigned by the device.
static PNAlarmCRBlockRes Parse(const Bytes &data)
Parse an AlarmCRBlockRes from raw bytes.
AlarmNotification-PDU: carries a diagnosis/process/pull/plug/... alarm event.
std::uint16_t slotNumber
Slot number where the alarm originated.
std::uint32_t moduleIdentNumber
Module ident number of the affected module.
static constexpr std::uint16_t BLOCK_ALARM_HIGH
Block type: high-priority alarm notification.
std::array< std::uint8_t, blockHeaderLength > blockHeader
Nested 6-byte block header.
static constexpr std::size_t kFixedSize
Size in bytes of the fixed portion of this PDU.
static constexpr std::uint16_t BLOCK_ALARM_ACK_LOW
Block type: low-priority alarm acknowledgement.
static constexpr std::uint16_t BLOCK_ALARM_ACK_HIGH
Block type: high-priority alarm acknowledgement.
static PNAlarmNotificationPDU Parse(const Bytes &data)
Parse an AlarmNotification-PDU from raw bytes.
std::uint32_t api
API number.
std::uint32_t submoduleIdentNumber
Submodule ident number of the affected submodule.
std::uint16_t subslotNumber
Subslot number where the alarm originated.
std::uint16_t alarmSpecifier
Alarm specifier flags (sequence number, channel diagnosis presence, etc.).
static constexpr std::uint16_t BLOCK_ALARM_LOW
Block type: low-priority alarm notification.
Bytes payload
Alarm item data (USI-dispatched; see alarms.h).
std::uint16_t alarmType
Alarm type (Diagnosis/Process/Pull/Plug/...).
DCP request block: Option(1) + SubOption(1) + Length(2) + payload(Length).
std::uint16_t length
Length in bytes of Payload.
IPConfiguration ParseIp() const
Interpret this block's payload as an IP configuration triple.
std::uint8_t suboption
DCP suboption code.
Bytes payload
Block payload.
DcpOption option
DCP option code.
Bytes ToBytes() const
Serialize this block back to raw bytes.
static constexpr std::size_t kFixedSize
Size in bytes of the fixed portion of this block.
static PNDCPBlockRequest Parse(const Bytes &data)
Parse a DCP request block from raw bytes.
DCP response block: Option(1) + SubOption(1) + Length(2) + Status(2) + payload.
static constexpr std::pair< std::uint8_t, std::uint8_t > DEVICE_ROLE
Block option/suboption: device role bitmask.
std::uint16_t status
Per-block status/error code.
std::uint8_t suboption
DCP suboption code.
static constexpr std::pair< std::uint8_t, std::uint8_t > DEVICE_ID
Block option/suboption: vendor/device ID.
static constexpr std::pair< std::uint8_t, std::uint8_t > IP_ADDRESS
Block option/suboption: IP address/netmask/gateway.
static constexpr std::pair< std::uint8_t, std::uint8_t > NAME_OF_STATION
Block option/suboption: station name.
static PNDCPBlock Parse(const Bytes &data)
Parse a DCP response block from raw bytes.
static constexpr std::size_t kFixedSize
Size in bytes of the fixed portion of this block.
std::uint8_t option
DCP option code.
std::uint16_t length
Length in bytes of Status plus Payload (see class.
static constexpr std::pair< std::uint8_t, std::uint8_t > DEVICE_OEM_ID
Block option/suboption: OEM vendor/device ID.
IPConfiguration ParseIp() const
Interpret this block's payload as an IP configuration triple.
static constexpr std::pair< std::uint8_t, std::uint8_t > DEVICE_OPTIONS
Block option/suboption: supported option list.
static constexpr std::pair< std::uint8_t, std::uint8_t > IP_FULL_SUITE
Block option/suboption: full IP suite.
static constexpr std::pair< std::uint8_t, std::uint8_t > ALL
Block option/suboption wildcard: all blocks.
static constexpr std::pair< std::uint8_t, std::uint8_t > DEVICE_ALIAS
Block option/suboption: device alias name.
static constexpr std::pair< std::uint8_t, std::uint8_t > DEVICE_INSTANCE
Block option/suboption: device instance.
Bytes payload
Block payload (excludes Status).
Bytes ToBytes() const
Serialize this block back to raw bytes.
static constexpr std::pair< std::uint8_t, std::uint8_t > IP_MAC
Block option/suboption: IP/MAC address.
static constexpr std::pair< std::uint8_t, std::uint8_t > DEVICE_TYPE
Block option/suboption: device type string.
Describes one direction (input or output) of a submodule's cyclic data.
std::uint16_t dataDescription
Data direction: 1 = Input, 2 = Output.
Bytes ToBytes() const
Serialize this description back to raw bytes.
std::uint8_t lengthIops
Length in bytes of the IOPS (provider status) trailer.
std::uint16_t submoduleDataLength
Length in bytes of this direction's cyclic data.
static constexpr std::size_t kSize
Size in bytes of this description.
std::uint8_t lengthIocs
Length in bytes of the IOCS (consumer status) trailer.
IOCRBlockRes: device's response confirming an IOCR (part of the CONNECT response).
std::array< std::uint8_t, blockHeaderLength > blockHeader
Nested 6-byte block header.
static PNIOCRBlockRes Parse(const Bytes &data)
Parse an IOCRBlockRes from raw bytes.
std::uint16_t iocrReference
IOCR reference assigned by the controller.
static constexpr std::uint16_t BLOCK_TYPE
Block type identifier for IOCRBlockRes.
std::uint16_t frameId
Frame ID assigned by the device for this IOCR.
std::uint16_t iocrType
IOCR type (Input/Output/MulticastProvider/MulticastConsumer).
static constexpr std::size_t kSize
Size in bytes of this block.
Control block used for Release/PrmBegin/PrmEnd/ApplicationReady/RTClass3 requests.
std::array< std::uint8_t, uuidLenght > arUuid
AR UUID this control operation applies to.
std::uint16_t controlBlockProperties
Control block property flags.
static constexpr std::size_t kSize
Size in bytes of this block.
std::uint16_t padding1
Reserved/padding.
static PNIODReleaseBlock Parse(const Bytes &data)
Parse a control block from raw bytes.
std::uint16_t sessionKey
Session key matching the AR.
std::array< std::uint8_t, blockHeaderLength > blockHeader
Nested 6-byte block header.
ControlCommand controlCommand
Control command bitmask (PrmEnd/AppReady/Release/Done/...).
std::uint16_t padding2
Reserved/padding.
Bytes ToBytes() const
Serialize this block back to raw bytes.
IODWriteReqHeader: request header for writing a data record.
static constexpr std::uint16_t BLOCK_TYPE
Block type identifier for IODWriteReqHeader.
std::uint16_t seqNum
Sequence number for tracking retries.
std::uint16_t index
Record data index being written.
Bytes payload
Record data to write.
std::array< std::uint8_t, uuidLenght > arUuid
AR UUID this record belongs to.
std::array< std::uint8_t, 24 > rwPadding
Reserved/padding.
static constexpr std::size_t kFixedSize
Size in bytes of the fixed portion of this block.
std::uint32_t recordDataLength
Length in bytes of Payload.
std::uint16_t subslot
Subslot number.
std::uint16_t slot
Slot number.
std::array< std::uint8_t, blockHeaderLength > blockHeader
Nested 6-byte block header.
std::uint32_t api
API number.
Bytes ToBytes() const
Serialize this block back to raw bytes.
std::uint16_t padding
Reserved/padding.
IODWriteResHeader: response header confirming (or rejecting) a data record write.
std::array< std::uint8_t, blockHeaderLength > blockHeader
Nested 6-byte block header.
std::uint32_t recordDataLength
Length in bytes accepted by the device.
static constexpr std::uint16_t BLOCK_TYPE
Block type identifier for IODWriteResHeader.
std::uint16_t padding
Reserved/padding.
std::uint16_t slot
Slot number.
std::uint16_t seqNum
Sequence number echoed from the request.
std::uint16_t additionalValue1
Additional status value 1 (device-specific).
std::array< std::uint8_t, uuidLenght > arUuid
AR UUID this record belongs to.
std::uint16_t index
Record data index written.
static PNIODWriteRes Parse(const Bytes &data)
Parse an IODWriteResHeader from raw bytes.
std::uint32_t status
PNIO status code (0 = success).
std::uint16_t subslot
Subslot number.
static constexpr std::size_t kSize
Size in bytes of this block.
std::uint16_t additionalValue2
Additional status value 2 (device-specific).
std::array< std::uint8_t, 16 > rwPadding
Reserved/padding.
std::uint32_t api
API number.
I&M0: mandatory identification data (vendor, order ID, serial number, revisions).
std::uint16_t imProfileId
I&M profile ID.
std::uint16_t imHardwareRevision
Hardware revision number.
static constexpr std::size_t kSize
Size in bytes of this record.
std::uint16_t imProfileSpecificType
I&M profile-specific type.
std::string imSerialNumber
Device serial number (16 chars).
std::uint16_t imSupported
Bitmask of which I&M1-I&M15 records this device supports.
std::uint8_t imSwRevisionBugFix
Bug fix revision digit.
static PNInM0 Parse(const Bytes &data)
Parse an I&M0 record from raw bytes.
std::uint16_t imVersion
I&M data structure version.
std::uint8_t swRevisionPrefix
Software revision prefix character (e.g. 'V', 'R', 'P', 'U', 'T').
std::uint16_t imRevisionCounter
Monotonically increasing revision counter.
std::uint8_t imSwRevisionFunctionalEnhancement
Functional enhancement revision digit.
std::uint16_t VendorId() const
Combine VendorIdHigh/VendorIdLow into a 16-bit vendor ID.
std::uint8_t imSwRevisionInternalChange
Internal change revision digit.
std::uint16_t vendorId
The PROFINET vendor ID.
std::string orderId
Manufacturer-specific order/part number (20 chars).
static constexpr std::uint16_t IDX
Record data index for I&M0.
std::array< std::uint8_t, blockHeaderLength > blockHeader
Nested 6-byte block header.
bool operator==(const PNInM0 &) const =default
Compares two PNInM0 for equality.
I&M1: user-assigned tag function and location strings.
std::string imTagLocation
User-assigned installation location (22 chars).
static PNInM1 Parse(const Bytes &data)
Parse an I&M1 record from raw bytes.
std::array< std::uint8_t, blockHeaderLength > blockHeader
Nested 6-byte block header.
bool operator==(const PNInM1 &) const =default
Compares two PNInM1 for equality.
static constexpr std::uint16_t IDX
Record data index for I&M1.
std::string imTagFunction
User-assigned function description (32 chars).
static constexpr std::size_t kSize
Size in bytes of this record.
static PNInM2 Parse(const Bytes &data)
Parse an I&M2 record from raw bytes.
std::string imDate
Installation date, "YYYY-MM-DD HH:MM" (16 chars).
bool operator==(const PNInM2 &) const =default
Compares two PNInM2 for equality.
std::array< std::uint8_t, blockHeaderLength > blockHeader
Nested 6-byte block header.
static constexpr std::uint16_t IDX
Record data index for I&M2.
static constexpr std::size_t kSize
Size in bytes of this record.
I&M3: free-text descriptor.
static constexpr std::uint16_t IDX
Record data index for I&M3.
std::array< std::uint8_t, blockHeaderLength > blockHeader
Nested 6-byte block header.
std::string imDescriptor
Free-text descriptor (54 chars).
static PNInM3 Parse(const Bytes &data)
Parse an I&M3 record from raw bytes.
bool operator==(const PNInM3 &) const =default
Compares two PNInM3 for equality.
static constexpr std::size_t kSize
Size in bytes of this record.
I&M4: PROFIsafe signature (binary, not text).
bool operator==(const PNInM4 &) const =default
Compares two PNInM4 for equality.
std::array< std::uint8_t, 54 > imSignature
PROFIsafe signature bytes.
static PNInM4 Parse(const Bytes &data)
Parse an I&M4 record from raw bytes.
static constexpr std::uint16_t IDX
Record data index for I&M4.
static constexpr std::size_t kSize
Size in bytes of this record.
std::array< std::uint8_t, blockHeaderLength > blockHeader
Nested 6-byte block header.
I&M5: free-text annotation.
std::array< std::uint8_t, blockHeaderLength > blockHeader
Nested 6-byte block header.
static PNInM5 Parse(const Bytes &data)
Parse an I&M5 record from raw bytes.
static constexpr std::uint16_t IDX
Record data index for I&M5.
std::string imAnnotation
Free-text annotation (64 chars).
bool operator==(const PNInM5 &) const =default
Compares two PNInM5 for equality.
static constexpr std::size_t kSize
Size in bytes of this record.
I&M6-I&M15: reserved for future use per IEC 61158-6-10.
Bytes payload
Opaque remaining payload.
bool operator==(const PNInMReserved &) const =default
Compares two PNInMReserved for equality.
static constexpr std::uint16_t IDX
Record data index for this reserved I&M slot.
std::array< std::uint8_t, blockHeaderLength > blockHeader
Nested 6-byte block header.
static PNInMReserved Parse(const Bytes &data)
Parse a reserved I&M record from raw bytes.
NRD (Network Representation Data) wrapper carrying the actual IOD payload.
Bytes payload
The wrapped IOD data.
static PNNRDData Parse(const Bytes &data)
Parse an NRD wrapper and payload from raw bytes.
Bytes ToBytes() const
Serialize this wrapper and payload back to raw bytes.
std::uint32_t argsLength
Length in bytes of the arguments (usually equals ActualCount).
std::uint32_t offset
Byte offset into the logical result (0 unless fragmented).
std::uint32_t argsMaximumStatus
Maximum status/argument buffer size accepted by the caller.
static constexpr std::size_t kFixedSize
Size in bytes of the fixed portion of this wrapper.
std::uint32_t maximumCount
Maximum number of bytes the caller can accept.
std::uint32_t actualCount
Actual length in bytes of Payload.
Decoded PROFINET RTA ERR-PDU.
std::uint8_t errorCode1
PNIO ErrorCode1 byte.
static RtaErrorReason ClassifyRtaErrorReason(std::uint8_t errorCode2)
Return the decoded RTA reason.
static RtaErrorClass ClassifyRtaError(std::uint8_t errorCode2)
Return the decoded RTA reason.
bool IsUserAbort() const
Whether this is the user-specific RTA abort.
bool IsObsoleted() const
Whether this reason code is obsolete.
RtaErrorClass kind
Decoded RTA class.
RtaErrorClass ErrorClass() const
Classify the ErrorCode2 reason.
RtaErrorReason reason
Decoded RTA reason.
bool IsSequenceNumberError() const
Whether this is RTA sequence-number coordination failure.
bool IsRtaProtocolError() const
Whether the status belongs to the RTA protocol-error class.
static RtaErrorClass ClassifyRtaError(RtaErrorReason reason)
Return the decoded RTA reason.
PNRTAHeader header
Complete RTA header associated with this error.
std::string ReasonName() const
Return the decoded RTA reason name.
std::uint8_t errorCode2
PNIO ErrorCode2 byte.
bool IsAbort() const
Whether this reason is an RTA abort reason.
bool IsExtended() const
Whether the reason is one of the later extended RTA reasons.
std::uint8_t errorDecode
PNIO ErrorDecode byte.
std::uint32_t statusPnio
Raw four-byte PNIO status value.
std::uint8_t errorCode
PNIO ErrorCode byte.
Declares Linux Ethernet, addressing, timing, and utility helpers used by the PROFINET stack.
Generic helpers for reading and writing integer and byte data in big- and little-endian wire formats.