PROFINET IO Controller Stack 1.0.0
Modern C++ implementation of a PROFINET IO Controller stack
Loading...
Searching...
No Matches
rt.h File Reference

Declares PROFINET RT_CLASS_1 cyclic frame and IOCR data structures. More...

#include <cstdint>
#include <mutex>
#include <optional>
#include <string>
#include <vector>
#include "profinet/protocol.h"
#include "profinet/util.h"
+ Include dependency graph for rt.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  profinet::rt::IODataObject
 Single IO data object within the C_SDU: one piece of process data mapped to a slot/subslot, with its IOPS (and optional IOCS) offset. More...
 
struct  profinet::rt::IOCRConfig
 IOCR configuration derived from AR setup: timing parameters and IO object mappings needed for cyclic data exchange. More...
 
struct  profinet::rt::RTFrame
 A single PROFINET Real-Time cyclic frame: Frame ID + C_SDU payload + cycle counter/status trailer. More...
 
class  profinet::rt::CyclicDataBuilder
 Builds C_SDU payload from IO data objects with double-buffering. More...
 

Namespaces

namespace  profinet
 
namespace  profinet::rt
 

Functions

template<typename SlotT >
std::pair< IOCRConfig, IOCRConfigprofinet::rt::BuildIocrConfigs (const std::vector< SlotT > &slots, std::uint16_t inputFrameId, std::uint16_t outputFrameId, std::uint16_t sendClockFactor=32, std::uint16_t reductionRatio=32, int watchdogFactor=3, std::uint16_t cSduLength=43)
 
Bytes profinet::rt::BuildEthernetFrame (const MacAddress &dstMac, const MacAddress &srcMac, const RTFrame &rtFrame)
 Build a complete Ethernet frame carrying an RT frame.
 
std::optional< RTFrameprofinet::rt::ParseEthernetFrame (const Bytes &data)
 Parse a complete Ethernet frame and extract its RT frame.
 

Variables

constexpr std::uint16_t profinet::rt::ETHERTYPE_PROFINET = 0x8892
 EtherType used by PROFINET RT frames (0x8892).
 
constexpr std::uint16_t profinet::rt::FRAME_ID_RT_CLASS_1_MIN = 0xC000
 Minimum frame ID in the RT_CLASS_1 range.
 
constexpr std::uint16_t profinet::rt::FRAME_ID_RT_CLASS_1_MAX = 0xF7FF
 Maximum frame ID in the RT_CLASS_1 range.
 
constexpr std::uint16_t profinet::rt::VLAN_TAG_RT = 0x8100C000
 802.1Q priority tag for cyclic RT frames per IEC 61158-6-10: TPID 0x8100, PCP 6, VID 0 (TCI 0xC000, matching the negotiated IOCRTagHeader). Devices validate the negotiated priority, and managed switches may drop untagged sub-64-byte RT frames as runts, so TX frames must carry the tag.
 
constexpr std::uint16_t profinet::rt::FRAME_ID_ALARM_HIGH = 0xFC01
 Frame ID used for high-priority alarms.
 
constexpr std::uint16_t profinet::rt::FRAME_ID_ALARM_LOW = 0xFE01
 Frame ID used for low-priority alarms.
 
constexpr std::uint16_t profinet::rt::IOCR_TYPE_INPUT = 1
 IOCR direction: Device -> Controller.
 
constexpr std::uint16_t profinet::rt::IOCR_TYPE_OUTPUT = 2
 IOCR direction: Controller -> Device.
 
constexpr std::uint8_t profinet::rt::RT_CLASS_1 = 0x01
 Real-time class: software scheduled (250us-512ms).
 
constexpr std::uint8_t profinet::rt::RT_CLASS_2 = 0x02
 Real-time class: hardware scheduled (reserved).
 
constexpr std::uint8_t profinet::rt::RT_CLASS_3 = 0x03
 Real-time class: isochronous (IRT, hardware only).
 
constexpr std::uint8_t profinet::rt::DATA_STATUS_STATE = 0x01
 DataStatus bit: provider state, 0=Backup, 1=Primary.
 
constexpr std::uint8_t profinet::rt::DATA_STATUS_REDUNDANCY = 0x02
 DataStatus bit: redundancy state.
 
constexpr std::uint8_t profinet::rt::DATA_STATUS_VALID = 0x04
 DataStatus bit: data validity, 0=Invalid, 1=Valid.
 
constexpr std::uint8_t profinet::rt::DATA_STATUS_RESERVED = 0x08
 DataStatus bit: reserved.
 
constexpr std::uint8_t profinet::rt::DATA_STATUS_PROVIDER_RUN = 0x10
 DataStatus bit: provider run state, 0=Stop, 1=Run.
 
constexpr std::uint8_t profinet::rt::DATA_STATUS_STATION_OK = 0x20
 DataStatus bit: station health, 0=Problem, 1=OK.
 
constexpr std::uint8_t profinet::rt::DATA_STATUS_IGNORE = 0x80
 DataStatus bit: 1=Ignore this frame.
 
constexpr std::uint8_t profinet::rt::IOXS_GOOD = 0x80
 IOxS value: good, subslot level.
 
constexpr std::uint8_t profinet::rt::IOXS_DATA_STATE_GOOD = 0x80
 IOxS value: DataState is bit 7 of an IOxS byte; the lower bits carry Instance and Extension, so a received IOxS must be masked rather than compared to IOXS_GOOD.
 
constexpr std::uint8_t profinet::rt::IOXS_BAD = 0x00
 IOxS value: bad.
 
constexpr std::uint8_t profinet::rt::IOXS_EXTENSION = 0x01
 IOxS value: extension bit set (another IOxS byte follows).
 

Detailed Description

Declares PROFINET RT_CLASS_1 cyclic frame and IOCR data structures.

Defines cyclic RT frame serialization and parsing, IOCR configuration, individual IO data objects, IO status locations, and cyclic process-data buffer construction.

Data structures for RT_CLASS_1 cyclic data exchange:

  • RTFrame: cyclic frame serialization/deserialization
  • IOCRConfig: IOCR configuration derived from AR setup
  • IODataObject: individual IO data object within the C_SDU
  • CyclicDataBuilder: double-buffered C_SDU payload builder

Per IEC 61158-6-10: RT frames use EtherType 0x8892; frame IDs 0x8000-0xFBFF for RT_CLASS_1; the C_SDU carries process data + IOxS.

Definition in file rt.h.