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

Classes

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

Functions

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

Function Documentation

◆ IsMacAddress()

bool profinet::device::IsMacAddress ( const std::string &  identifier)

Whether a string parses as a MAC address.

Parameters
identifierString to test.
Returns
True if ParseMac(Identifier) would succeed.

Definition at line 173 of file device.cpp.

References ParseMac().

+ Here is the call graph for this function:

◆ ParseMac()

std::optional< MacAddress > profinet::device::ParseMac ( const std::string &  macStr)

Parse a MAC address string in any common separator style.

Parameters
macStrMAC address as "aa:bb:cc:dd:ee:ff", "aa-bb-cc-dd-ee-ff", or "aa.bb.cc.dd.ee.ff".
Returns
The parsed 6-byte MAC address, or std::nullopt (not a throw) for anything that doesn't parse as exactly 6 hex octets.

Matches device.py's _parse_mac – used to distinguish a MAC-address identifier from a station-name identifier in Discover().

Definition at line 57 of file device.cpp.

References profinet::macAddressLength.

Referenced by profinet::device::ProfinetDevice::Discover(), and IsMacAddress().

+ Here is the caller graph for this function:

◆ Scan()

std::vector< ProfinetDevice > profinet::device::Scan ( const std::string &  interface = "eth0",
double  timeoutSec = 3.0 
)

Scan the network for PROFINET devices via DCP Identify.

Parameters
interfaceNetwork interface name to use, e.g. "eth0".
timeoutSecHow long to listen for responses.
Returns
The discovered devices.

Throws PermissionDeniedError if raw-socket privileges are insufficient.

Definition at line 713 of file device.cpp.

References profinet::GetMac(), profinet::dcp::ReadResponse(), and profinet::dcp::SendDiscover().

Referenced by ScanDict().

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

◆ ScanDict()

std::map< std::string, DeviceInfo > profinet::device::ScanDict ( const std::string &  interface = "eth0",
double  timeoutSec = 3.0 
)

Scan the network and return a name -> DeviceInfo map.

Parameters
interfaceNetwork interface name to use, e.g. "eth0".
timeoutSecHow long to listen for responses.
Returns
DCP-discovered fields keyed by station name; no RPC connection is made, so Im0/Topology/Annotation are left unset.

Definition at line 731 of file device.cpp.

References profinet::device::DeviceInfo::ip, profinet::device::DeviceInfo::mac, profinet::device::DeviceInfo::name, and Scan().

+ Here is the call graph for this function: