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

High-level PROFINET device interface and device lifecycle management. More...

#include <functional>
#include <map>
#include <memory>
#include <optional>
#include <string>
#include <vector>
#include "profinet/alarmListener.h"
#include "profinet/alarms.h"
#include "profinet/blocks.h"
#include "profinet/cyclic.h"
#include "profinet/dcp.h"
#include "profinet/diagnosis.h"
#include "profinet/protocol.h"
#include "profinet/rpc.h"
#include "profinet/rt.h"
#include "profinet/util.h"
+ Include dependency graph for device.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  profinet::device::WriteItem
 A single write operation for ProfinetDevice::WriteMultiple(). More...
 
struct  profinet::device::DeviceInfo
 Complete device information summary. More...
 
class  profinet::device::ProfinetDevice
 High-level PROFINET device interface. More...
 

Namespaces

namespace  profinet
 
namespace  profinet::device
 

Functions

std::optional< MacAddressprofinet::device::ParseMac (const std::string &macStr)
 Parse a MAC address string in any common separator style.
 
bool profinet::device::IsMacAddress (const std::string &identifier)
 Whether a string parses as a MAC address.
 
std::vector< ProfinetDeviceprofinet::device::Scan (const std::string &interface="eth0", double timeoutSec=3.0)
 Scan the network for PROFINET devices via DCP Identify.
 
std::map< std::string, DeviceInfoprofinet::device::ScanDict (const std::string &interface="eth0", double timeoutSec=3.0)
 Scan the network and return a name -> DeviceInfo map.
 

Detailed Description

High-level PROFINET device interface and device lifecycle management.

Provides the user-facing interface for discovering, connecting to, and interacting with PROFINET devices. The implementation is ported from profinet-py's device.py and combines DCP discovery, DCE/RPC record access, I&M data, diagnostics, alarms, and cyclic I/O behind a single device API.

The header provides:

  • MAC address parsing and validation helpers.
  • DeviceInfo for combining DCP and optional I&M/topology information.
  • ProfinetDevice for device discovery and connection lifecycle management.
  • Raw and AR-less record read/write operations.
  • I&M0-I&M5 read and I&M1-I&M3 write convenience methods.
  • Module configuration and diagnosis access.
  • Alarm reading, callbacks, and background alarm listening.
  • Cyclic I/O establishment and controller management.
  • Network-wide DCP device scanning and ScanDict() discovery helpers.

ProfinetDevice manages its RPC connection and alarm listener using RAII and supports dependency injection of RPC and alarm components for testing. Operations that require an established Application Relationship connect automatically when necessary.

Example: auto device = profinet::device::ProfinetDevice::Discover("my-device", "eth0"); device.Connect(); auto im0 = device.ReadIm0(); std::cout << im0.OrderId << "\n"; device.Close();

Definition in file device.h.