|
PROFINET IO Controller Stack 1.0.0
Modern C++ implementation of a PROFINET IO Controller stack
|
Classes | |
| class | CyclicDataBuilder |
| Builds C_SDU payload from IO data objects with double-buffering. More... | |
| struct | IOCRConfig |
| IOCR configuration derived from AR setup: timing parameters and IO object mappings needed for cyclic data exchange. More... | |
| struct | 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 | RTFrame |
| A single PROFINET Real-Time cyclic frame: Frame ID + C_SDU payload + cycle counter/status trailer. More... | |
Functions | |
| template<typename SlotT > | |
| std::pair< IOCRConfig, IOCRConfig > | 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 | BuildEthernetFrame (const MacAddress &dstMac, const MacAddress &srcMac, const RTFrame &rtFrame) |
| Build a complete Ethernet frame carrying an RT frame. | |
| std::optional< RTFrame > | ParseEthernetFrame (const Bytes &data) |
| Parse a complete Ethernet frame and extract its RT frame. | |
Variables | |
| constexpr std::uint16_t | ETHERTYPE_PROFINET = 0x8892 |
| EtherType used by PROFINET RT frames (0x8892). | |
| constexpr std::uint16_t | FRAME_ID_RT_CLASS_1_MIN = 0xC000 |
| Minimum frame ID in the RT_CLASS_1 range. | |
| constexpr std::uint16_t | FRAME_ID_RT_CLASS_1_MAX = 0xF7FF |
| Maximum frame ID in the RT_CLASS_1 range. | |
| constexpr std::uint16_t | 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 | FRAME_ID_ALARM_HIGH = 0xFC01 |
| Frame ID used for high-priority alarms. | |
| constexpr std::uint16_t | FRAME_ID_ALARM_LOW = 0xFE01 |
| Frame ID used for low-priority alarms. | |
| constexpr std::uint16_t | IOCR_TYPE_INPUT = 1 |
| IOCR direction: Device -> Controller. | |
| constexpr std::uint16_t | IOCR_TYPE_OUTPUT = 2 |
| IOCR direction: Controller -> Device. | |
| constexpr std::uint8_t | RT_CLASS_1 = 0x01 |
| Real-time class: software scheduled (250us-512ms). | |
| constexpr std::uint8_t | RT_CLASS_2 = 0x02 |
| Real-time class: hardware scheduled (reserved). | |
| constexpr std::uint8_t | RT_CLASS_3 = 0x03 |
| Real-time class: isochronous (IRT, hardware only). | |
| constexpr std::uint8_t | DATA_STATUS_STATE = 0x01 |
| DataStatus bit: provider state, 0=Backup, 1=Primary. | |
| constexpr std::uint8_t | DATA_STATUS_REDUNDANCY = 0x02 |
| DataStatus bit: redundancy state. | |
| constexpr std::uint8_t | DATA_STATUS_VALID = 0x04 |
| DataStatus bit: data validity, 0=Invalid, 1=Valid. | |
| constexpr std::uint8_t | DATA_STATUS_RESERVED = 0x08 |
| DataStatus bit: reserved. | |
| constexpr std::uint8_t | DATA_STATUS_PROVIDER_RUN = 0x10 |
| DataStatus bit: provider run state, 0=Stop, 1=Run. | |
| constexpr std::uint8_t | DATA_STATUS_STATION_OK = 0x20 |
| DataStatus bit: station health, 0=Problem, 1=OK. | |
| constexpr std::uint8_t | DATA_STATUS_IGNORE = 0x80 |
| DataStatus bit: 1=Ignore this frame. | |
| constexpr std::uint8_t | IOXS_GOOD = 0x80 |
| IOxS value: good, subslot level. | |
| constexpr std::uint8_t | 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 | IOXS_BAD = 0x00 |
| IOxS value: bad. | |
| constexpr std::uint8_t | IOXS_EXTENSION = 0x01 |
| IOxS value: extension bit set (another IOxS byte follows). | |
| Bytes profinet::rt::BuildEthernetFrame | ( | const MacAddress & | dstMac, |
| const MacAddress & | srcMac, | ||
| const RTFrame & | rtFrame | ||
| ) |
Build a complete Ethernet frame carrying an RT frame.
| dstMac | Destination MAC address. |
| srcMac | Source MAC address. |
| rtFrame | RT frame to embed. |
Definition at line 212 of file rt.cpp.
References ETHERTYPE_PROFINET, profinet::LowByteMask, profinet::OneOctetShift, and profinet::rt::RTFrame::ToBytes().
Referenced by profinet::cyclic::CyclicController::SendOutputFrame().
Here is the call graph for this function:
Here is the caller graph for this function:| std::pair< IOCRConfig, IOCRConfig > profinet::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 |
||
| ) |
Definition at line 444 of file rt.h.
References profinet::rt::IOCRConfig::dataLength, profinet::rt::IOCRConfig::frameId, IOCR_TYPE_INPUT, IOCR_TYPE_OUTPUT, profinet::rt::IOCRConfig::objects, profinet::rt::IOCRConfig::phase, profinet::rt::IOCRConfig::reductionRatio, profinet::rt::IOCRConfig::referenceIOCR, profinet::rt::IOCRConfig::sendClockFactor, profinet::rt::IOCRConfig::typeIOCR, and profinet::rt::IOCRConfig::watchdogFactor.
Referenced by profinet::device::ProfinetDevice::StartCyclic().
Here is the caller graph for this function:Parse a complete Ethernet frame and extract its RT frame.
| data | Complete frame bytes, starting at the destination MAC. |
Definition at line 229 of file rt.cpp.
References ETHERTYPE_PROFINET, profinet::rt::RTFrame::FromBytes(), and profinet::OneOctetShift.
Here is the call graph for this function:
|
inlineconstexpr |
|
inlineconstexpr |
DataStatus bit: provider run state, 0=Stop, 1=Run.
Definition at line 81 of file rt.h.
Referenced by profinet::rt::RTFrame::IsRunning(), and profinet::cyclic::CyclicController::SendOutputFrame().
|
inlineconstexpr |
|
inlineconstexpr |
|
inlineconstexpr |
DataStatus bit: provider state, 0=Backup, 1=Primary.
Definition at line 73 of file rt.h.
Referenced by profinet::rt::RTFrame::IsPrimary(), profinet::cyclic::CyclicController::SendOutputFrame(), and profinet::cyclic::CyclicController::SendStopFrames().
|
inlineconstexpr |
DataStatus bit: station health, 0=Problem, 1=OK.
Definition at line 83 of file rt.h.
Referenced by profinet::rt::RTFrame::IsOk(), profinet::cyclic::CyclicController::SendOutputFrame(), and profinet::cyclic::CyclicController::SendStopFrames().
|
inlineconstexpr |
DataStatus bit: data validity, 0=Invalid, 1=Valid.
Definition at line 77 of file rt.h.
Referenced by profinet::rt::RTFrame::IsValid(), profinet::cyclic::CyclicController::SendOutputFrame(), and profinet::cyclic::CyclicController::SendStopFrames().
|
inlineconstexpr |
EtherType used by PROFINET RT frames (0x8892).
Definition at line 34 of file rt.h.
Referenced by BuildEthernetFrame(), ParseEthernetFrame(), and profinet::cyclic::CyclicController::ProcessInputFrame().
|
inlineconstexpr |
|
inlineconstexpr |
|
inlineconstexpr |
|
inlineconstexpr |
|
inlineconstexpr |
IOCR direction: Device -> Controller.
Definition at line 60 of file rt.h.
Referenced by BuildIocrConfigs(), and profinet::rt::IOCRConfig::IsInput().
|
inlineconstexpr |
IOCR direction: Controller -> Device.
Definition at line 62 of file rt.h.
Referenced by BuildIocrConfigs(), and profinet::rt::IOCRConfig::IsOutput().
|
inlineconstexpr |
IOxS value: bad.
Definition at line 95 of file rt.h.
Referenced by profinet::cyclic::CyclicController::HandleWatchdogTimeout().
|
inlineconstexpr |
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.
Definition at line 93 of file rt.h.
Referenced by profinet::cyclic::CyclicController::LocalIsInputGood(), and profinet::cyclic::CyclicController::ProcessInputFrame().
|
inlineconstexpr |
|
inlineconstexpr |
IOxS value: good, subslot level.
Definition at line 89 of file rt.h.
Referenced by profinet::cyclic::CyclicController::CyclicController(), profinet::cyclic::CyclicController::ProcessInputFrame(), and profinet::cyclic::CyclicController::SetOutputData().
|
inlineconstexpr |
|
inlineconstexpr |
|
inlineconstexpr |
|
inlineconstexpr |
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.