OpenProfinet¶
Installing¶
The latest releases can be obtained on the GitHub repository and installed as follows.
$ sudo apt install ./OpenProfinet-0.9.2-x86_64.deb
Building¶
OpenProfinet is built using CMake. Simply pull the repository, and run CMake in the standard way.
$ git clone https://github.com/naresh97/OpenProfinet.git && cd ./OpenProfinet
$ mkdir ./build && cd ./build
$ cmake ..
$ make
Pre-requisites¶
The following pre-requisites are required for building. Ubuntu/Debian packages are specified, but packages on other distributions should be installed in a similar way. Refer to your distribution’s package manager.
$ sudo apt install libpcap-dev
Documentation¶
ProfinetTool¶
The ProfinetTool class provides a library of tools required for
-
class ProfinetTool¶
ProfinetTool class contains the methods providing the core functionality of configuring a Profinet network
Public Functions
-
explicit ProfinetTool(int timeout = 5000)¶
Construct ProfinetTool class using the default interface
- Parameters
timeout – Timeout for searching for devices on network
-
ProfinetTool(const std::string &interface, int timeout)¶
Construct ProfinetTool class
- Parameters
interface – The interface to use to configure the Profinet netwoork
timeout – Timeout for searching for devices on network
-
std::vector<ProfinetDevice> searchForDevices(bool printFoundDevices = true)¶
Search for devices on the Profinet network
- Parameters
printFoundDevices – Print the devices found to stdout
- Returns
A vector of found devices as a vector of type ProfinetDevice
-
void configureDevices(const std::string &deviceName, const std::string &newName, const std::string &newIP, const std::string &newSubnet, const std::string &newGateway)¶
Configure a device on the Profinet network
Leave parameter blank ( empty string or std::string() ) if parameter should not be changed
WARNING: Might fail if Subnet/Gateway settings do not match IP (bad response from device)
- Parameters
deviceName – The station name of the device to configure
newName – The new station name of the device
newIP – The new IP address of the device
newSubnet – The new subnet mask of the device
newGateway – The new gateway IP address of the device
-
explicit ProfinetTool(int timeout = 5000)¶
ProfinetDevice¶
-
struct ProfinetDevice¶
ProfinetDevice models the parameters for a Profinet device
PCAP Interface¶
The PCAP Interface specified in pcapInterface.h provides the a C-based interface to the libpcap library. Here, we listen, build and send packets to a specified interface, as well as process incoming packets on the byte level.
Defines
-
PROFINET_DEVICE_LIST_SIZE¶
Defines buffer size for number of Profinet devices on the network
Functions
-
void get_default_interface(char *interface)¶
Gets the default network interface on the machine
- Parameters
interface – Pointer of char array to output interface
-
void discovery_request(const char interface[])¶
Create a multicast Profinet-DCP discovery request. Profinet devices on the network will respond to this request.
- Parameters
interface – Interface to broadcast request on
-
void profinet_listen(const char interface[], struct profinet_packet_array *profinetPacketArray, int timeout)¶
Listen for Profinet packets
- Parameters
interface – Interface to listen on
profinetPacketArray – Pointer to array of Profinet packets to output to
timeout – Listen timeout in seconds
-
void get_profinet_devices(struct profinet_packet_array *profinetPacketArray, struct profinet_device *profinetDevices, int *count)¶
Gets discovery responses from a provided array of Profinet packets
- Parameters
profinetPacketArray – Pointer to array of packets to search
profinetDevices – Pointer to array of Profinet devices to output to
count – Pointer to integer of number of Profinet devices found to output to
-
bool set_device_configuration(const char *interface, struct profinet_device *device)¶
Sends a request to a device, requesting it to configure itself to the given parameters
- Parameters
interface – Interface, over which to send configuration request
device – Pointer to the Profinet device to send request to
- Returns
Whether the device has acknowledged the configuration request
Licensing¶
The source code and binaries of this project use the GPLv3 license for non-commercial uses only!
If you would like to use any part of the OpenProfinet project for commercial purposes, you must obtain explicit permission from the author.