Prerequisites: -------------- For working with the ANSI C or C++ based OPC UA SDK on a RaspberryPi device you need the following prerequisites: Hardware: * RaspberryPi Model B - Raspbian “wheezy” (2013-02-09) * PiFace Digital IO Module * Development PC for cross-compiling - In this README we assume that you are using Ubuntu Linux. Any other Linux also works, but you might need to adapt the install commands. 1) Initial configuration of the RaspberryPi ------------------------------------------- By default the RaspberryPi is configured for DHCP. You will need a DHCP/DNS network infrastructure for that to work. Most home routers and company networks support this. In this case the RaspberryPi device can simply be reached by its hostname "raspberrypi" via SSH. If you don't have a DHCP/DNS infrastructure you can either install one using packages like "dnsmasq" (See https://help.ubuntu.com/community/Dnsmasq) or you can configure your RaspberryPi to use a static IP. (Optional) Configure a static IP: --------------------------------- 1.) Connect keyboard and monitor to your RaspberryPi. 2.) Edit the file /etc/network/interfaces to set a hard coded IP address: pi@raspberrypi ~ $ sudoedit /etc/network/interfaces #iface eth0 inet dhcp iface eth0 inet static address 192.168.5.13 network 192.168.5.0 netmask 255.255.255.0 broadcast 192.168.5.255 gateway 192.168.5.1 pi@raspberrypi ~ $ sudo reboot When using a static IP you need to replace the hostname "raspberrypi" with your configured IP in the next steps. The remaining document assumes that you are working with DHCP. a) Connecting the first time via SSH ------------------------------------ Default hostname: raspberrypi Default username: pi Default password: raspberry PC ~ $ ssh -l pi raspberrypi When connecting the first time, you will see a prompt about that the device is not fully configured. Run raspi-config for this initial configuration. It is recommended to execute: pi@raspberrypi ~ $ sudo raspi-config - expand_rootfs - change_pass (to a better password) - finish & reboot (for expand_rootfs to finish) b) Installing your SSH public key --------------------------------- To avoid further password prompts when connecting via SSH you can install you SSH public key on your device. 1.) Generate SSH keypair (only if you don't have one already!) PC ~ $ ssh-keygen 2.) Install you public key on the RaspberryPi PC ~ $ ssh-copy-id pi@raspberrypi 3.) Test if ssh works without password prompt now PC ~ $ ssh -l pi raspberrypi (Now you should see the Pi shell without getting asked for a password) pi@raspberrypi ~ $ exit 2) Enabled IPv6 support ----------------------- The UA SDK is compiled with IPv6 support. By default the RaspberryPi does not load the ipv6 kernel module. This will cause an error when starting the uaserver without the optional "-n " parameter. To enable IPv6 support you need to load this module. # temporary load ipv6 module pi@raspberrypi ~ $ sudo modprobe ipv6 # to load this module automatically at startup you need to add a new line "ipv6" to /etc/modules. pi@raspberrypi ~ $ sudoedit /etc/modules With enabled IPv6 support the uaserver will listen on all IPv4 and IPv6 addresses (0.0.0.0 and ::) by default. 3) Configuration of the PiFace addon board ------------------------------------------ a) The PiFace board uses SPI for communication with the RaspberryPi, but SPI is disabled by default, so you will have to enable it by commenting out the SPI kernel module in the blacklist by prepending a #: pi@raspberrypi ~ $ sudoedit /etc/modprobe.d/raspi-blacklist.conf #blacklist spi-bcm2708 b) For allowing the user 'pi' to access the SPI device, run the script 'spidev-setup' that is delivered with the SDK on your RaspberryPi: PC ~/work $ scp spidev-setup pi@raspberrypi: PC ~/work $ ssh -l pi raspberrypi pi@raspberrypi ~ $ chmod +x ./spidev-setup pi@raspberrypi ~ $ sudo ./spidev-setup pi@raspberrypi ~ $ sudo reboot 4) Copy files to the target system ---------------------------------- To copy the application to the target system you will need to transfer some files to the target. The following steps assume that you sftp to copy all files. The RaspberryPi is by default configured to use DHCP. The default user is pi, the password is raspberry. a) Connect to the target RaspberryPi via ssh and create the following folders: PC ~ $ ssh -l pi raspberrypi pi@raspberrypi ~ $ mkdir -p ua/{bin,lib} pi@raspberrypi ~ $ exit b) Now transfer the application, its passwd and group file and the uastack into the created folders using another shell: PC ~ $ cd ~/work/sdk/bin PC ~/work/sdk/bin $ scp sdk/bin/* pi@raspberrypi:ua/bin PC ~/work/sdk/bin $ scp sdk/lib/*.so pi@raspberrypi:ua/lib c) After that you can run the application: PC ~ $ ssh -l pi raspberrypi pi@raspberrypi ~ $ cd ua/bin pi@raspberrypi ~ $ ./uaserverc_piface # starting the release version pi@raspberrypi ~ $ ./uaserverc_pifaced # starting the debug version Press "y" the accept the license agreement. Now the application will start up. The first startup of the server will take some time, because the server generates a PKI folder hierarchy and its own certificates. You can stop the server again by pressing CTRL-C (SIGINT) or sending a SIGTERM signal. The server will wait 3s before actually shutting down to give clients a chance to proper cleanup their resources. Call "./uaserverc_piface -h" to get a list of available commandline options. 5) Connect to the UA Server on the target ----------------------------------------- Use your OPC UA Client (e.g. UaExpert can be downloaded at www.unifiedautomation.com) and connect to the UA Server on the target. Browse the address space and drag and drop the nodes you want to monitor into the DAView.