PROFINET IO Controller Stack 1.0.0
Modern C++ implementation of a PROFINET IO Controller stack
Loading...
Searching...
No Matches
profinet::rpc::RPCCon Class Reference

Connection to a PROFINET IO-Device: establishes an AR (Application Relationship) and performs acyclic read/write and CONTROL operations. More...

#include <rpc.h>

+ Inheritance diagram for profinet::rpc::RPCCon:
+ Collaboration diagram for profinet::rpc::RPCCon:

Public Member Functions

 RPCCon (RPCCon &&)=delete
 Deleted move constructor to prevent moving instances of this class.
 
RPCConoperator= (RPCCon &&)=delete
 Deleted move assignment operator to prevent moving instances of this class.
 
 RPCCon (const dcp::DCPDeviceDescription &info, RPCConOptions options={})
 Prepare a PROFINET DCE/RPC connection object for an IO-device (does not connect yet).
 
 ~RPCCon ()
 Disconnect (best-effort) and close the underlying sockets.
 
 RPCCon (const RPCCon &)=delete
 Not copyable because the connection owns non-copyable Asio sockets.
 
RPCConoperator= (const RPCCon &)=delete
 Not copyable because the connection owns non-copyable Asio sockets.
 
std::optional< ConnectResultConnect (std::optional< MacAddress > srcMac=std::nullopt, bool withAlarmCr=false, std::optional< IOCRSetup > iocrSetup=std::nullopt) override
 Establish (or re-establish) the AR with the device.
 
PNIODHeader Read (std::uint32_t api, std::uint16_t slot, std::uint16_t subslot, std::uint16_t idx) override
 Read a data record via slot/subslot/index (AR must be connected).
 
PNIODHeader ReadImplicit (std::uint32_t api, std::uint16_t slot, std::uint16_t subslot, std::uint16_t idx) override
 Read a data record without an established AR.
 
void Write (std::uint32_t api, std::uint16_t slot, std::uint16_t subslot, std::uint16_t idx, const Bytes &data) override
 Write a data record via slot/subslot/index (AR must be connected).
 
std::vector< blocks::WriteMultipleResultWriteMultiple (const std::vector< WriteItem > &writes) override
 Write multiple records atomically via IODWriteMultipleReq (0xE040).
 
Bytes ReadRaw (std::uint16_t idx, std::uint16_t slot=0, std::uint16_t subslot=1)
 Read a raw record payload by index (convenience wrapper over Read()).
 
PNInM0 ReadIm0 (std::uint16_t slot=0, std::uint16_t subslot=1) override
 Read I&M0 (mandatory identification data).
 
PNInM1 ReadIm1 (std::uint16_t slot=0, std::uint16_t subslot=1) override
 Read I&M1 (tag function/location).
 
PNInM2 ReadIm2 (std::uint16_t slot=0, std::uint16_t subslot=1) override
 Read I&M2 (installation date).
 
PNInM3 ReadIm3 (std::uint16_t slot=0, std::uint16_t subslot=1) override
 Read I&M3 (free-text descriptor).
 
PNInM4 ReadIm4 (std::uint16_t slot=0, std::uint16_t subslot=1) override
 Read I&M4 (PROFIsafe signature).
 
PNInM5 ReadIm5 (std::uint16_t slot=0, std::uint16_t subslot=1) override
 Read I&M5 (free-text annotation).
 
PNInM6 ReadIm6 (std::uint16_t slot=0, std::uint16_t subslot=1) override
 Read I&M6 (reserved).
 
PNInM7 ReadIm7 (std::uint16_t slot=0, std::uint16_t subslot=1) override
 Read I&M7 (reserved).
 
PNInM8 ReadIm8 (std::uint16_t slot=0, std::uint16_t subslot=1) override
 Read I&M8 (reserved).
 
PNInM9 ReadIm9 (std::uint16_t slot=0, std::uint16_t subslot=1) override
 Read I&M9 (reserved).
 
PNInM10 ReadIm10 (std::uint16_t slot=0, std::uint16_t subslot=1) override
 Read I&M10 (reserved).
 
PNInM11 ReadIm11 (std::uint16_t slot=0, std::uint16_t subslot=1) override
 Read I&M11 (reserved).
 
PNInM12 ReadIm12 (std::uint16_t slot=0, std::uint16_t subslot=1) override
 Read I&M12 (reserved).
 
PNInM13 ReadIm13 (std::uint16_t slot=0, std::uint16_t subslot=1) override
 Read I&M13 (reserved).
 
PNInM14 ReadIm14 (std::uint16_t slot=0, std::uint16_t subslot=1) override
 Read I&M14 (reserved).
 
PNInM15 ReadIm15 (std::uint16_t slot=0, std::uint16_t subslot=1) override
 Read I&M15 (reserved).
 
AllIM ReadAllIm (std::uint16_t slot=0, std::uint16_t subslot=1) override
 Read all I&M records a device supports.
 
blocks::ModuleDiffBlock ReadModuleDiff () override
 Read and parse the device's ModuleDiffBlock.
 
diagnosis::DiagnosisData ReadDiagnosis (std::uint16_t slot=0, std::uint16_t subslot=0, std::uint16_t index=0xF000) override
 Read and parse diagnosis data at the given location/index.
 
std::map< std::uint16_t, diagnosis::DiagnosisDataReadAllDiagnosis () override
 Read diagnosis from all standard diagnosis indices.
 
blocks::PDRealData ReadPdRealData () override
 Read and parse the device's PDRealData (physical topology).
 
blocks::RealIdentificationData ReadRealIdentificationData () override
 Read and parse the device's RealIdentificationData (logical structure).
 
std::vector< blocks::SlotInfoDiscoverSlots () override
 Convenience accessor for ReadRealIdentificationData().Slots.
 
std::pair< blocks::PDRealData, blocks::RealIdentificationDataDiscoverTopology () override
 Read both PDRealData and RealIdentificationData in one call.
 
std::map< std::uint16_t, IndexProbeResultEnumerateIndices (std::uint16_t slot=0, std::uint16_t subslot=1, std::optional< std::vector< std::uint16_t > > customIndices=std::nullopt) override
 Probe a set of indices and report which are readable/empty/erroring.
 
Bytes PrmBegin () override
 Send PrmBegin (start of the parameterization phase).
 
Bytes PrmEnd () override
 Send PrmEnd (end of the parameterization phase).
 
Bytes ReadyForRtClass3 () override
 Send ReadyForRTClass3 (isochronous real-time readiness).
 
Bytes ApplicationReady (double timeoutSec=30.0) override
 Wait for the device's CControl/ApplicationReady request and confirm it.
 
void Disconnect () override
 Send Release to terminate the AR.
 
void Close () noexcept override
 Disconnect() and close the underlying sockets.
 
bool IsConnected () const override
 Whether the AR is currently established.
 
const dcp::DCPDeviceDescriptionInfo () const override
 The device this connection targets.
 
const std::array< std::uint8_t, uuidLenght > & ArUuid () const
 The AR UUID for this connection.
 
std::uint16_t SessionKey () const
 The session key for this connection.
 
std::uint16_t LocalAlarmRef () const override
 Controller's own local alarm reference.
 
int DeviceAlarmRef () const override
 Device's local alarm reference, from AlarmCRBlockRes.
 
bool HasAlarmCr () const override
 Whether an AlarmCR was successfully established.
 
asio::io_context & IoContext () override
 Returns the underlying Asio I/O context.
 
- Public Member Functions inherited from profinet::rpc::IRPCCon
virtual ~IRPCCon ()=default
 Virtual destructor.
 

Private Member Functions

PNRPCHeader CreateRpc (std::uint16_t operation, const Bytes &nrd)
 Build an RPC header for the given operation and NRD body.
 
Bytes BuildAlarmCrBlock (int transport=0, int priority=0) const
 Build an AlarmCRBlockReq for inclusion in the CONNECT request.
 
PNRPCHeader SendReceive (const PNRPCHeader &request)
 Send an RPC request and synchronously wait for its response.
 
void CloseSockets () noexcept
 Close the RPC and CControl UDP sockets.
 
void CheckTimeout ()
 Reconnect if the AR has been idle longer than CONNECTION_TIMEOUT.
 
Bytes SendControl (BlockType blockType, ControlCommand controlCommand, bool waitResponse=true, const Bytes &subBlocks={})
 Send a CONTROL operation and optionally wait for its response.
 

Static Private Member Functions

static PNNRDData CreateNrd (const Bytes &payload)
 Wrap a payload in an NRD (Network Representation Data) header.
 
static int ParseAlarmCrResponse (const Bytes &responseData)
 Parse the AlarmCRBlockRes from a CONNECT response.
 
static Bytes BuildIocrBlock (int iocrType, int iocrReference, const IOCRSetup &setup)
 Build an IOCRBlockReq (header + API object list) for the CONNECT request.
 
static Bytes BuildExpectedSubmoduleBlock (const IOCRSetup &setup)
 Build an ExpectedSubmoduleBlockReq for the CONNECT request.
 
static Bytes BuildUnifiedExpectedSubmoduleBlock (const IOCRSetup &setup)
 
static std::uint16_t ParseIocrResponse (const Bytes &responseData, int iocrType)
 Parse an IOCRBlockRes from a CONNECT response.
 

Private Attributes

dcp::DCPDeviceDescription info
 DCP-discovered description of the target device.
 
double timeout
 Default RPC response timeout in seconds.
 
std::array< std::uint8_t, uuidLenghtarUuid {}
 AR UUID for this connection.
 
std::array< std::uint8_t, uuidLenghtactivityUuid {}
 Activity UUID for the current RPC exchange.
 
std::array< std::uint8_t, uuidLenghtlocalObjectUuid {}
 This controller's own object UUID.
 
std::array< std::uint8_t, uuidLenghtremoteObjectUuid {}
 The target device's object UUID.
 
bool live = false
 Whether the AR is currently established.
 
std::chrono::steady_clock::time_point liveMonotonic {}
 Timestamp of the last successful RPC exchange, for CONNECTION_TIMEOUT tracking.
 
std::optional< MacAddresssrcMac
 Source MAC address used to establish the AR.
 
std::uint16_t sessionKey = 0
 Session key for this connection.
 
std::uint16_t alarmRef = 0x8001
 Controller's own local alarm reference.
 
int deviceAlarmRef = 0
 Device's local alarm reference, if an AlarmCR was established.
 
bool alarmCrEnabled = false
 Whether an AlarmCR was successfully established.
 
std::uint32_t sequenceNumber = 0
 Monotonically increasing RPC sequence number.
 
int iocrRefCounter = 1
 Counter used to allocate unique IOCR references.
 
int inputIocrRef = 0
 IOCR reference for the input (device -> controller) IOCR.
 
int outputIocrRef = 0
 IOCR reference for the output (controller -> device) IOCR.
 
std::uint16_t inputFrameId = 0
 Frame ID assigned to the input IOCR.
 
std::uint16_t outputFrameId = 0
 Frame ID assigned to the output IOCR.
 
std::optional< IOCRSetupiocrSetup
 Cyclic IO configuration used for the current AR, if any.
 
asio::io_context ioContext {}
 Asio execution context used by the RPC transport.
 
std::unique_ptr< RpcTransportrpcTransport
 
std::unique_ptr< RpcTransportccontrolTransport
 

Friends

class RpcTest
 FRIEND_CLASS declaration granting access to the specific test case for validating CreateRpc.
 

Detailed Description

Connection to a PROFINET IO-Device: establishes an AR (Application Relationship) and performs acyclic read/write and CONTROL operations.

Example:

auto info = rpc::GetStationInfo(sock, my_mac, "device-name");
conn.Connect(my_mac);
auto iod = conn.Read(/*api=*/0, /*slot=*/0, /*subslot=*/1, /*idx=*/0xAFF0);
Abstract interface for a PROFINET RPC connection.
Definition IRPCCon.h:50
dcp::DCPDeviceDescription info
DCP-discovered description of the target device.
Definition rpc.h:539
dcp::DCPDeviceDescription GetStationInfo(const EthernetSocket &sock, const MacAddress &src, const std::string &name, int timeoutSec=static_cast< int >(DEFAULT_TIMEOUT *2))
Resolve a device by PROFINET station name via DCP.
Definition rpc.cpp:588

Definition at line 149 of file rpc.h.

Constructor & Destructor Documentation

◆ RPCCon() [1/3]

profinet::rpc::RPCCon::RPCCon ( RPCCon &&  )
delete

Deleted move constructor to prevent moving instances of this class.

◆ RPCCon() [2/3]

profinet::rpc::RPCCon::RPCCon ( const dcp::DCPDeviceDescription info,
RPCConOptions  options = {} 
)
explicit

Prepare a PROFINET DCE/RPC connection object for an IO-device (does not connect yet).

The constructor initializes the Asio UDP transports but does not establish a PROFINET Application Relationship. The AR is established by Connect().

Parameters
infoDCP-discovered description of the target device.
optionsA configured RPCConOption in which you can set timeoutSec, Default RPC response timeout.

Definition at line 652 of file rpc.cpp.

References activityUuid, arUuid, ccontrolTransport, profinet::dcp::DCPDeviceDescription::deviceHigh, profinet::dcp::DCPDeviceDescription::deviceLow, info, profinet::dcp::DCPDeviceDescription::ip, localObjectUuid, remoteObjectUuid, profinet::rpc::RPCConOptions::rpcPort, rpcTransport, profinet::dcp::DCPDeviceDescription::vendorHigh, and profinet::dcp::DCPDeviceDescription::vendorLow.

◆ ~RPCCon()

profinet::rpc::RPCCon::~RPCCon ( )

Disconnect (best-effort) and close the underlying sockets.

Definition at line 671 of file rpc.cpp.

References Close().

+ Here is the call graph for this function:

◆ RPCCon() [3/3]

profinet::rpc::RPCCon::RPCCon ( const RPCCon )
delete

Not copyable because the connection owns non-copyable Asio sockets.

Member Function Documentation

◆ ApplicationReady()

Bytes profinet::rpc::RPCCon::ApplicationReady ( double  timeoutSec = 30.0)
overridevirtual

◆ ArUuid()

const std::array< std::uint8_t, uuidLenght > & profinet::rpc::RPCCon::ArUuid ( ) const
inline

The AR UUID for this connection.

Returns
The 16-byte AR UUID.

Definition at line 430 of file rpc.h.

References arUuid.

◆ BuildAlarmCrBlock()

Bytes profinet::rpc::RPCCon::BuildAlarmCrBlock ( int  transport = 0,
int  priority = 0 
) const
private

Build an AlarmCRBlockReq for inclusion in the CONNECT request.

Parameters
transportTransport type (0 = RTA over Ethernet).
priorityAlarm priority.
Returns
The serialized block.

Definition at line 714 of file rpc.cpp.

References profinet::PNAlarmCRBlockReq::alarmCrProperties, profinet::PNAlarmCRBlockReq::alarmCrTagHeaderHigh, profinet::PNAlarmCRBlockReq::alarmCrTagHeaderLow, profinet::PNAlarmCRBlockReq::alarmCrType, alarmRef, profinet::PNAlarmCRBlockReq::BLOCK_TYPE, profinet::PNAlarmCRBlockReq::blockHeader, profinet::blockHeaderLenght, profinet::PNBlockHeader::blockLength, profinet::PNBlockHeader::blockType, profinet::PNBlockHeader::blockVersionHigh, profinet::PNBlockHeader::blockVersionLow, profinet::PNAlarmCRBlockReq::DEFAULT_MAX_ALARM_DATA_LENGTH, profinet::PNAlarmCRBlockReq::DEFAULT_RTA_RETRIES, profinet::PNAlarmCRBlockReq::DEFAULT_RTA_TIMEOUT_FACTOR, profinet::PNAlarmCRBlockReq::DEFAULT_TAG_HEADER_HIGH, profinet::PNAlarmCRBlockReq::DEFAULT_TAG_HEADER_LOW, profinet::PNAlarmCRBlockReq::etherTypeLT, profinet::IP_ETHERTYPE, profinet::PNAlarmCRBlockReq::kSize, profinet::PNAlarmCRBlockReq::localAlarmReference, profinet::PNAlarmCRBlockReq::maxAlarmDataLength, profinet::PROFINET_ETHERTYPE, profinet::PNAlarmCRBlockReq::rtaRetries, profinet::PNAlarmCRBlockReq::rtaTimeoutFactor, profinet::PNBlockHeader::ToBytes(), profinet::PNAlarmCRBlockReq::ToBytes(), profinet::rpc::VERSION_HIGH, and profinet::rpc::VERSION_LOW.

Referenced by Connect().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ BuildExpectedSubmoduleBlock()

Bytes profinet::rpc::RPCCon::BuildExpectedSubmoduleBlock ( const IOCRSetup setup)
staticprivate

Build an ExpectedSubmoduleBlockReq for the CONNECT request.

Parameters
setupCyclic IO configuration describing the expected slots.
Returns
The serialized block.

Definition at line 2439 of file rpc.cpp.

References profinet::blocks::ExpectedSubmoduleBlockReq::AddSubmodule(), profinet::blocks::InputAndOutput, profinet::blocks::InputOnly, profinet::blocks::None, profinet::blocks::OutputOnly, profinet::rpc::IOCRSetup::slots, and profinet::blocks::ExpectedSubmoduleBlockReq::ToBytes().

Referenced by Connect().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ BuildIocrBlock()

Bytes profinet::rpc::RPCCon::BuildIocrBlock ( int  iocrType,
int  iocrReference,
const IOCRSetup setup 
)
staticprivate

Build an IOCRBlockReq (header + API object list) for the CONNECT request.

Parameters
iocrTypeIOCR type (Input/Output).
iocrReferenceIOCR reference chosen by the controller.
setupCyclic IO configuration.
Returns
The serialized block.

Definition at line 1690 of file rpc.cpp.

References profinet::PNIOCRBlockReqHeader::BLOCK_TYPE, profinet::PNIOCRBlockReqHeader::blockHeader, profinet::PNBlockHeader::blockLength, profinet::PNBlockHeader::blockType, profinet::PNBlockHeader::blockVersionHigh, profinet::PNBlockHeader::blockVersionLow, profinet::PNIOCRBlockReqHeader::dataHoldFactor, profinet::rpc::IOCRSetup::dataHoldFactor, profinet::PNIOCRBlockReqHeader::dataLength, profinet::rpc::IOCRSetup::dataLength, profinet::PNIOCRBlockReqHeader::etherTypeLT, profinet::PNIOCRBlockReqHeader::frameId, profinet::PNIOCRBlockReqHeader::frameSendOffset, profinet::rpc::IOSlot::inputLength, profinet::PNIOCRBlockReqHeader::iocrMulticastMac, profinet::PNIOCRBlockReqHeader::iocrProperties, profinet::PNIOCRBlockReqHeader::iocrReference, profinet::PNIOCRBlockReqHeader::iocrTagHeader, profinet::PNIOCRBlockReqHeader::iocrType, profinet::PNIOCRBlockReqHeader::kSize, profinet::PNIOCRBlockReqHeader::numberOfApis, profinet::rpc::IOSlot::outputLength, profinet::PNIOCRBlockReqHeader::phase, profinet::PROFINET_ETHERTYPE, profinet::wire::PutU16(), profinet::wire::PutU32(), profinet::PNIOCRBlockReqHeader::reductionRatio, profinet::rpc::IOCRSetup::reductionRatio, profinet::PNIOCRBlockReqHeader::sendClockFactor, profinet::rpc::IOCRSetup::sendClockFactor, profinet::PNIOCRBlockReqHeader::sequence, profinet::rpc::IOSlot::slot, profinet::rpc::IOCRSetup::slots, profinet::rpc::IOSlot::subslot, profinet::PNBlockHeader::ToBytes(), profinet::PNIOCRBlockReqHeader::ToBytes(), profinet::rpc::VERSION_HIGH, profinet::rpc::VERSION_LOW, profinet::PNIOCRBlockReqHeader::watchdogFactor, and profinet::rpc::IOCRSetup::watchdogFactor.

Referenced by Connect().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ BuildUnifiedExpectedSubmoduleBlock()

Bytes profinet::rpc::RPCCon::BuildUnifiedExpectedSubmoduleBlock ( const IOCRSetup setup)
staticprivate

Definition at line 2482 of file rpc.cpp.

References profinet::blocks::ExpectedSubmoduleBlockReq::AddSubmodule(), profinet::rpc::IOCRSetup::slots, and profinet::blocks::ExpectedSubmoduleBlockReq::ToBytes().

+ Here is the call graph for this function:

◆ CheckTimeout()

void profinet::rpc::RPCCon::CheckTimeout ( )
private

Reconnect if the AR has been idle longer than CONNECTION_TIMEOUT.

Definition at line 2600 of file rpc.cpp.

References Connect(), profinet::rpc::CONNECTION_TIMEOUT, live, and liveMonotonic.

Referenced by Read(), Write(), and WriteMultiple().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ Close()

void profinet::rpc::RPCCon::Close ( )
overridevirtualnoexcept

Disconnect() and close the underlying sockets.

Called automatically by the destructor (RAII equivalent of rpc.py's context-manager exit).

Implements profinet::rpc::IRPCCon.

Definition at line 3521 of file rpc.cpp.

References ccontrolTransport, Disconnect(), and rpcTransport.

Referenced by ~RPCCon(), and profinet::device::ProfinetDevice::ReadImplicit().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ CloseSockets()

void profinet::rpc::RPCCon::CloseSockets ( )
privatenoexcept

Close the RPC and CControl UDP sockets.

◆ Connect()

std::optional< ConnectResult > profinet::rpc::RPCCon::Connect ( std::optional< MacAddress srcMac = std::nullopt,
bool  withAlarmCr = false,
std::optional< IOCRSetup iocrSetup = std::nullopt 
)
overridevirtual

Establish (or re-establish) the AR with the device.

Parameters
srcMacSource MAC address; required on the first call.
withAlarmCrWhether to also request an AlarmCR (not all devices support it).
iocrSetupIf set, also establish cyclic IO (EXPERIMENTAL).
Returns
A ConnectResult when IocrSetup was provided, else std::nullopt.

Throws RPCConnectionError on failure.

Implements profinet::rpc::IRPCCon.

Definition at line 2612 of file rpc.cpp.

References activityUuid, alarmCrEnabled, profinet::ApplicationRelationRequest, profinet::PNNRDData::argsMaximumStatus, profinet::PNARBlockRequest::arProperties, profinet::PNARBlockRequest::arType, profinet::PNARBlockRequest::arUuid, arUuid, profinet::rpc::ConnectResult::arUuid, profinet::PNARBlockRequest::blockHeader, profinet::blockHeaderLenght, profinet::PNBlockHeader::blockLength, profinet::PNBlockHeader::blockType, profinet::PNBlockHeader::blockVersionHigh, profinet::PNBlockHeader::blockVersionLow, BuildAlarmCrBlock(), BuildExpectedSubmoduleBlock(), BuildIocrBlock(), profinet::PNARBlockRequest::cmInitiatorActivityTimeoutFactor, profinet::PNARBlockRequest::cmInitiatorMacAddress, profinet::PNARBlockRequest::cmInitiatorObjectUuid, profinet::PNARBlockRequest::cmInitiatorStationName, profinet::PNRPCHeader::CONNECT, CreateNrd(), CreateRpc(), deviceAlarmRef, profinet::PNIOError::FromArgsStatus(), profinet::PNARBlockRequest::initiatorUdpRtport, inputFrameId, inputIocrRef, iocrRefCounter, iocrSetup, profinet::PNARBlockRequest::kFixedSize, live, localObjectUuid, outputFrameId, outputIocrRef, profinet::PNNRDData::Parse(), ParseAlarmCrResponse(), ParseIocrResponse(), profinet::PNRPCHeader::payload, profinet::PNNRDData::payload, profinet::PROFINET_ETHERTYPE, SendReceive(), profinet::PNARBlockRequest::sessionKey, sessionKey, srcMac, profinet::PNARBlockRequest::stationNameLength, profinet::PNNRDData::ToBytes(), profinet::PNBlockHeader::ToBytes(), profinet::PNARBlockRequest::ToBytes(), profinet::rpc::VERSION_HIGH, and profinet::rpc::VERSION_LOW.

Referenced by CheckTimeout().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ CreateNrd()

PNNRDData profinet::rpc::RPCCon::CreateNrd ( const Bytes payload)
staticprivate

Wrap a payload in an NRD (Network Representation Data) header.

Parameters
payloadPayload to wrap.
Returns
The constructed NRD wrapper.

Definition at line 702 of file rpc.cpp.

References profinet::PNNRDData::actualCount, profinet::PNNRDData::argsLength, profinet::PNNRDData::argsMaximumStatus, profinet::PNNRDData::maximumCount, profinet::PNNRDData::offset, profinet::PNNRDData::payload, and payload.

Referenced by Connect(), Disconnect(), Read(), ReadImplicit(), SendControl(), Write(), and WriteMultiple().

+ Here is the caller graph for this function:

◆ CreateRpc()

PNRPCHeader profinet::rpc::RPCCon::CreateRpc ( std::uint16_t  operation,
const Bytes nrd 
)
private

◆ DeviceAlarmRef()

int profinet::rpc::RPCCon::DeviceAlarmRef ( ) const
inlineoverridevirtual

Device's local alarm reference, from AlarmCRBlockRes.

Returns
The device's alarm reference, or -1 if no AlarmCR was established (e.g. Connect() was called without WithAlarmCr).

Needed by AlarmEndpoint::DeviceRef regardless of whether cyclic IO (and thus a ConnectResult) was also requested.

Implements profinet::rpc::IRPCCon.

Definition at line 455 of file rpc.h.

References deviceAlarmRef.

◆ Disconnect()

void profinet::rpc::RPCCon::Disconnect ( )
overridevirtual

Send Release to terminate the AR.

Best-effort, does not wait for a response. Safe to call when not connected (no-op).

Implements profinet::rpc::IRPCCon.

Definition at line 3483 of file rpc.cpp.

References profinet::PNIODReleaseBlock::arUuid, arUuid, profinet::PNIODReleaseBlock::blockHeader, profinet::blockHeaderLenght, profinet::PNBlockHeader::blockLength, profinet::PNBlockHeader::blockType, profinet::PNBlockHeader::blockVersionHigh, profinet::PNBlockHeader::blockVersionLow, profinet::PNIODReleaseBlock::controlBlockProperties, profinet::PNIODReleaseBlock::controlCommand, CreateNrd(), CreateRpc(), live, profinet::PNIODReleaseBlock::padding1, profinet::PNIODReleaseBlock::padding2, profinet::Release, profinet::PNRPCHeader::RELEASE, profinet::ReleaseRequest, rpcTransport, profinet::PNIODReleaseBlock::sessionKey, sessionKey, profinet::PNRPCHeader::ToBytes(), profinet::PNNRDData::ToBytes(), profinet::PNBlockHeader::ToBytes(), and profinet::PNIODReleaseBlock::ToBytes().

Referenced by Close().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ DiscoverSlots()

std::vector< blocks::SlotInfo > profinet::rpc::RPCCon::DiscoverSlots ( )
overridevirtual

Convenience accessor for ReadRealIdentificationData().Slots.

Returns
The device's populated slots.

Implements profinet::rpc::IRPCCon.

Definition at line 3097 of file rpc.cpp.

References ReadRealIdentificationData(), and profinet::blocks::RealIdentificationData::slots.

+ Here is the call graph for this function:

◆ DiscoverTopology()

std::pair< blocks::PDRealData, blocks::RealIdentificationData > profinet::rpc::RPCCon::DiscoverTopology ( )
overridevirtual

Read both PDRealData and RealIdentificationData in one call.

Returns
A (PDRealData, RealIdentificationData) pair.

Implements profinet::rpc::IRPCCon.

Definition at line 3102 of file rpc.cpp.

References ReadPdRealData(), and ReadRealIdentificationData().

+ Here is the call graph for this function:

◆ EnumerateIndices()

std::map< std::uint16_t, rpc::IndexProbeResult > profinet::rpc::RPCCon::EnumerateIndices ( std::uint16_t  slot = 0,
std::uint16_t  subslot = 1,
std::optional< std::vector< std::uint16_t > >  customIndices = std::nullopt 
)
overridevirtual

Probe a set of indices and report which are readable/empty/erroring.

Parameters
slotSlot number to probe.
subslotSubslot number to probe.
customIndicesIf provided, only these indices are probed; otherwise the standard catalog (I&M, diagnosis, port/interface, device) is used, matching rpc.py's default probe list.
Returns
Probe results keyed by index.

Implements profinet::rpc::IRPCCon.

Definition at line 3107 of file rpc.cpp.

References profinet::DeviceIndices(), profinet::DiagnosisIndices(), profinet::rpc::IndexProbeResult::error, profinet::PNIOError::errorCode1, profinet::rpc::IndexProbeResult::errorCode1, profinet::PNIOError::errorCode2, profinet::rpc::IndexProbeResult::errorCode2, profinet::EXPECTED_ID_SUBSLOT, profinet::GetIndexName(), profinet::ImIndices(), profinet::InterfaceIndices(), profinet::MODULE_DIFF_BLOCK, profinet::rpc::IndexProbeResult::name, profinet::PNIODHeader::payload, profinet::PortIndices(), Read(), profinet::REAL_ID_SUBSLOT, profinet::RECORD_INPUT_DATA, profinet::RECORD_OUTPUT_DATA, profinet::rpc::IndexProbeResult::size, and profinet::rpc::IndexProbeResult::status.

+ Here is the call graph for this function:

◆ HasAlarmCr()

bool profinet::rpc::RPCCon::HasAlarmCr ( ) const
inlineoverridevirtual

Whether an AlarmCR was successfully established.

Returns
True if the device accepted an AlarmCR.

Implements profinet::rpc::IRPCCon.

Definition at line 462 of file rpc.h.

References alarmCrEnabled.

◆ Info()

const dcp::DCPDeviceDescription & profinet::rpc::RPCCon::Info ( ) const
inlineoverridevirtual

The device this connection targets.

Returns
The DCP-discovered device description.

Implements profinet::rpc::IRPCCon.

Definition at line 423 of file rpc.h.

References info.

◆ IoContext()

asio::io_context & profinet::rpc::RPCCon::IoContext ( )
inlineoverridevirtual

Returns the underlying Asio I/O context.

Returns
Reference to the Asio I/O context used by the RPC connection.

Implements profinet::rpc::IRPCCon.

Definition at line 467 of file rpc.h.

References ioContext.

◆ IsConnected()

bool profinet::rpc::RPCCon::IsConnected ( ) const
inlineoverridevirtual

Whether the AR is currently established.

Returns
True if connected.

Implements profinet::rpc::IRPCCon.

Definition at line 416 of file rpc.h.

References live.

◆ LocalAlarmRef()

std::uint16_t profinet::rpc::RPCCon::LocalAlarmRef ( ) const
inlineoverridevirtual

Controller's own local alarm reference.

Returns
The local alarm reference sent in AlarmCRBlockReq.

Implements profinet::rpc::IRPCCon.

Definition at line 444 of file rpc.h.

References alarmRef.

◆ operator=() [1/2]

RPCCon & profinet::rpc::RPCCon::operator= ( const RPCCon )
delete

Not copyable because the connection owns non-copyable Asio sockets.

◆ operator=() [2/2]

RPCCon & profinet::rpc::RPCCon::operator= ( RPCCon &&  )
delete

Deleted move assignment operator to prevent moving instances of this class.

Returns
A reference to the destination object (unreachable).

◆ ParseAlarmCrResponse()

int profinet::rpc::RPCCon::ParseAlarmCrResponse ( const Bytes responseData)
staticprivate

Parse the AlarmCRBlockRes from a CONNECT response.

Parameters
responseDataRaw CONNECT response NRD payload.
Returns
The device's local alarm reference, or -1 if not present.

Definition at line 739 of file rpc.cpp.

References profinet::PNAlarmCRBlockRes::BLOCK_TYPE, profinet::blockHeaderLenght, profinet::PNAlarmCRBlockRes::Parse(), and profinet::rpc::PeekBlockHeader().

Referenced by Connect().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ ParseIocrResponse()

std::uint16_t profinet::rpc::RPCCon::ParseIocrResponse ( const Bytes responseData,
int  iocrType 
)
staticprivate

Parse an IOCRBlockRes from a CONNECT response.

Parameters
responseDataRaw CONNECT response NRD payload.
iocrTypeIOCR type to look for (Input or Output).
Returns
The frame ID assigned by the device, or 0 if not present.

Definition at line 2519 of file rpc.cpp.

References profinet::PNIOCRBlockRes::BLOCK_TYPE, profinet::blockHeaderLenght, profinet::PNIOCRBlockRes::Parse(), and profinet::rpc::PeekBlockHeader().

Referenced by Connect().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ PrmBegin()

Bytes profinet::rpc::RPCCon::PrmBegin ( )
overridevirtual

Send PrmBegin (start of the parameterization phase).

Returns
The NRD response payload.

Implements profinet::rpc::IRPCCon.

Definition at line 3226 of file rpc.cpp.

References profinet::ParameterizationBeginRequest, profinet::PrmBegin, and SendControl().

+ Here is the call graph for this function:

◆ PrmEnd()

Bytes profinet::rpc::RPCCon::PrmEnd ( )
overridevirtual

Send PrmEnd (end of the parameterization phase).

Returns
The NRD response payload.

Implements profinet::rpc::IRPCCon.

Definition at line 3230 of file rpc.cpp.

References profinet::ControlPrmEndRequest, profinet::PrmEnd, and SendControl().

+ Here is the call graph for this function:

◆ Read()

PNIODHeader profinet::rpc::RPCCon::Read ( std::uint32_t  api,
std::uint16_t  slot,
std::uint16_t  subslot,
std::uint16_t  idx 
)
overridevirtual

Read a data record via slot/subslot/index (AR must be connected).

Parameters
apiAPI number.
slotSlot number.
subslotSubslot number.
idxRecord data index to read.
Returns
The parsed IOD response header and payload.

Throws PNIOError on a device-reported error, RPCTimeoutError on timeout.

Implements profinet::rpc::IRPCCon.

Definition at line 2748 of file rpc.cpp.

References profinet::PNIODHeader::api, profinet::PNNRDData::argsMaximumStatus, profinet::PNIODHeader::arUuid, arUuid, profinet::PNIODHeader::blockHeader, profinet::blockHeaderLenght, profinet::PNBlockHeader::blockLength, profinet::PNBlockHeader::blockType, profinet::PNBlockHeader::blockVersionHigh, profinet::PNBlockHeader::blockVersionLow, CheckTimeout(), CreateNrd(), CreateRpc(), profinet::PNBlockHeader::DEFAULT_BLOCK_LENGTH, profinet::PNIOError::FromArgsStatus(), profinet::PNIODHeader::index, profinet::PNBlockHeader::IODReadRequestHeader, profinet::PNIODHeader::length, profinet::PNIODHeader::padding1, profinet::PNIODHeader::padding2, profinet::PNNRDData::Parse(), profinet::PNIODHeader::Parse(), profinet::PNRPCHeader::payload, profinet::PNNRDData::payload, profinet::PNRPCHeader::READ, SendReceive(), profinet::PNIODHeader::sequenceNumber, profinet::PNIODHeader::slot, profinet::PNIODHeader::subslot, profinet::PNIODHeader::targetArUuid, profinet::PNNRDData::ToBytes(), profinet::PNIODHeader::ToBytes(), profinet::PNBlockHeader::ToBytes(), profinet::rpc::VERSION_HIGH, and profinet::rpc::VERSION_LOW.

Referenced by EnumerateIndices(), ReadDiagnosis(), ReadIm0(), ReadIm1(), ReadIm10(), ReadIm11(), ReadIm12(), ReadIm13(), ReadIm14(), ReadIm15(), ReadIm2(), ReadIm3(), ReadIm4(), ReadIm5(), ReadIm6(), ReadIm7(), ReadIm8(), ReadIm9(), ReadModuleDiff(), ReadPdRealData(), ReadRaw(), and ReadRealIdentificationData().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ ReadAllDiagnosis()

std::map< std::uint16_t, diagnosis::DiagnosisData > profinet::rpc::RPCCon::ReadAllDiagnosis ( )
overridevirtual

Read diagnosis from all standard diagnosis indices.

Returns
Diagnosis data keyed by index, for indices with at least one entry.

Covers subslot/device/API-level indices.

Implements profinet::rpc::IRPCCon.

Definition at line 3055 of file rpc.cpp.

References profinet::diagnosis::DiagnosisData::entries, and ReadDiagnosis().

+ Here is the call graph for this function:

◆ ReadAllIm()

AllIM profinet::rpc::RPCCon::ReadAllIm ( std::uint16_t  slot = 0,
std::uint16_t  subslot = 1 
)
overridevirtual

Read all I&M records a device supports.

Parameters
slotSlot number (defaults to 0, the device's DAP).
subslotSubslot number (defaults to 1).
Returns
The records that were successfully read (see AllIM for per-record semantics).

Implements profinet::rpc::IRPCCon.

Definition at line 2924 of file rpc.cpp.

References profinet::rpc::AllIM::im0, profinet::rpc::AllIM::im1, profinet::rpc::AllIM::im10, profinet::rpc::AllIM::im11, profinet::rpc::AllIM::im12, profinet::rpc::AllIM::im13, profinet::rpc::AllIM::im14, profinet::rpc::AllIM::im15, profinet::rpc::AllIM::im2, profinet::rpc::AllIM::im3, profinet::rpc::AllIM::im4, profinet::rpc::AllIM::im5, profinet::rpc::AllIM::im6, profinet::rpc::AllIM::im7, profinet::rpc::AllIM::im8, profinet::rpc::AllIM::im9, ReadIm0(), ReadIm1(), ReadIm10(), ReadIm11(), ReadIm12(), ReadIm13(), ReadIm14(), ReadIm15(), ReadIm2(), ReadIm3(), ReadIm4(), ReadIm5(), ReadIm6(), ReadIm7(), ReadIm8(), and ReadIm9().

+ Here is the call graph for this function:

◆ ReadDiagnosis()

diagnosis::DiagnosisData profinet::rpc::RPCCon::ReadDiagnosis ( std::uint16_t  slot = 0,
std::uint16_t  subslot = 0,
std::uint16_t  index = 0xF000 
)
overridevirtual

Read and parse diagnosis data at the given location/index.

Parameters
slotSlot number to read diagnosis for.
subslotSubslot number to read diagnosis for.
indexDiagnosis record index to read.
Returns
The parsed diagnosis data (empty if none is present).

Falls back from the full block parser to the simple parser if the full parse yields no entries, matching rpc.py. Returns an empty DiagnosisData (does not throw) on any RPCError, matching rpc.py's own "log and return empty" behavior.

Implements profinet::rpc::IRPCCon.

Definition at line 3022 of file rpc.cpp.

References profinet::diagnosis::DiagnosisData::api, profinet::diagnosis::DiagnosisData::entries, profinet::diagnosis::ParseDiagnosisBlock(), profinet::diagnosis::ParseDiagnosisSimple(), profinet::PNIODHeader::payload, profinet::diagnosis::DiagnosisData::rawData, Read(), profinet::diagnosis::DiagnosisData::slot, and profinet::diagnosis::DiagnosisData::subslot.

Referenced by ReadAllDiagnosis().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ ReadIm0()

PNInM0 profinet::rpc::RPCCon::ReadIm0 ( std::uint16_t  slot = 0,
std::uint16_t  subslot = 1 
)
overridevirtual

Read I&M0 (mandatory identification data).

Parameters
slotSlot number (defaults to 0, the device's DAP).
subslotSubslot number (defaults to 1).
Returns
The parsed I&M0 record.

Implements profinet::rpc::IRPCCon.

Definition at line 2859 of file rpc.cpp.

References profinet::PNInM0::IDX, profinet::PNInM0::Parse(), payload, and Read().

Referenced by ReadAllIm().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ ReadIm1()

PNInM1 profinet::rpc::RPCCon::ReadIm1 ( std::uint16_t  slot = 0,
std::uint16_t  subslot = 1 
)
overridevirtual

Read I&M1 (tag function/location).

Parameters
slotSlot number (defaults to 0, the device's DAP).
subslotSubslot number (defaults to 1).
Returns
The parsed I&M1 record.

Implements profinet::rpc::IRPCCon.

Definition at line 2863 of file rpc.cpp.

References profinet::PNInM1::IDX, profinet::PNInM1::Parse(), payload, and Read().

Referenced by ReadAllIm().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ ReadIm10()

PNInM10 profinet::rpc::RPCCon::ReadIm10 ( std::uint16_t  slot = 0,
std::uint16_t  subslot = 1 
)
overridevirtual

Read I&M10 (reserved).

Parameters
slotSlot number (defaults to 0, the device's DAP).
subslotSubslot number (defaults to 1).
Returns
The parsed I&M10 record.

Implements profinet::rpc::IRPCCon.

Definition at line 2899 of file rpc.cpp.

References profinet::PNInMReserved< Idx >::IDX, profinet::PNInMReserved< Idx >::Parse(), payload, and Read().

Referenced by ReadAllIm().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ ReadIm11()

PNInM11 profinet::rpc::RPCCon::ReadIm11 ( std::uint16_t  slot = 0,
std::uint16_t  subslot = 1 
)
overridevirtual

Read I&M11 (reserved).

Parameters
slotSlot number (defaults to 0, the device's DAP).
subslotSubslot number (defaults to 1).
Returns
The parsed I&M11 record.

Implements profinet::rpc::IRPCCon.

Definition at line 2903 of file rpc.cpp.

References profinet::PNInMReserved< Idx >::IDX, profinet::PNInMReserved< Idx >::Parse(), payload, and Read().

Referenced by ReadAllIm().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ ReadIm12()

PNInM12 profinet::rpc::RPCCon::ReadIm12 ( std::uint16_t  slot = 0,
std::uint16_t  subslot = 1 
)
overridevirtual

Read I&M12 (reserved).

Parameters
slotSlot number (defaults to 0, the device's DAP).
subslotSubslot number (defaults to 1).
Returns
The parsed I&M12 record.

Implements profinet::rpc::IRPCCon.

Definition at line 2907 of file rpc.cpp.

References profinet::PNInMReserved< Idx >::IDX, profinet::PNInMReserved< Idx >::Parse(), payload, and Read().

Referenced by ReadAllIm().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ ReadIm13()

PNInM13 profinet::rpc::RPCCon::ReadIm13 ( std::uint16_t  slot = 0,
std::uint16_t  subslot = 1 
)
overridevirtual

Read I&M13 (reserved).

Parameters
slotSlot number (defaults to 0, the device's DAP).
subslotSubslot number (defaults to 1).
Returns
The parsed I&M13 record.

Implements profinet::rpc::IRPCCon.

Definition at line 2911 of file rpc.cpp.

References profinet::PNInMReserved< Idx >::IDX, profinet::PNInMReserved< Idx >::Parse(), payload, and Read().

Referenced by ReadAllIm().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ ReadIm14()

PNInM14 profinet::rpc::RPCCon::ReadIm14 ( std::uint16_t  slot = 0,
std::uint16_t  subslot = 1 
)
overridevirtual

Read I&M14 (reserved).

Parameters
slotSlot number (defaults to 0, the device's DAP).
subslotSubslot number (defaults to 1).
Returns
The parsed I&M14 record.

Implements profinet::rpc::IRPCCon.

Definition at line 2915 of file rpc.cpp.

References profinet::PNInMReserved< Idx >::IDX, profinet::PNInMReserved< Idx >::Parse(), payload, and Read().

Referenced by ReadAllIm().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ ReadIm15()

PNInM15 profinet::rpc::RPCCon::ReadIm15 ( std::uint16_t  slot = 0,
std::uint16_t  subslot = 1 
)
overridevirtual

Read I&M15 (reserved).

Parameters
slotSlot number (defaults to 0, the device's DAP).
subslotSubslot number (defaults to 1).
Returns
The parsed I&M15 record.

Implements profinet::rpc::IRPCCon.

Definition at line 2919 of file rpc.cpp.

References profinet::PNInMReserved< Idx >::IDX, profinet::PNInMReserved< Idx >::Parse(), payload, and Read().

Referenced by ReadAllIm().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ ReadIm2()

PNInM2 profinet::rpc::RPCCon::ReadIm2 ( std::uint16_t  slot = 0,
std::uint16_t  subslot = 1 
)
overridevirtual

Read I&M2 (installation date).

Parameters
slotSlot number (defaults to 0, the device's DAP).
subslotSubslot number (defaults to 1).
Returns
The parsed I&M2 record.

Implements profinet::rpc::IRPCCon.

Definition at line 2867 of file rpc.cpp.

References profinet::PNInM2::IDX, profinet::PNInM2::Parse(), payload, and Read().

Referenced by ReadAllIm().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ ReadIm3()

PNInM3 profinet::rpc::RPCCon::ReadIm3 ( std::uint16_t  slot = 0,
std::uint16_t  subslot = 1 
)
overridevirtual

Read I&M3 (free-text descriptor).

Parameters
slotSlot number (defaults to 0, the device's DAP).
subslotSubslot number (defaults to 1).
Returns
The parsed I&M3 record.

Implements profinet::rpc::IRPCCon.

Definition at line 2871 of file rpc.cpp.

References profinet::PNInM3::IDX, profinet::PNInM3::Parse(), payload, and Read().

Referenced by ReadAllIm().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ ReadIm4()

PNInM4 profinet::rpc::RPCCon::ReadIm4 ( std::uint16_t  slot = 0,
std::uint16_t  subslot = 1 
)
overridevirtual

Read I&M4 (PROFIsafe signature).

Parameters
slotSlot number (defaults to 0, the device's DAP).
subslotSubslot number (defaults to 1).
Returns
The parsed I&M4 record.

Implements profinet::rpc::IRPCCon.

Definition at line 2875 of file rpc.cpp.

References profinet::PNInM4::IDX, profinet::PNInM4::Parse(), payload, and Read().

Referenced by ReadAllIm().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ ReadIm5()

PNInM5 profinet::rpc::RPCCon::ReadIm5 ( std::uint16_t  slot = 0,
std::uint16_t  subslot = 1 
)
overridevirtual

Read I&M5 (free-text annotation).

Parameters
slotSlot number (defaults to 0, the device's DAP).
subslotSubslot number (defaults to 1).
Returns
The parsed I&M5 record.

Implements profinet::rpc::IRPCCon.

Definition at line 2879 of file rpc.cpp.

References profinet::PNInM5::IDX, profinet::PNInM5::Parse(), payload, and Read().

Referenced by ReadAllIm().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ ReadIm6()

PNInM6 profinet::rpc::RPCCon::ReadIm6 ( std::uint16_t  slot = 0,
std::uint16_t  subslot = 1 
)
overridevirtual

Read I&M6 (reserved).

Parameters
slotSlot number (defaults to 0, the device's DAP).
subslotSubslot number (defaults to 1).
Returns
The parsed I&M6 record.

Implements profinet::rpc::IRPCCon.

Definition at line 2883 of file rpc.cpp.

References profinet::PNInMReserved< Idx >::IDX, profinet::PNInMReserved< Idx >::Parse(), payload, and Read().

Referenced by ReadAllIm().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ ReadIm7()

PNInM7 profinet::rpc::RPCCon::ReadIm7 ( std::uint16_t  slot = 0,
std::uint16_t  subslot = 1 
)
overridevirtual

Read I&M7 (reserved).

Parameters
slotSlot number (defaults to 0, the device's DAP).
subslotSubslot number (defaults to 1).
Returns
The parsed I&M7 record.

Implements profinet::rpc::IRPCCon.

Definition at line 2887 of file rpc.cpp.

References profinet::PNInMReserved< Idx >::IDX, profinet::PNInMReserved< Idx >::Parse(), payload, and Read().

Referenced by ReadAllIm().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ ReadIm8()

PNInM8 profinet::rpc::RPCCon::ReadIm8 ( std::uint16_t  slot = 0,
std::uint16_t  subslot = 1 
)
overridevirtual

Read I&M8 (reserved).

Parameters
slotSlot number (defaults to 0, the device's DAP).
subslotSubslot number (defaults to 1).
Returns
The parsed I&M8 record.

Implements profinet::rpc::IRPCCon.

Definition at line 2891 of file rpc.cpp.

References profinet::PNInMReserved< Idx >::IDX, profinet::PNInMReserved< Idx >::Parse(), payload, and Read().

Referenced by ReadAllIm().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ ReadIm9()

PNInM9 profinet::rpc::RPCCon::ReadIm9 ( std::uint16_t  slot = 0,
std::uint16_t  subslot = 1 
)
overridevirtual

Read I&M9 (reserved).

Parameters
slotSlot number (defaults to 0, the device's DAP).
subslotSubslot number (defaults to 1).
Returns
The parsed I&M9 record.

Implements profinet::rpc::IRPCCon.

Definition at line 2895 of file rpc.cpp.

References profinet::PNInMReserved< Idx >::IDX, profinet::PNInMReserved< Idx >::Parse(), payload, and Read().

Referenced by ReadAllIm().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ ReadImplicit()

PNIODHeader profinet::rpc::RPCCon::ReadImplicit ( std::uint32_t  api,
std::uint16_t  slot,
std::uint16_t  subslot,
std::uint16_t  idx 
)
overridevirtual

Read a data record without an established AR.

Parameters
apiAPI number.
slotSlot number.
subslotSubslot number.
idxRecord data index to read.
Returns
The parsed IOD response header and payload.

Implements profinet::rpc::IRPCCon.

Definition at line 2784 of file rpc.cpp.

References profinet::PNIODHeader::api, profinet::PNNRDData::argsMaximumStatus, profinet::PNIODHeader::arUuid, profinet::PNIODHeader::blockHeader, profinet::blockHeaderLenght, profinet::PNBlockHeader::blockLength, profinet::PNBlockHeader::blockType, profinet::PNBlockHeader::blockVersionHigh, profinet::PNBlockHeader::blockVersionLow, CreateNrd(), CreateRpc(), profinet::PNIOError::FromArgsStatus(), profinet::PNRPCHeader::IMPLICIT_READ, profinet::PNIODHeader::index, profinet::PNBlockHeader::IODReadRequestHeader, profinet::PNIODHeader::length, profinet::PNIODHeader::padding1, profinet::PNIODHeader::padding2, profinet::PNNRDData::Parse(), profinet::PNIODHeader::Parse(), profinet::PNRPCHeader::payload, profinet::PNNRDData::payload, SendReceive(), profinet::PNIODHeader::sequenceNumber, profinet::PNIODHeader::slot, profinet::PNIODHeader::subslot, profinet::PNIODHeader::targetArUuid, profinet::PNNRDData::ToBytes(), profinet::PNIODHeader::ToBytes(), and profinet::PNBlockHeader::ToBytes().

Referenced by profinet::device::ProfinetDevice::ReadImplicit().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ ReadModuleDiff()

blocks::ModuleDiffBlock profinet::rpc::RPCCon::ReadModuleDiff ( )
overridevirtual

Read and parse the device's ModuleDiffBlock.

Returns
The parsed module/submodule configuration differences.

Implements profinet::rpc::IRPCCon.

Definition at line 3016 of file rpc.cpp.

References profinet::MODULE_DIFF_BLOCK, profinet::blocks::ParseModuleDiffBlock(), profinet::PNIODHeader::payload, and Read().

+ Here is the call graph for this function:

◆ ReadPdRealData()

blocks::PDRealData profinet::rpc::RPCCon::ReadPdRealData ( )
overridevirtual

Read and parse the device's PDRealData (physical topology).

Returns
The parsed interface and port information.

Implements profinet::rpc::IRPCCon.

Definition at line 3085 of file rpc.cpp.

References profinet::blocks::ParsePdRealData(), profinet::PNIODHeader::payload, profinet::PD_REAL_DATA, and Read().

Referenced by DiscoverTopology().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ ReadRaw()

Bytes profinet::rpc::RPCCon::ReadRaw ( std::uint16_t  idx,
std::uint16_t  slot = 0,
std::uint16_t  subslot = 1 
)

Read a raw record payload by index (convenience wrapper over Read()).

Parameters
idxRecord data index to read.
slotSlot number.
subslotSubslot number.
Returns
The raw record payload.

Definition at line 2854 of file rpc.cpp.

References profinet::PNIODHeader::payload, and Read().

+ Here is the call graph for this function:

◆ ReadRealIdentificationData()

blocks::RealIdentificationData profinet::rpc::RPCCon::ReadRealIdentificationData ( )
overridevirtual

Read and parse the device's RealIdentificationData (logical structure).

Returns
The parsed slot/subslot structure.

Implements profinet::rpc::IRPCCon.

Definition at line 3091 of file rpc.cpp.

References profinet::blocks::ParseRealIdentificationData(), profinet::PNIODHeader::payload, Read(), and profinet::REAL_ID_API.

Referenced by DiscoverSlots(), and DiscoverTopology().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ ReadyForRtClass3()

Bytes profinet::rpc::RPCCon::ReadyForRtClass3 ( )
overridevirtual

Send ReadyForRTClass3 (isochronous real-time readiness).

Returns
The NRD response payload.

Implements profinet::rpc::IRPCCon.

Definition at line 3234 of file rpc.cpp.

References profinet::ControlRtClass3Request, profinet::ReadyForRtClass3, and SendControl().

+ Here is the call graph for this function:

◆ SendControl()

Bytes profinet::rpc::RPCCon::SendControl ( BlockType  blockType,
ControlCommand  controlCommand,
bool  waitResponse = true,
const Bytes subBlocks = {} 
)
private

Send a CONTROL operation and optionally wait for its response.

Parameters
blockTypeControl block type.
controlCommandControl command bitmask.
waitResponseWhether to wait for and return the response.
subBlocksAdditional blocks to append after the control block.
Returns
The NRD response payload, or empty if WaitResponse is false.

Definition at line 3181 of file rpc.cpp.

References profinet::PNNRDData::argsMaximumStatus, profinet::PNIODReleaseBlock::arUuid, arUuid, profinet::PNIODReleaseBlock::blockHeader, profinet::blockHeaderLenght, profinet::PNBlockHeader::blockLength, profinet::PNBlockHeader::blockType, profinet::PNBlockHeader::blockVersionHigh, profinet::PNBlockHeader::blockVersionLow, profinet::PNRPCHeader::CONTROL, profinet::PNIODReleaseBlock::controlBlockProperties, profinet::PNIODReleaseBlock::controlCommand, CreateNrd(), CreateRpc(), profinet::PNIOError::FromArgsStatus(), live, profinet::PNIODReleaseBlock::padding1, profinet::PNIODReleaseBlock::padding2, profinet::PNNRDData::Parse(), profinet::PNRPCHeader::payload, profinet::PNNRDData::payload, rpcTransport, SendReceive(), profinet::PNIODReleaseBlock::sessionKey, sessionKey, profinet::PNRPCHeader::ToBytes(), profinet::PNNRDData::ToBytes(), profinet::PNBlockHeader::ToBytes(), and profinet::PNIODReleaseBlock::ToBytes().

Referenced by PrmBegin(), PrmEnd(), and ReadyForRtClass3().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ SendReceive()

PNRPCHeader profinet::rpc::RPCCon::SendReceive ( const PNRPCHeader request)
private

Send an RPC request and synchronously wait for its response.

Parameters
requestRPC request packet to transmit.
Returns
Parsed RPC response packet.
Exceptions
RPCTimeoutErrorwhen no response arrives before the configured timeout.
RPCErrorwhen the socket or RPC response is invalid.

Definition at line 2547 of file rpc.cpp.

References profinet::PNRPCHeader::FAULT, info, profinet::PNRPCHeader::kFixedSize, live, liveMonotonic, profinet::dcp::DCPDeviceDescription::name, profinet::PNRPCHeader::operationNumber, profinet::PNRPCHeader::packetType, profinet::PNRPCHeader::Parse(), profinet::PNRPCHeader::REJECT, profinet::PNRPCHeader::REQUEST, profinet::PNRPCHeader::RESPONSE, rpcTransport, timeout, and profinet::PNRPCHeader::ToBytes().

Referenced by Connect(), Read(), ReadImplicit(), SendControl(), Write(), and WriteMultiple().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ SessionKey()

std::uint16_t profinet::rpc::RPCCon::SessionKey ( ) const
inline

The session key for this connection.

Returns
The session key.

Definition at line 437 of file rpc.h.

References sessionKey.

◆ Write()

void profinet::rpc::RPCCon::Write ( std::uint32_t  api,
std::uint16_t  slot,
std::uint16_t  subslot,
std::uint16_t  idx,
const Bytes data 
)
overridevirtual

◆ WriteMultiple()

std::vector< blocks::WriteMultipleResult > profinet::rpc::RPCCon::WriteMultiple ( const std::vector< WriteItem > &  writes)
overridevirtual

Write multiple records atomically via IODWriteMultipleReq (0xE040).

Parameters
writesThe individual write operations to perform.
Returns
Per-write results (which may include per-write failures).

Throws PNIOError/RPCError if the overall request fails; individual per-write results are returned rather than thrown.

Implements profinet::rpc::IRPCCon.

Definition at line 2968 of file rpc.cpp.

References profinet::blocks::IODWriteMultipleBuilder::AddWrite(), profinet::PNIODHeader::api, profinet::PNNRDData::argsMaximumStatus, profinet::PNIODHeader::arUuid, arUuid, profinet::PNIODHeader::blockHeader, profinet::blockHeaderLenght, profinet::PNBlockHeader::blockLength, profinet::PNBlockHeader::blockType, profinet::PNBlockHeader::blockVersionHigh, profinet::PNBlockHeader::blockVersionLow, profinet::blocks::IODWriteMultipleBuilder::Build(), CheckTimeout(), CreateNrd(), CreateRpc(), profinet::PNIOError::FromArgsStatus(), profinet::PNIODHeader::index, profinet::IoDataWriteRequest, profinet::PNIODHeader::length, profinet::PNIODHeader::padding1, profinet::PNIODHeader::padding2, profinet::PNNRDData::Parse(), profinet::blocks::ParseWriteMultipleResponse(), profinet::PNRPCHeader::payload, profinet::PNNRDData::payload, profinet::PNIODHeader::payload, payload, SendReceive(), profinet::PNIODHeader::sequenceNumber, profinet::PNIODHeader::slot, profinet::PNIODHeader::subslot, profinet::PNIODHeader::targetArUuid, profinet::PNNRDData::ToBytes(), profinet::PNIODHeader::ToBytes(), profinet::PNBlockHeader::ToBytes(), profinet::PNRPCHeader::WRITE, and profinet::blocks::IODWriteMultipleBuilder::writeMultipleIndex.

+ Here is the call graph for this function:

Friends And Related Symbol Documentation

◆ RpcTest

friend class RpcTest
friend

FRIEND_CLASS declaration granting access to the specific test case for validating CreateRpc.

Definition at line 153 of file rpc.h.

Member Data Documentation

◆ activityUuid

std::array<std::uint8_t, uuidLenght> profinet::rpc::RPCCon::activityUuid {}
private

Activity UUID for the current RPC exchange.

Definition at line 548 of file rpc.h.

Referenced by RPCCon(), Connect(), and CreateRpc().

◆ alarmCrEnabled

bool profinet::rpc::RPCCon::alarmCrEnabled = false
private

Whether an AlarmCR was successfully established.

Definition at line 576 of file rpc.h.

Referenced by Connect(), and HasAlarmCr().

◆ alarmRef

std::uint16_t profinet::rpc::RPCCon::alarmRef = 0x8001
private

Controller's own local alarm reference.

Definition at line 570 of file rpc.h.

Referenced by BuildAlarmCrBlock(), and LocalAlarmRef().

◆ arUuid

std::array<std::uint8_t, uuidLenght> profinet::rpc::RPCCon::arUuid {}
private

AR UUID for this connection.

Definition at line 545 of file rpc.h.

Referenced by RPCCon(), ApplicationReady(), ArUuid(), Connect(), Disconnect(), Read(), SendControl(), Write(), and WriteMultiple().

◆ ccontrolTransport

std::unique_ptr<RpcTransport> profinet::rpc::RPCCon::ccontrolTransport
private

Definition at line 603 of file rpc.h.

Referenced by RPCCon(), ApplicationReady(), and Close().

◆ deviceAlarmRef

int profinet::rpc::RPCCon::deviceAlarmRef = 0
private

Device's local alarm reference, if an AlarmCR was established.

Definition at line 573 of file rpc.h.

Referenced by Connect(), and DeviceAlarmRef().

◆ info

dcp::DCPDeviceDescription profinet::rpc::RPCCon::info
private

DCP-discovered description of the target device.

Definition at line 539 of file rpc.h.

Referenced by RPCCon(), Info(), and SendReceive().

◆ inputFrameId

std::uint16_t profinet::rpc::RPCCon::inputFrameId = 0
private

Frame ID assigned to the input IOCR.

Definition at line 591 of file rpc.h.

Referenced by Connect().

◆ inputIocrRef

int profinet::rpc::RPCCon::inputIocrRef = 0
private

IOCR reference for the input (device -> controller) IOCR.

Definition at line 585 of file rpc.h.

Referenced by Connect().

◆ ioContext

asio::io_context profinet::rpc::RPCCon::ioContext {}
private

Asio execution context used by the RPC transport.

Definition at line 600 of file rpc.h.

Referenced by IoContext().

◆ iocrRefCounter

int profinet::rpc::RPCCon::iocrRefCounter = 1
private

Counter used to allocate unique IOCR references.

Definition at line 582 of file rpc.h.

Referenced by Connect().

◆ iocrSetup

std::optional<IOCRSetup> profinet::rpc::RPCCon::iocrSetup
private

Cyclic IO configuration used for the current AR, if any.

Definition at line 597 of file rpc.h.

Referenced by Connect().

◆ live

bool profinet::rpc::RPCCon::live = false
private

Whether the AR is currently established.

Definition at line 557 of file rpc.h.

Referenced by ApplicationReady(), CheckTimeout(), Connect(), Disconnect(), IsConnected(), SendControl(), and SendReceive().

◆ liveMonotonic

std::chrono::steady_clock::time_point profinet::rpc::RPCCon::liveMonotonic {}
private

Timestamp of the last successful RPC exchange, for CONNECTION_TIMEOUT tracking.

Definition at line 560 of file rpc.h.

Referenced by ApplicationReady(), CheckTimeout(), and SendReceive().

◆ localObjectUuid

std::array<std::uint8_t, uuidLenght> profinet::rpc::RPCCon::localObjectUuid {}
private

This controller's own object UUID.

Definition at line 551 of file rpc.h.

Referenced by RPCCon(), and Connect().

◆ outputFrameId

std::uint16_t profinet::rpc::RPCCon::outputFrameId = 0
private

Frame ID assigned to the output IOCR.

Definition at line 594 of file rpc.h.

Referenced by Connect().

◆ outputIocrRef

int profinet::rpc::RPCCon::outputIocrRef = 0
private

IOCR reference for the output (controller -> device) IOCR.

Definition at line 588 of file rpc.h.

Referenced by Connect().

◆ remoteObjectUuid

std::array<std::uint8_t, uuidLenght> profinet::rpc::RPCCon::remoteObjectUuid {}
private

The target device's object UUID.

Definition at line 554 of file rpc.h.

Referenced by RPCCon(), and CreateRpc().

◆ rpcTransport

std::unique_ptr<RpcTransport> profinet::rpc::RPCCon::rpcTransport
private

Definition at line 602 of file rpc.h.

Referenced by RPCCon(), Close(), Disconnect(), SendControl(), and SendReceive().

◆ sequenceNumber

std::uint32_t profinet::rpc::RPCCon::sequenceNumber = 0
private

Monotonically increasing RPC sequence number.

Definition at line 579 of file rpc.h.

Referenced by CreateRpc().

◆ sessionKey

std::uint16_t profinet::rpc::RPCCon::sessionKey = 0
private

Session key for this connection.

Definition at line 566 of file rpc.h.

Referenced by ApplicationReady(), Connect(), Disconnect(), SendControl(), and SessionKey().

◆ srcMac

std::optional<MacAddress> profinet::rpc::RPCCon::srcMac
private

Source MAC address used to establish the AR.

Definition at line 563 of file rpc.h.

Referenced by Connect().

◆ timeout

double profinet::rpc::RPCCon::timeout
private

Default RPC response timeout in seconds.

Definition at line 542 of file rpc.h.

Referenced by SendReceive().


The documentation for this class was generated from the following files: