Moxa ioPAC 8600 User Manual

ioPAC 8600 CPU30 C Version Software
User’s Manual
Version 1.2, February 2021
www.moxa.com/product
© 2021 Moxa Inc. All rights reserved.
ioPAC 8600 CPU30 C Version Software
Moxa Americas
Toll
Te
Fax: +1-714-528-6778
Moxa China (Shanghai office)
Toll
Tel:
Fax: +86-21-5258-5505
Moxa Europe
Tel:
Fax:
Moxa Asia
Tel:
Fax
Moxa India
Tel:
Fax: +91-80-4132-1045
User’s Manual
The software described in this manual is furnished under a license agreement and may be used only in accordance
Copyright Notice
© 2021 Moxa Inc. All rights reserved.
Trademarks
The MOXA logo is a registered trademark of Moxa Inc.
All other trademarks or registered marks in this manual belong to their respective manufacturers.
Disclaimer
Information in this document is subject to change without notice and does not represent a commitment on the part of
Moxa.
Moxa provides this document as is, without warranty of any kind, either expressed or implied, including, but not
limited to, its particular purpose. Moxa reserves the right to make improvements and/or changes to this manual, or to
the products and/or the programs described in this manual, at any time.
Information provided in this manual is intended to be accurate and reliable. However, Moxa assumes no responsibility
for its use, or for any infringements on the rights of third parties that may result from its use.
This product might include unintentional technical or typographical errors. Changes are periodically made to the
information herein to correct such errors, and these changes are incorporated into new editions of the publication.
Technical Support Contact Information
www.moxa.com/support
-free: 1-888-669-2872
l: +1-714-528-6777
-free: 800-820-5036
+86-21-5258-9955
+49-89-3 70 03 99-0
+49-89-3 70 03 99-99
+91-80-4172-9088
+886-2-8919-1230
: +886-2-8919-1231
-Pacific
Table of Contents
1. Introduction ...................................................................................................................................... 1-1
Overview ........................................................................................................................................... 1-2
Scope ........................................................................................................................................ 1-2
Related Documents ..................................................................................................................... 1-2
Supported Products ..................................................................................................................... 1-2
Software Architecture .......................................................................................................................... 1-2
Software Package ........................................................................................................................ 1-4
2. Getting Started.................................................................................................................................. 2-1
Developing the First Program ............................................................................................................... 2-2
Hardware Requirements ............................................................................................................... 2-2
Development Procedure ............................................................................................................... 2-2
Configuring the Ethernet Interface ........................................................................................................ 2-2
Modifying Network Settings with the Serial Console ......................................................................... 2-2
Modifying Network Settings over the Network ................................................................................. 2-3
Connecting an ioPAC Controller to a Linux PC ......................................................................................... 2-3
Installing the Toolchain on the PC ......................................................................................................... 2-4
Configuring Cross Compiler and glibc Environment Variables .................................................................... 2-4
Developing Code and Compiling a Program ............................................................................................ 2-4
Upload and Run the Program ................................................................................................................ 2-5
Systemctl Command ........................................................................................................................... 2-6
3. Controller Management ..................................................................................................................... 3-1
System Information ............................................................................................................................ 3-2
Firmware Upgrade and Default Settings ................................................................................................. 3-2
Upgrading the Firmware ............................................................................................................... 3-2
Upgrading the Firmware from the SD Card ..................................................................................... 3-4
Loading Factory Defaults .............................................................................................................. 3-4
Enabling and Disabling Daemons .......................................................................................................... 3-5
System Time Setting ........................................................................................................................... 3-5
Setting the Time Manually ............................................................................................................ 3-5
Using NTP Client to update the Time .............................................................................................. 3-5
Configuring the NTP Server .......................................................................................................... 3-6
Executing Scheduled Commands with Cron Daemon ............................................................................... 3-6
File System ........................................................................................................................................ 3-7
Web Server ........................................................................................................................................ 3-8
LOG ................................................................................................................................................ 3-10
4. Controller Communications ............................................................................................................... 4-1
Internet Configuration ......................................................................................................................... 4-2
Modbus TCP Master and Slave....................................................................................................... 4-2
DNS........................................................................................................................................... 4-2
FTP ............................................................................................................................................ 4-2
Telnet ........................................................................................................................................ 4-3
SSH ........................................................................................................................................... 4-3
Iptables ..................................................................................................................................... 4-3
NAT (SNAT) ................................................................................................................................ 4-4
Port Forwarding (DNAT) ............................................................................................................... 4-5
PPPoE ........................................................................................................................................ 4-5
NFS (Network File System) Client .................................................................................................. 4-6
Sending Mail ............................................................................................................................... 4-7
OpenVPN .................................................................................................................................... 4-7
IPSec VPN ................................................................................................................................ 4-10
NTP Server/Client ...................................................................................................................... 4-11
Port Trunking ............................................................................................................................ 4-11
DDNS ...................................................................................................................................... 4-12
opkg ........................................................................................................................................ 4-12
5. Controller Data Acquisition ............................................................................................................... 5-1
I/O Data Access.................................................................................................................................. 5-2
Data Backup Memory .......................................................................................................................... 5-2
Millisecond Timestamp ........................................................................................................................ 5-2
MX-AOPC UA Server ............................................................................................................................ 5-2
6. Controller Programming .................................................................................................................... 6-1
Programming Guide ............................................................................................................................ 6-2
Memory Usage ............................................................................................................................ 6-2
Using C/C++ ...................................................................................................................................... 6-2
Linux Toolchain ........................................................................................................................... 6-2
GDB .......................................................................................................................................... 6-3
Library and APIs .......................................................................................................................... 6-4
A. System Commands ............................................................................................................................ A-1
Special Moxa Utilities .......................................................................................................................... A-1
1

1. Introduction

The following topics are covered in this chapter:
Overview
Scope
Related Documents
Supported Products
Software Architecture
Software Package
ioPAC 8600 CPU30 C Version Introduction
1-2

Overview

In this section, we describe the scope of this document, and list relevant reference documents, and
supported products.
Scope
The purpose of this document is to help users set up and configure the ioPAC controller and quickly become
familiar with the programming environment. The following topics are covered in this document:
Introduction
Getting Started
Controller Management
Controller Communications
Controller Data Acquisition
Controller Programming
The following information is provided in the Appendix:
System Commands
Related Documents
Additional information about ioPAC controller features is available in the following manuals, which can be
downloaded from Moxa’s website:
ioPAC 8600 Hardware User’s Manual
C/C++ Sample Code Programming Guide for ioPAC Programmable Controllers
Supported Products
In this document, we cover the following products:
ioPAC 8600-CPU30 Series

Software Architecture

The ioPAC CPU30 Programmable Controller uses an ARM Cortex™ A8-based industrial-grade CPU for the
system and ARM Cortex™ M4-based CPUs for the modules. It provides up to 4 GB eMMC, 512 MB SDRAM,
and a microSD socket (up to 32 GB) for users to install application software and to store data directly on the
controller.
The pre-installed operating system (OS) provides an open platform for software program development,
which follows a standard Linux-based architecture. Software that runs on desktop PCs can be easily
exported to the controller with a cross compiler. Program porting can be done with the toolchain provided
by Moxa.
The built-in flash ROM is partitioned into the following directory partitions: Boot Loader, Kernel, Root File
System, and User. In order to prevent user applications from crashing the Root File System, the controller
uses a unique Root File System with Protected Configuration for emergency use. This Root File System
comes with serial and Ethernet communication capability for users to load the Factory Default Image file.
User settings and applications are saved in the User directory.
ioPAC 8600 CPU30 C Version Introduction
1-3
The ioPAC CPU30 uses OverlayFS as the file system when Linux 4.0 is implemented. For more information
about OverlayFS, check the following links:
https://github.com/torvalds/linux/commit/e9be9d5e76e34872f0c37d72e25bc27fe9e2c54c
https://docs.docker.com/engine/userguide/storagedriver/overlayfs-driver/
For more information about the memory map and programming, refer to the Programming Guide section
in Chapter 6.
ioPAC 8600 CPU30 C Version Introduction
1-4
System
File System
Ext3, Ext2, Ext4, vfat, msdos, nfs, ntfs, overlay
Busybox
Linux normal command utility collection
ddns
NO-IP client program
PPPoE
Point-to-Point over Ethernet daemon
ntpd
NTP server daemon
Linux Toolchain
Software Package
Boot loader ioPAC 8600-CPU30 Boot Loader (v1.0)
Kernel Linux 4.1.15 with Real-time patch (PREEMPT_RT)
Protocol Stack ARP, PPP, CHAP, PAP, IPv4, ICMP, TCP, UDP, DHCP, FTP, HTTP, NTP, NFS, SMTP,
SSH 1.0/2.0, SSL, Telnet, PPPoE, OpenVPN, TFTP
OS Shell command Bash
Utilities
telnet Telnet client program
ssh SSH client program
ftp FTP client program
smtpclient Email utility
ntpdate NTP client program
tftp TFTP client program
Daemons
pppd Dial in/out over serial port daemon
telnetd Telnet server daemon
inetd TCP server manager program
ftpd FTP server daemon
sshd Secure shell server
openvpn Virtual private network
openssl Open SSL
HTTP server Monkey HTTP server
systemd-journald system log daemon
gcc(v5.1.1) C/C++ PC Cross Compiler
gdb(v7.10.0) Source Level Debug Server
glibc(v2.21) POSIX standard C library
2

2. Getting Started

This chapter is intended as a quick start guide to help new users set up and configure the ioPAC
Programmable Controller quickly, and develop a simple program to run on the ioPAC Programmable
Controller.
The following topics are covered in this chapter:
Developing the First Program
Hardware Requirements
Development Procedure
Configuring the Ethernet Interface
Modifying Network Settings with the Serial Console
Modifying Network Settings over the Network
Connecting an ioPAC Controller to a Linux PC
Installing the Toolchain on the PC
Configuring Cross Compiler and glibc Environment Variables
Developing Code and Compiling a Program
Upload and Run the Program
Systemctl Command
ioPAC 8600 CPU30 C Version Getting Started
2-2
[moxa@ioPAC8600 ~]$ sudo nmcli c down eth0
/org/freedesktop/NetworkManager/ActiveConnection/1)

Developing the First Program

In this section, we list the hardware you will need to create your first program, and give an overview of the
program development procedure.
Hardware Requirements
The following hardware items are required to complete the first program:
 1 x ioPAC Programmable Controller
1 x 24-110 VDC power supply
1 x Ethernet cable
1 x PC or laptop with following minimum requirements
CPU: Intel Pentium 4 or above
RAM: 512 MB (1024 MB recommended)
HDD: at least 200 MB of free space
Network Interface: 10/100M Ethernet
Linux Operating System (we recommend Ubuntu 14.04)
Development Procedure
Take the following steps to develop your first program:
Step 1: Connect a Controller to a Linux PC
Step 2: Install the Toolchain onto the PC
Step 3: Configure Cross Compiler and glibc Environment Variables
Step 4: Develop the Code and Compile the Program
Step 5: Upload and Run the Program

Configuring the Ethernet Interface

The network settings of the ioPAC Programmable Controller can be modified with the ioPAC’s serial console
or web console.
Modifying Network Settings with the Serial Console
In this section, we show how to use the serial console to configure the network interface. The default IP
addresses and port numbers are 192.168.127.254/24 for interface port eth0 and 192.168.126.254/24 for
interface port eth1. We illustrate how to configure both static and dynamic IP addresses for interface port
eth0.
Static IP address:
1. Deactivate eth0.
Connection 'eth0' successfully deactivated (D-Bus active path:
2. Configure a static IP and gateway for eth0.
ioPAC 8600 CPU30 C Version Getting Started
2-3
[moxa@ioPAC8600 ~]$ sudo nmcli c modify eth0 ipv4.method manual ipv4.addresses
192.168.127.254/24 ipv4.gateway 192.168.127.1
[moxa@ioPAC8600 ~]$ sudo nmcli c up eth0
/org/freedesktop/NetworkManager/ActiveConnection/2)
[moxa@ioPAC8600 ~]# sudo nmcli c down eth0
/org/freedesktop/NetworkManager/ActiveConnection/1)
[moxa@ioPAC8600 ~]# sudo nmcli c modify eth0 ipv4.method auto
[moxa@ioPAC8600 ~]# sudo nmcli c up eth0
/org/freedesktop/NetworkManager/ActiveConnection/2)
[moxa@ioPAC8600 ~]# sudo nmcli c modify eth0 ipv4.method manual ipv4.addresses
192.168.127.254/24 ipv4.gateway 192.168.127.1
[moxa@ioPAC8600 ~]# sudo reboot
LAN2 (default IP: 192.168.126.254)
192.168.126.100
[root@localhost ~]# ssh moxa@192.168.127.254
3. Activate eth0.
Connection successfully activated (D-Bus active path:
Dynamic IP Address:
1. Deactivate eth0.
Connection 'eth0' successfully deactivated (D-Bus active path:
2. Configure eth0 to request an IP address dynamically.
3. Activate eth0.
Connection successfully activated (D-Bus active path:
Modifying Network Settings over the Network
In this section, we show how to use the web console to configure the network interface over an Ethernet
connection. The default IP addresses and port numbers are 192.168.127.254/24 for interface port eth0 and
192.168.126.254/24 for interface port eth1. We illustrate how to configure a static IP address for interface
port eth0.
Static IP address:
1. Configure a static IP and gateway for eth0.
2. Reboot the system.

Connecting an ioPAC Controller to a Linux PC

Take the following steps to establish a connection between the PC and the controller.
Step 1: Use an Ethernet cable to connect the PC’s Ethernet port to the ioPAC controller’s LAN1 or LAN2
port.
Step 2: Change the PC’s IP address as indicated below:
If the ioPAC controller is connected to: Set PC’s IP address to:
LAN1 (default IP: 192.168.127.254) 192.168.127.100
Step 3: Use the ssh command to access the ioPAC’s console.
Step 4: When a connection between the PC and controller has been established, the following message will
be shown on the screen.
ioPAC 8600 CPU30 C Version Getting Started
2-4
[root@localhost ~]$ ssh moxa@192.168.127.254
[moxa@ioPAC8600 ~]$
[root@localhost ~]$ mount /dev/cdrom /mnt/cdrom
/mnt/cdrom/Software/Toolchain/ioPAC_CPU30_toolchain_Vx.x.x.x_Buildxxxxxxxx.sh
[moxa@ioPAC8600 ~]# PATH=$PATH:/usr/local/arm-linux/bin:/usr/sbin
[moxa@ioPAC8600 ~]# export LD_LIBRARY_PATH
[moxa@ioPAC8600 ~]# cd /tmp/
root@moxa:/tmp# cp –r /mnt/cdrom/Software/Sample/hello_world/* /tmp/example
[moxa@ioPAC8600 ~]# cd/tmp/example/hello_world
root@moxa:/tmp/example/hello_world# make
root@moxa:/tmp/example/hello_world# make
lrtu_common
-ltag -Wl,-rpath,/lib/RTU/ -Wl,--allow-shlib-undefined
moxa@192.168.127.254's password:

Installing the Toolchain on the PC

The controller’s GNU toolchain requires approximately 2 GB of hard disk space on your PC. The controller’s
toolchain software is located on the Document and Software CD. To install the toolchain, insert the CD into
your PC’s CD-ROM and then issue the following commands:
[root@localhost ~]$ unzip /mnt/cdrom/Software/Toolchain/
ioPAC_CPU30_toolchain_Vx.x.x.x_Buildxxxxxxxx.zip .
[root@localhost ~]$ sh
The toolchain will be installed automatically on the host Linux PC within a few minutes.

Configuring Cross Compiler and glibc Environment Variables

Before compiling the program, issue the following commands to change the path to the directory that
contains the toolchain files (including the compiler, link, and library). Configuring the path allows you to run
the compiler from any directory.
[moxa@ioPAC8600 ~]# export PATH
[moxa@ioPAC8600 ~]# LD_LIBRARY_PATH=/usr/local/arm-linux/tools/lib:/usr/lib

Developing Code and Compiling a Program

Use the hello_world.c sample program and makefile from the Software and Document CD to learn how to
develop code and compile a program on the ioPAC controller.
Type the following commands from the host PC to copy the files used for this example.
root@moxa:/tmp# mkdir example
To compile the program, go to the hello_world subdirectory and issue the following commands:
The following response should be shown on the screen.
/usr/local/arm-linux/bin/arm-linux-gcc -I/usr/local/arm-linux/include -
I/usr/local/arm-linux/include/RTU -o hello_world hello_world.o -L/usr/local/arm-
linux/lib -lpthread -lmxml -L/usr/local/arm-linux/lib/RTU -lmoxa_rtu -
ioPAC 8600 CPU30 C Version Getting Started
2-5
NOTE
Since Moxa’s too
be sure to type the
any other directory, the host Linux PC
errors.
ATTENTION
You
can
221 Goodbye.
The hello_world-release and hello_world-debug executable files are described below:
• hello_world-release: an ARM platform executable file (created specifically to run on the Moxa
Controllers)
• hello_world-debug: an ARM platform GDB debug server executable file
must use the sudo command to run the programs that use Moxa library for the ioPAC 8600. Or, you
switch to the root account before you run programs that use Moxa library for the ioPAC 8600.
lchain places a specially designed makefile in the /tmp/example/hello_world directory,
#make command from within that directory. If you type the #make command from
might use other system compilers (e.g., cc or gcc), resulting in

Upload and Run the Program

In this section, we give step-by-step instructions that describe how to upload and run the hello_world.c
program. Before starting the process, set up the networking environment as follows:
• ioPAC 8600 IP: 192.168.127.254
• localhost IP: 192.168.127.1
• Make sure that the ioPAC 8600 and localhost can connect to each other over the network.
1. Start vftpd service on the ioPAC 8600.
[moxa@ioPAC8600 ~]$ sudo systemctl start vsftpd.service
2. Open the directory where the program will be saved on localhost.
[root@localhost ~]$ ls –hl
total 12
-rwxr-xr-x 1 root root 10.1K Jan 8 00:34 hello_world
3. Upload the program from localhost to the ioPAC8600.
[root@localhost ~]$ ftp 192.168.127.254
Connected to 192.168.127.254.
220 (vsFTPd 3.0.3)
Name (192.168.127.254:root): moxa
331 Please specify the password.
Password:
230 Login successful.
Remote system type is UNIX.
Using binary mode to transfer files.
ftp> put hello_world
200 PORT command successful. Consider using PASV.
150 Ok to send data.
226 Transfer complete.
10340 bytes sent in 5.5e-05 seconds (179 Mbytes/s)
ftp> quit
4. Open the directory where the program will be saved on the ioPAC8600.
[moxa@ioPAC8600 ~]$ ls -hl
total 12
-rw------- 1 moxa moxa 10.1K Jan 8 00:39 hello_world
ioPAC 8600 CPU30 C Version Getting Started
2-6
5. Change the program to an executable file.
[moxa@ioPAC8600 ~]$ chmod +x hello_world
6. Run the program.
[moxa@ioPAC8600 ~]$ ./hello_world
Hello World

Systemctl Command

The following commands can be used with the ioPAC 8600 CPU30 Series to execute some services without
doing any settings in advance. To control a service, type the respective command after
[moxa@ioPAC8600 ~].
• list installed unit files
# systemctl list-unit-files
• start the service
# systemctl start [unit.service]
• stop the service
# systemctl stop [unit.service]
• restart the service
# systemctl restart [unit.service]
• enable the service to start on bootup
# systemctl enable [unit.service]
• disable the service from starting on bootup
# systemctl disable [unit.service]
• show service status
# systemctl status [unit.service]
Loading...
+ 32 hidden pages