|
| 1 | +## netX programming examples |
| 2 | + |
| 3 | +Made for [netPI RTE 3](https://www.netiot.com/netpi/), the Open Edge Connectivity Ecosystem with Real-Time Ethernet |
| 4 | + |
| 5 | +### netX sample applications for PROFINET, EtherNet/IP and EtherCAT |
| 6 | + |
| 7 | +Base of this image builds a tagged version of [debian:jessie](https://hub.docker.com/r/resin/armv7hf-debian/tags/) with enabled [SSH](https://en.wikipedia.org/wiki/Secure_Shell) and created user 'pi'. |
| 8 | + |
| 9 | +Additionally the image provides netX programming examples in source code (and as precompiled executables) for |
| 10 | + |
| 11 | +* PROFINET IO device |
| 12 | +* EtherNet/IP adapter |
| 13 | +* EtherCAT slave |
| 14 | + |
| 15 | +#### Container prerequisites |
| 16 | + |
| 17 | +##### Port mapping |
| 18 | + |
| 19 | +For enabling remote login to the container across SSH the container's SSH port 22 needs to be exposed to the host. |
| 20 | + |
| 21 | +##### Host device |
| 22 | + |
| 23 | +To grant access to the netX from inside the container the `/dev/spidev0.0` host device needs to be added to the container. |
| 24 | + |
| 25 | +#### Getting started |
| 26 | + |
| 27 | +STEP 1. Open netPI's landing page under `https://<netpi's ip address>`. |
| 28 | + |
| 29 | +STEP 2. Click the Docker tile to open the [Portainer.io](http://portainer.io/) Docker management user interface. |
| 30 | + |
| 31 | +STEP 3. Enter the following parameters under **Containers > Add Container** |
| 32 | + |
| 33 | +* **Image**: `hilschernetpi/netpi-netx-programming-examples` |
| 34 | + |
| 35 | +* **Port mapping**: `Host "22" (any unused one) -> Container "22"` |
| 36 | + |
| 37 | +* **Restart policy"** : `always` |
| 38 | + |
| 39 | +* **Runtime > Devices > add device**: `Host "/dev/spidev0.0" -> Container "/dev/spidev0.0"` |
| 40 | + |
| 41 | +STEP 4. Press the button **Actions > Start container** |
| 42 | + |
| 43 | +Pulling the image from Docker Hub may take up to 5 minutes. |
| 44 | + |
| 45 | +#### Accessing |
| 46 | + |
| 47 | +The container starts the SSH service automatically. |
| 48 | + |
| 49 | +Login to it with an SSH client such as [putty](http://www.putty.org/) using netPI's IP address at your mapped port. Use the credentials `pi` as user and `raspberry` as password when asked and you are logged in as non-root user `pi`. |
| 50 | + |
| 51 | +##### Files and folders |
| 52 | + |
| 53 | +The login directs you to the pi user home directory /home/pi with following structure |
| 54 | + |
| 55 | +``` |
| 56 | +/home/pi/ |
| 57 | + | |
| 58 | + +--/devicedescriptions - device description files such as EDS, GSDML, ESI needed for master engineering |
| 59 | + +--/driver - netX driver installation package |
| 60 | + +--/firmwares - netX firmware installation packages |
| 61 | + +--/includes - protocol specific include files for compilation |
| 62 | + +--/manuals - common cifX API manual and protocol specific API manuals |
| 63 | + +--/objs - folder where the object files of the compilation process are stored to |
| 64 | + +--/sources - protocol specific source codes of the demos |
| 65 | + | Makefile - Makefile to compile all example applications using 'make' command |
| 66 | + | PNS_simpleConfig - precompiled and executable PROFINET IO device example |
| 67 | + | EIS_simpleConfig - precompiled and executable EtherNet/IP adapter example |
| 68 | + | ECS_simpleConfig - precompiled and executable EtherCAT slave example |
| 69 | +``` |
| 70 | +##### netX driver installation |
| 71 | + |
| 72 | +To install the netX SPI driver package move to the `driver` folder and call |
| 73 | + |
| 74 | +`dpkg -i netx-docker-pi-drv-1.1.3.deb` |
| 75 | + |
| 76 | +The driver will be installed into the folder `/opt/cifx`. |
| 77 | + |
| 78 | +The cifX API function library needed for linking will be installed into folder `/usr/lib`. |
| 79 | + |
| 80 | +Basic include files needed for the compilation process will be installed into folder `/usr/include`. |
| 81 | + |
| 82 | +##### netX firmware installation |
| 83 | + |
| 84 | +To install a firmware package move to the folder `firmwares` and call |
| 85 | + |
| 86 | +* `dpkg -i netpi-docker-pi-pns-3.12.0.2.deb` for PROFINET IO device firmware or |
| 87 | +* `dpkg -i netpi-docker-pi-eis-2.12.5.0.deb` for EtherNet/IP adapter firmware or |
| 88 | +* `dpkg -i netpi-docker-pi-ecs-4.7.0.2.deb` for EtherCAT slave firmware |
| 89 | + |
| 90 | +Any firmware package extracts its firmware into the folder `/opt/cifx/deviceconfig/FW/channel0`. |
| 91 | + |
| 92 | +The firmware will be loaded by the driver into netX the first time the driver is accessed with `cifXDriverInit()` command. |
| 93 | + |
| 94 | +There can be only one installed firmware package at a time. An existing package will be automatically uninstalled during installation. |
| 95 | + |
| 96 | +##### Compiling the programming examples |
| 97 | + |
| 98 | +To compile the programming examples simply call `make` in the pi home directory. The command will locate the `Makefile` which initiates the compilation process. |
| 99 | + |
| 100 | +The following executables will be compiled |
| 101 | + |
| 102 | +* `PNS_simpleConfig` as PROFINET IO device demo |
| 103 | +* `EIS_simpleConfig` as EtherNet/IP adapter demo |
| 104 | +* `ECS_simpleConfig` as EtherCAT slave demo |
| 105 | + |
| 106 | +You may be faced with the following warning during compilation process |
| 107 | + |
| 108 | +`make: warning: Clock skew detected. Your build may be incomplete.` |
| 109 | + |
| 110 | +There is a discrepancy between netPI's system clock and the time the executeables/object files have been generated. Call `make clean` and remove the executeable. Then start the compilation process again. Make also sure you have set netPI's system clock correctly. |
| 111 | + |
| 112 | +##### Starting the executables |
| 113 | + |
| 114 | +To start the compiled examples call the following executeables in the pi home directory |
| 115 | + |
| 116 | +* `sudo ./PNS_simpleConfig` for the PROFINET IO device example |
| 117 | +* `sudo ./EIS_simpleConfig` for the EtherNet/IP adapter example |
| 118 | +* `sudo ./ECS_simpleConfig` for the EtherCAT slave example |
| 119 | + |
| 120 | +The examples check if the corresponding firmware package has been installed properly, if not they install it automatically. |
| 121 | + |
| 122 | +##### Linking the cifX library to applications |
| 123 | + |
| 124 | +To link the cifX driver library to own applications just add the option `-lcifx` to your GCC compilation command. |
| 125 | + |
| 126 | +##### The cifX API reference (netX driver API) |
| 127 | + |
| 128 | +The cifX driver function API is described in the manual |
| 129 | + |
| 130 | +`cifX_API_PR_04_EN.pdf` |
| 131 | + |
| 132 | +located in the `manuals` folder. |
| 133 | + |
| 134 | +##### The protocol specific APIs (PROFINET, EtherNet/IP ... APIs) |
| 135 | + |
| 136 | +A netX firmware has a common part that is behaving the same for all firmwares and a protocol dependent specific part. Particularly the configuration varies from protocol to protocol and shows different characteristics. |
| 137 | + |
| 138 | +The protocol specific dependencies are described in these manuals |
| 139 | + |
| 140 | +* `PROFINET_IO-Device_V3.12_Protocol_API_17_EN.pdf` for PROFINET IO device |
| 141 | +* `EtherNetIP_Adapter_Protocol_API_19_EN.pdf` for EtherNet/IP adapter |
| 142 | +* `EtherCAT Slave V4 Protocol API 09 EN.pdf` for EtherCAT slave |
| 143 | + |
| 144 | +located in the `manuals` folder. |
| 145 | + |
| 146 | +#### Tags |
| 147 | + |
| 148 | +* **hilscher/netPI-net-programming-examples:latest** - non-versioned latest development output of the master branch. Can run on any netPI RTE 3 system software version. |
| 149 | + |
| 150 | +#### GitHub sources |
| 151 | + |
| 152 | +The image is built from the GitHub project [netPI-netx-programming-examples](https://github.com/Hilscher/netPI-netx-programming-examples). It complies with the [Dockerfile](https://docs.docker.com/engine/reference/builder/) method to build a Docker image [automated](https://docs.docker.com/docker-hub/builds/). |
| 153 | + |
| 154 | +To build the container for an ARM CPU on [Docker Hub](https://hub.docker.com/)(x86 based) the Dockerfile uses the method described here [resin.io](https://resin.io/blog/building-arm-containers-on-any-x86-machine-even-dockerhub/). |
| 155 | + |
| 156 | +[](http://www.hilscher.com) Hilscher Gesellschaft fuer Systemautomation mbH www.hilscher.com |
0 commit comments