Moxa Technologies UC-7408 User Manual

Moxa Technologies UC-7408 User Manual

Embedded computers
Hide thumbs Also See for UC-7408:
Table of Contents

Advertisement

Quick Links

UC-7408 User's Manual
Fourth Edition, June 2008
www.moxa.com/product
© 2008 Moxa Inc., all rights reserved.
Reproduction without permission is prohibited.

Advertisement

Table of Contents
loading
Need help?

Need help?

Do you have a question about the UC-7408 and is the answer not in the manual?

Questions and answers

Subscribe to Our Youtube Channel

Summary of Contents for Moxa Technologies UC-7408

  • Page 1 UC-7408 User’s Manual Fourth Edition, June 2008 www.moxa.com/product © 2008 Moxa Inc., all rights reserved. Reproduction without permission is prohibited.
  • Page 2: Copyright Notice

    UC-7408 User’s Manual The software described in this manual is furnished under a license agreement and may be used only in accordance with the terms of that agreement. Copyright Notice Copyright © 2008 Moxa Inc. All rights reserved. Reproduction without permission is prohibited.
  • Page 3: Table Of Contents

    Test Program—Developing Hello.c ..................2-13 Installing the Tool Chain (Linux)................2-13 Checking the Flash Memory Space ................2-13 Compiling Hello.c ....................2-14 Uploading “Hello” to UC-7408 and Running the Program........2-15 Developing Your First Application ..................2-15 Testing Environment ....................2-15...
  • Page 4 Upgrading the Firmware..................... 3-2 Loading Factory Defaults ................... 3-5 Backing Up the User File System................3-5 Deploying the User File System to Additional UC-7408 Units ......... 3-5 Enabling and Disabling Daemons.................... 3-6 Setting the Run-Level ......................3-8 Adjusting the System Time ...................... 3-9 Setting the Time Manually ..................
  • Page 5 Installing the Software....................6-2 Broadcast Search ......................6-4 Linux ucfinder.......................... 6-5 Appendix A System Commands..................A-1 busybox (V0.60.4): Linux normal command utility collection..........A-1 File manager......................A-1 Editor......................... A-1 Network........................A-1 Process........................A-2 Other.......................... A-2 Moxa special utilities....................A-2 Appendix B Windows Tool Chain Introduction............. B-1 Introduction..........................B-2 Installation Procedure ......................B-3 Using the BASH Shell ......................B-9...
  • Page 6: Chapter 1 Introduction

    The digital I/O feature of UC-7408 provides users with the convenience of connecting digital devices to a front-end embedded computer. UC-7408 can be used for on/off event handling by reading the state change of the digital input signal. Output signals from external digital devices can be imported into UC-7408’s digital input channels, and then UC-7408 can be programmed to take...
  • Page 7: Overview

    PCMCIA interface for wireless LAN communication, and CompactFlash for mass storage flash disk expansion. UC-7408 uses an Intel XScale IXP-422 266 Mhz RISC CPU. Unlike the X86 CPU, which uses a CISC design, the IXP-422’s RISC design architecture and modern semiconductor technology provide UC-7408 with a powerful computing engine and communication functions, but without generating a lot of heat.
  • Page 8: Product Hardware Specifications

    UC-7408 User’s Manual Introduction DIN-Rail or wall mounting installation Robust fanless design Product Hardware Specifications UC-7408-LX Intel Xscale IXP-422, 266 MHz 128 MB Flash 32 MB Auto-sensing 10/100 Mbps x 2 LAN Protection Built-in 1.5 KV magnetic isolation 8-ch digital input, 8-ch digital output, TTL (3.3V)
  • Page 9: Hardware Introduction

    UC-7408 User’s Manual Introduction Hardware Introduction Appearance and Dimensions Appearance UC-7408 Rear View 12-48 VDC Power Input 10/100 Mbps Ethernet x 2 DC 12-48V PCMCIA LAN1 LAN2 Console V+ V- USB 1.1 Client x 1, CF x 1 miniB Connector...
  • Page 10: Hardware Block Diagram

    UC-7408 User’s Manual Introduction Dimensions 197 mm [7.76"] Hardware Block Diagram The following block diagram shows the layout of UC-7408’s internal components. Ethernet PCMCIA & Console LAN2 LAN1 Power CompactFlash Client PCI to cardbus Bridge Power Xscale IXP-422 266 MHz...
  • Page 11: Led Indicators

    UC-7408 User’s Manual Introduction LED Indicators UC-7408 has 12 LED indicators on the top panel. Refer to the following table for information about each LED. LED Name Color Meaning Ready Green Power is ON, and system is ready (after booting up)
  • Page 12: Real Time Clock

    Wall or Cabinet The two metal brackets that come standard with UC-7408 are used to attach UC-7408 to a wall, or the inside of a cabinet. Use two screws per bracket first to attach the brackets to the bottom of the UC-7408 (Fig.
  • Page 13: Din-Rail Mounting

    DIN-Rail Mounting The aluminum DIN-Rail attachment plate is included in the package. If you need to reattach the DIN-Rail attachment plate to UC-7408, make sure the stiff metal spring is situated towards the top, as shown in the figures below.
  • Page 14: Connecting The Power

    Where necessary, it is strongly advised that you label wiring to all devices in the system. Connecting the Power Connect the 12-48 VDC power line with UC-7408’s terminal block. If the power is properly supplied, the Ready LED will illuminate with a solid green color after 30 to 60 seconds have passed.
  • Page 15: Connecting To The Network

    (P1 to P8). For normal data acquisition applications, you should connect to UC-7408’s serial ports (P1 to P8) via a V90 or GPRS modem. If you would like to use the console port for normal data acquisition applications, you can set the Console port to startup via PPP protocol.
  • Page 16: Compactflash

    UC-7408’s Flash ROM is partitioned into Boot Loader, Linux Kernel, Mini Root File System, and User Root File System partitions. In order to prevent user applications from crashing the Root File System, UC-7408 uses a specially designed Mini File System with Protected Configuration for emergency use. This Mini File System comes with serial and Ethernet communication capability for users to load the Factory Default Image file.
  • Page 17: Journaling Flash File System (Jffs2)

    Linux Kernel & Root Boot Loader To improve system reliability, UC-7408 has a built-in mechanism that prevents the system from crashing. The procedure is as follows. When the Linux kernel boots up, the kernel will mount the root file system, and then enable services and daemons.
  • Page 18: Software Package

    UC-7408 User’s Manual Introduction Although JFFS2 is a journaling file system, this does not preclude the loss of data. The file system will remain in a consistent state across power failures and will always be mountable. However, if the board is powered down during a write then the incomplete write will be rolled back on the next boot, but writes that have already been completed will not be affected.
  • Page 19: Chapter 2 Getting Started

    Getting Started Chapter 2 In this chapter, we explain how to connect UC-7408, turn on the power, and then get started using the programming and other functions. The following topics are covered in this chapter: Powering on UC-7408 Connecting UC-7408 to a PC...
  • Page 20: Powering On Uc-7408

    Connect the SG wire to the Shielded Contact located in the upper left corner of the UC-7408, and then power on UC-7408 by connecting it to the power adaptor. It takes about 30 to 60 seconds for the system to boot up. Once the system is ready, the Ready LED will light up, and the Network address settings will appear on the LCM display.
  • Page 21: Telnet Console

    PC’s IP address and netmask so that your PC is on the same subnet as one of UC-7408’s two LAN ports. For example, if you connect to LAN 1, you can set your PC’s IP address to 192.168.3.126 and netmask to 255.255.255.0. If you connect to LAN 2, you can set your PC’s IP address to 192.168.4.126 and netmask to 255.255.255.0.
  • Page 22: Ssh Console

    When connecting to UC-7408 over a LAN, you must configure your PC’s Ethernet IP address to be on the same subnet as the UC-7408 you wish to contact. If you do not get connected on the first try, re-check the serial and IP settings, and then unplug and re-plug UC-7408’s power cord.
  • Page 23: Configuring The Ethernet Interface

    UC-7408 User’s Manual Getting Started Linux Users From a Linux machine, use the “ssh” command to access UC-7408’s Console utility via SSH. #ssh 192.168.3.127 Select yes to complete the connection. [root@bee_notebook root]# ssh 192.168.3.127 The authenticity of host ‘192.168.3.127 (192.168.3.127)’ can’t be established.
  • Page 24 Getting Started Dynamic IP addresses: By default, UC-7408 is configured for “static” IP addresses. To configure one or both LAN ports to request an IP address dynamically, replace static with dhcp and then delete the address, network, netmask, and broadcast lines.
  • Page 25: Modifying Network Settings Over The Network

    UC-7408 User’s Manual Getting Started NOTE After changing the IP settings, use the networking restart command to activate the new IP address. Modifying Network Settings over the Network IP settings can be activated over the network, but the new settings will not be saved to the flash ROM without modifying the file /etc/network/interfaces.
  • Page 26 UC-7408 User’s Manual Getting Started 3. Configure the Wireless LAN card’s default SSID setting profile. (Default SSID is “any”) #vi /etc/wlan/wlan.conf // Consult your network administrator for SSID required in your wireless network. For example, SSID_waln0=”any”, Enable_wlan0=y// 4. Duplicate the configuration profile to a new profile.
  • Page 27: Ieee802.11G

    UC-7408 User’s Manual Getting Started IEEE802.11g The following IEEE802.11g wireless modules are supported: ASUS—WL-107g CNET—CWC-854 (181D version) Edmiax—EW-7108PCg Amigo—AWP-914W GigaByte—GN-WMGK Other brands that use the Ralink RT2560 series chip set To configure the WLAN for IEEE802.11g: 1. Unplug the CardBus Wireless LAN card first.
  • Page 28 UC-7408 User’s Manual Getting Started Additional WLAN parameters are contained in the file RT2500STA.dat. To open the file, navigate to the RT2500STA folder and invoke vi, or type the following command #vi /etc/Wireless/RT2500STA/RT2500STA.dat to edit the file with vi editor. Setting options for the various parameters are listed below the figure.
  • Page 29 UC-7408 User’s Manual Getting Started NetworkType—Sets the wireless operation mode Setting Explanation Infra Infrastructure mode (uses access points to transmit data) Adhoc Adhoc mode (transmits data from host to host) Channel—Sets the channel Setting Explanation auto 1 to 14 the channel you want to use AuthMode—Sets the authentication mode...
  • Page 30 UC-7408 User’s Manual Getting Started TurboRate—Enables or disables TurboRate Setting Explanation disable enable BGProtection—Sets 11b/11g protection (this function is for engineering testing only) Setting Explanation auto always on always off ShortSlot—Enables or disables the short slot time Setting Explanation disable enable TxRate—Sets the TxRate...
  • Page 31: Test Program-Developing Hello.c

    Chain requires about 100 MB of hard disk space on your PC. The UC-7408 Tool Chain software is located on the UC-7408 CD. To install the Tool Chain, insert the CD into your PC and then issue the following commands: #mount /dev/cdrom /mnt/cdrom #rpm –ivh /mnt/cdrom/mxscaleb-3.3.2-6.i386.rpm...
  • Page 32: Compiling Hello.c

    If there isn’t enough “Available” space for your application, you will need to delete some existing files. To do this, connect your PC to the UC-7408 with the console cable, and then use the console utility to delete the files from UC-7408’s flash memory.
  • Page 33: Uploading "Hello" To Uc-7408 And Running The Program

    UC-7408’s serial and Ethernet ports. As illustrated in the following figure, the purpose of this application is to transfer data between PC 1 and the UC-7408 via an RS-232 connection. At the remote site, data can be transferred between UC-7408’s Ethernet port and PC 2 over an Ethernet connection.
  • Page 34: Compiling Tcps2.C

    -rw-r—-r-- 1 root root 6164 Nov 27 11:55 tcpsp.c [root@server11 1st_application]# Two executable files, tcps2-release and tcps2-debug, are created. tcps2-release—an IXP platform execution file (created specifically to run on UC-7408) tcps2-debug—an IXP platform GDB debug server execution file (see Chapter 5 for details about the GDB debug tool).
  • Page 35: Uploading Tcps2-Release And Running The Program

    UC-7408 User’s Manual Getting Started Uploading tcps2-release and Running the Program Use the following commands to use FTP to upload tcps2-release to the UC-7408. 1. From the PC, type: #ftp 192.168.3.127 2. Next, use the bin command to set the transfer mode to Binary, and the put command to initiate the file transfer: ftp>...
  • Page 36 UC-7408 User’s Manual Getting Started 4. The program should start running in the background. Use either the #jobs or #ps –ef command to check if the tcps2 program is actually running in the background. #jobs // use this command to check if the program is running 192.168.3.127 –...
  • Page 37: Testing Procedure Summary

    2. Upload and run tcps2-release in the background (#./tcps2-release &). 3. Check that the process is running (#jobs or #ps -ef). 4. Use a serial cable to connect PC1 to UC-7408’s serial port 1. 5. Use an Ethernet cable to connect PC2 to UC-7408.
  • Page 38: Managing Embedded Linux

    System Version Information System Image Backup Upgrading the Firmware Loading Factory Defaults Backing Up the User File System Deploying the User File System to Additional UC-7408 Units Enabling and Disabling Daemons Setting the Run-Level Adjusting the System Time Setting the Time Manually...
  • Page 39: System Version Information

    Moxa’s website (www.moxa.com). The name of the file has the form uc7408-x.x.x.frm, with “x.x.x” indicating the firmware version. To upgrade the firmware, download the firmware file to a PC, and then transfer the file to the UC-7408 unit via a serial Console or Telnet Console connection.
  • Page 40 27.5M 0% /mnt/ramdisk root@Moxa:~# cd /mnt/ramdisk root@Moxa:/mnt/ramdisk# The following instructions give the steps required to save the firmware file to UC-7408’s RAM disk, and then upgrade the firmware. 1. Type the following commands to enable the RAM disk: #upramdisk #cd /mnt/ramdisk 2.
  • Page 41 UC-7408 User’s Manual Managing Embedded Linux local: UC7420-1.5.frm remote: UC7420-1.5.frm 200 Port command successful. 150 Opening data connection for UC7420-1.5.frm 226 Transfer complete. 13167772 bytes received in 2.17 secs (5925.8 kB/s) ftp> 3. Next, use the upfirm command to upgrade the kernel and root file system: #upfirm uc7408-x.x.x.frm...
  • Page 42: Loading Factory Defaults

    Deploying the User File System to Additional UC-7408 Units For some applications, you may need to ghost one UC-7408 user file system to other UC-7408 units. Back up the user file system to a PC (refer to the previous subsection, “Backing Up the User File System,”...
  • Page 43: Enabling And Disabling Daemons

    Upgrade the firmware is OK. Please press any key to reboot system. Enabling and Disabling Daemons The following daemons are enabled when UC-7408 boots up for the first time. snmpd ..SNMP Agent daemon telnetd ..Telnet Server / Client daemon inetd .....Internet Daemons ftpd....FTP Server / Client daemon...
  • Page 44 UC-7408 User’s Manual Managing Embedded Linux 192.168.3.127 – PuTTY root@Moxa:~# cd /etc root@Moxa:/etc# ps -ef VmSize Stat Command root 1296 S init root [keventd] root [ksoftirqd_CPU0] root [kswapd] root [bdflush] root [kupdated] root [mtdblockd] root [khubd] root [jffs2_gcd_mtd3] root [ixp425_csr]...
  • Page 45: Setting The Run-Level

    UC-7408 User’s Manual Managing Embedded Linux 192.168.3.127 – PuTTY root@Moxa:~# ps -ef VmSize Stat Command root 1296 S init root [keventd] root [ksoftirqd_CPU0] root [kswapd] root [bdflush] root [kupdated] root [mtdblockd] root [khubd] root [jffs2_gcd_mtd3] root [ixp425_csr] root [ixp425 ixp0]...
  • Page 46: Adjusting The System Time

    Adjusting the System Time Setting the Time Manually UC-7408 has two time settings. One is the system time, and the other is the RTC (Real Time Clock) time kept by the UC-7408 hardware. Use the #date command to query the current system time or set a new system time.
  • Page 47: Ntp Client

    Thu Dec 9 10:01:08 2004 -0.933547 seconds root@Moxa:~# NTP Client UC-7408 has a built-in NTP (Network Time Protocol) client that is used to initialize a time request to a remote NTP server. Use #ntpdate <this client utility> to update the system time. #ntpdate time.stdtime.gov.tw #hwclock –w...
  • Page 48: Cron-Daemon To Execute Scheduled Commands

    UC-7408 User’s Manual Managing Embedded Linux How to run the shell script automatically when the kernel boots up Copy the example shell script fixtime to directory /etc/init.d, and then use chmod 755 fixtime to change the shell script mode. Next, use vi editor to edit the file /etc/inittab.
  • Page 49: Connecting Peripherals

    The UC-7408 supports PNP and hot pluggability for connecting a CF mass storage device. UC-7408 has a built-in auto mount utility that eases the mount procedure. The CF mass storage device will be mounted automatically by the mount command to /mnt/hda. UC-7408 will be un-mounted automatically by umount when you disconnect it.
  • Page 50: Chapter 4 Managing Communications

    Managing Communications Chapter 4 In this chapter, we explain how to configure UC-7408’s various communication functions. The following topics are covered in this chapter: Telnet / FTP Web Service—Apache Saving a Web Page to the CF Card IPTABLES NAT Example Enabling NAT at Bootup Dial-up Service—PPP...
  • Page 51: Telnet / Ftp

    Disable the daemon by typing ‘#’ in front of the first character of the row to comment out the line. UC-7408 supports DNS client (but not DNS server). To set up DNS client, you need to edit three configuration files: /etc/hosts, /etc/resolv.conf, and /etc/nsswitch.conf.
  • Page 52: Web Service-Apache

    UC-7408 User’s Manual Managing Communication Web Service—Apache The Apache web server’s main configuration file is /etc/apache/httpd.conf, with the default homepage located at /usr/www/html/index.html. Save your own homepage to the following directory: /usr/www/html/ Save your CGI page to the following directory:...
  • Page 53 UC-7408 User’s Manual Managing Communication To open the default CGI test script report page, type http://192.168.3.127/cgi-bin/test-cgi in your browser’s address box. NOTE The CGI function is enabled by default. If you want to disable the function, modify the file /etc/apache/httpd.conf. When you develop your own CGI application, make sure your CGI file is executable.
  • Page 54: Saving A Web Page To The Cf Card

    Prepare web page and put pages to CF card. Click on the following link to download the web page test suite: http://www.w3.org/MarkUp/Test/HTML401.zip. Uncompress the zip file to your desktop PC, and then use FTP to transfer it to UC-7408’s /mnt/hda directory. 192.168.3.127 – PuTTY root@Moxa:/mnt/hda# ls –al...
  • Page 55: Iptables

    UC-7408 User’s Manual Managing Communication Step4: Open your browser and connect to the UC-7408 by typing the current LAN1 IP address in the browser’s address box. NOTE Visit the Apache website at http://httpd.apache.org/docs/ for more information about setting up an Apache server.
  • Page 56 UC-7408 User’s Manual Managing Communication other computers that connect to this host can connect to the Internet when it the computer does not have an actual IP address. REDIRECT—a special form of DNAT that re-sends packets to a local host independent of the destination IP address.
  • Page 57 #lsmod #modprobe ip_tables #modprobe iptable_filter Use lsmod to check if the ip_tables module has already been loaded in the UC-7408. Use modprobe to insert and enable the module. Use the following command to load the modules (iptable_filter, iptable_mangle, iptable_nat): #modprobe iptable_filter Use iptables, iptables-restore, iptables-save to maintain the database.
  • Page 58 For packets coming into the UC-7408. OUTPUT: For locally-generated packets. FORWARD: For packets routed out through the UC-7408. PREROUTING: To alter packets as soon as they come in. POSTROUTING: To alter packets as they are about to be sent out.
  • Page 59: Nat

    IP addresses used on another network. One network is designated the inside network and the other is the outside network. Typically, UC-7408 connects several devices on a network and maps local inside network addresses to one or more global outside IP addresses, and un-maps the global IP addresses on incoming packets back into local IP addresses.
  • Page 60: Enabling Nat At Bootup

    Modem / PPP access is almost identical to connecting directly to a network through UC-7408’s Ethernet port. Since PPP is a peer-to-peer system, UC-7408 can also use PPP to link two networks (or a local network to the Internet) to create a Wide Area Network (WAN).
  • Page 61 UC-7408 User’s Manual Managing Communication The pppd daemon is used to connect to a PPP server from a Linux system. For detailed information about pppd see the man page. Example 1: Connecting to a PPP server over a simple dial-up connection The following command is used to connect to a PPP server by modem.
  • Page 62 UC-7408 User’s Manual Managing Communication defaultroute Once the PPP link is established, make it the default route; if you have a PPP link to the Internet, this is probably what you want. 192.1.1.17 This is a degenerate case of a general option of the form x.x.x.x:y.y.y.y. Here x.x.x.x is the local IP address and y.y.y.y is the IP address of the remote end of the PPP connection.
  • Page 63: Pppoe

    V1.5 or earlier versions. Copy the files from the web or CD-ROM, and directly update it by the copy command or FTP. 2. Connect UC-7408’s LAN port to an ADSL modem with a cross-over cable, HUB, or switch. 3. Login to the UC-7408 as the root user.
  • Page 64 UC-7408 User’s Manual Managing Communication “username@hinet.net” is the username obtained from the ISP to log in to the ISP account. “password” is the corresponding password for the account. 5. Edit the file /etc/ppp/pap-secrets and add the following: “username@hinet.net” * “password” * “username@hinet.net”...
  • Page 65 UC-7408 User’s Manual Managing Communication 6. Edit the file /etc/ppp/options and add the following line: plugin pppoe 7. Add one of two files: /etc/ppp/options.ixp0 or /etc/ppp/options.ixp1. The choice depends on which LAN is connected to the ADSL modem. If you use LAN1 to connect to the ADSL modem, then add /etc/ppp/options.ixp0.
  • Page 66: Nfs (Network File System)

    NFS allows users to develop applications for UC-7408, without worrying about the amount of disk space that will be available. UC-7408 supports NFS protocol for both client and server.
  • Page 67 Example 1 /tmp *(rw,no_root_squash) In this example, UC-7408 shares the /tmp directory to everyone, gives everyone both read and write authority. The root user on the client machine will have the same level of access to files on the system as the root on the server.
  • Page 68: Setting Up Uc-7408 As An Nfs Client

    You will need to add your hostname to the file /etc/hosts. SNMP UC-7408 has built-in SNMP V1 (Simple Network Management Protocol) agent software. It supports RFC1317 RS-232 like group and RFC 1213 MIB-II. The following simple example allows you to use an SNMP browser on the host site to query the UC-7408, which is the SNMP agent.
  • Page 69: Open Vpn

    UC-7408 does NOT support SNMP trap. The following tables list the variables supported by UC-7408. Open VPN This function is only available for firmware version V1.5 (and later versions). OpenVPN provides two types of tunnels for users to implement VPNS: Routed IP Tunnels and Bridged Ethernet Tunnels.
  • Page 70 UC-7408 User’s Manual Managing Communication Setup 1: Ethernet Bridging for Private Networks on Different Subnets 1. Set up four machines, as shown in the following diagram. local net OpenVPN A Host A eth1: 192.168.2.173 eth0: 192.168.2.171 eth0: 192.168.8.173 ixp0: 192.168.8.174 eth0: 192.168.4.172...
  • Page 71 UC-7408 User’s Manual Managing Communication if [ $i -gt 5 ]; then break i=`expr $i + 1` read f1 f2 case “$f1” in address ) IPADDR=$f2 netmask ) NETMASK=$f2 broadcast ) BROADCAST=$f2 esac done break done < /etc/network/interfaces # get the ip address of the specified interface...
  • Page 72 UC-7408 User’s Manual Managing Communication openvpn --mktun --dev tap${i} # connect tap device to the bridge brctl addif br0 tap${i} # null ip address of tap device ifconfig tap${i} 0.0.0.0 promisc up i=`expr $i + 1` if [ $i -ge $maxtap ]; then...
  • Page 73 UC-7408 User’s Manual Managing Communication # ln -s /etc/openvpn/openvpn-bridge /etc/rc.d/rc3.d/S32vpn-br # for example # ln -s /etc/openvpn/openvpn-bridge /etc/rc.d/rc6.d/K32vpn-br # for example 4. Create a configuration file named A-tap0-br.conf and an executable script file named A-tap0-br.sh on OpenVPN A. # point to the peer remote 192.168.8.174...
  • Page 74 UC-7408 User’s Manual Managing Communication networks connected to interface ixp1 that come to this bridge write to the TAP/TUN device that the OpenVPN program monitors. Once the OpenVPN program detects traffic on the virtual device, it sends the traffic to its peer.
  • Page 75 UC-7408 User’s Manual Managing Communication Setup 3: Routed IP 1. Set up four machines as shown in the following diagram: local net OpenVPN A Host A eth1: 192.168.2.173 eth0: 192.168.2.171 eth0: 192.168.8.173 ixp0: 192.168.8.174 eth0: 192.168.4.172 ixp1: 192.168.4.174 OpenVPN B...
  • Page 76 UC-7408 User’s Manual Managing Communication Note that the parameter “ifconfig” defines the first argument as the local internal interface and the second argument as the internal interface at the remote peer. Note that $5 is the argument that the OpenVPN program passes to the script file. Its value is the second argument of ifconfig in the configuration file.
  • Page 77: Chapter 5 Programmer's Guide

    Programmer’s Guide Chapter 5 This chapter includes important information for programmers. The following functions are covered in this chapter: Flash Memory Map Linux Tool Chain Introduction Debugging with GDB Device API RTC (Real Time Clock) Buzzer WDT (Watch Dog Timer) UART Digital I/O Make File Example...
  • Page 78: Flash Memory Map

    Redhat 7.3/8.0/9.0, Fefora core 1 & 2. The Tool Chain will need about 100 MB of hard disk space on your PC. The UC-7408 Tool Chain is located on the UC-7408 CD. To install the Tool Chain, insert the CD into your PC and then...
  • Page 79: Obtaining Help

    In the case of x86 environments, the prefix is i386-linux- and in the case of UC-7408 Xscale boards, it is mxscaleb-. For example the native C compiler is gcc and the cross C compiler for Xscale in UC-7408 is mxscaleb-gcc.
  • Page 80 UC-7408 User’s Manual Programmer’s Guide Uninstalling the Linux Tool Chain Use the command rpm –qa|grep mxscaleb to query if the Moxa tool chain is installed on the system. Use the command rpm -e mxscale-x.x.x-x to uninstall the Moxa Xscale tool chain.
  • Page 81: Debugging With Gdb

    6. Click the cont button Device API UC-7408 supports control devices with the ioctl system API. You will need to include <moxadevice.h>, and use the following ioctl function. int ioctl(int d, int request,…); Input: int d - open device node return file handle int request –...
  • Page 82: Buzzer

    UC-7408 User’s Manual Programmer’s Guide Buzzer The device node is located at /dev/console. UC-7408 supports Linux standard buzzer control, with UC-7408’s buzzer running at a fixed frequency of 100 Hz. You must include <sys/kd.h>. 1. Function: KDMKTONE ioctl(fd, KDMKTONE, unsigned int arg);...
  • Page 83 UC-7408 User’s Manual Programmer’s Guide int swtd_enable(int fd, unsigned long time) Description Enable application sWatchDog. And you must do ack after this process. Input int fd - the file handle, from the swtd_open() return value. unsigned long time - The time you wish to ack sWatchDog periodically. You must ack the sWatchDog before timeout.
  • Page 84 UC-7408 User’s Manual Programmer’s Guide int swtd_ack(int fd) Description: Acknowledge sWatchDog. When the user application enable sWatchDog. It need to call this function periodically with user predefined time in the application program. Input : int fd - the file handle from swtd_open() return value.
  • Page 85 UC-7408 User’s Manual Programmer’s Guide …. swtd_close(fd); exit(0); The makefile is shown below: all: mxscaleb-gcc –o xxxx xxxx.c –lmoxalib Example 2: #include <stdio.h> #include <stdlib.h> #include <signal.h> #include <string.h> #include <sys/stat.h> #include <sys/ioctl.h> #include <sys/select.h> #include <sys/time.h> #include <moxadevice.h> static void mydelay(unsigned long msec) struct timeval time;...
  • Page 86: Uart

    The normal tty device node is located at /dev/ttyM0 … ttyM7, and the modem tty device node is located at /dev/cum0 … cum7. UC-7408 supports Linux standard termios control. The Moxa UART Device API allows you to configure ttyM0 to ttyM7 as RS-232, RS-422, 4-wire RS-485, or 2-wire RS-485. UC-7408 supports RS-232, RS-422, 2-wire RS-485, and 4-wire RS485.
  • Page 87: Digital I/O

    UC-7408 User’s Manual Programmer’s Guide Example to get the baud rate #include <moxadevice.h> #include <termios.h> struct termios term; fd, speed; fd = open(“/dev/ttyM0”, O_RDWR); tcgetattr(fd, &term); if ( (term.c_cflag & (CBAUD|CBAUDEX)) != B4000000 ) { // follow the standard termios baud rate define } else { ioctl(fd, MOXA_GET_SPECIAL_BAUD_RATE, &speed);...
  • Page 88 UC-7408 User’s Manual Programmer’s Guide int set_dout_state(int doport, int state) Description: To set the DOUT port to high or low state. Input: - which DOUT port you want to set. Port starts from 0 to 7. int doport int state - to set high or low state;...
  • Page 89: Special Note

    UC-7408 User’s Manual Programmer’s Guide duration. The value of “duration” must be a multiple of 20 milliseconds. The range of “duration” is 0, or 40 <= duration <= 3600000 milliseconds. The error of the measurement is 24 ms. For example, if the DIN duration is...
  • Page 90 UC-7408 User’s Manual Programmer’s Guide #define MIN_DURATION 40 static char *DataString[2]={"Low ", "High "}; static void hightolowevent(int diport) printf("\nDIN port %d high to low.\n", diport); static void lowtohighevent(int diport) printf("\nDIN port %d low to high.\n", diport); int main(int argc, char * argv[]) int i, j, state, retval;...
  • Page 91 UC-7408 User’s Manual Programmer’s Guide scanf("%d", &i); retval=set_dout_state(i, 0); } else if ( i == 7 ) { // quit break; } else if ( i == 8 ) { // show event and duration printf("Event:\n"); for ( j=0; j<MAX_DOUT_PORT; j++ ) { retval=get_din_event(j, &i, &duration);...
  • Page 92 UC-7408 User’s Manual Programmer’s Guide #else #define dbg_printf(x...) #endif #define DURATION_NUM 7 #define TEST_NUM 10 static int ndin_StateChangeDetected, ndout_StateChangeDetected; static int nDuration; static unsigned long duration[2][DURATION_NUM]={ { 50, 40, 35, 30, 25, 20, 15 }, { 160, 140, 120, 100, 80, 60, 40, } };...
  • Page 93 UC-7408 User’s Manual Programmer’s Guide ndin_StateChangeDetected = 0; // reset these counters ndout_StateChangeDetected = 0; printf("DI duration,:0, DO duration:%d\n",duration[0][nDuration]); set_din_event(0, low2highevent, DIN_EVENT_LOW_TO_HIGH, 0); while( ndin_StateChangeDetected < TEST_NUM ) { pause(); printf("ndin_StateChangeDetected:%d, ndout_StateChangeDetected:%d,\n", ndin_StateChangeDetected, ndout_StateChangeDetected); printf("loss detection probability:%f\%,\n",(ndout_StateChangeDetected-ndin_StateChangeDetected)*100.0/nd out_StateChangeDetected); }//end of if( nChoice ==0 ) else if( nChoice == 1 ) { //test for din duration!=0 for ( nDuration=0;...
  • Page 94: Make File Example

    $(CC) -DDEBUG -o $(FNAME1)-dbg $(FNAME1).cxx -lmoxalib -lpthread clean: /bin/rm -f $(FNAME) $(FNAME)-dbg $(FNAME1) $(FNAME1)-dbg *.o Make File Example The following Makefile file example codes are copied from the Hello example on UC-7408’s CD-ROM. CC = /usr/local/mxscaleb/mxscaleb-gcc CPP = /usr/local/mxscaleb/mxscaleb-gcc SOURCES = hello.c OBJS = $(SOURCES:.c=.o)
  • Page 95: Chapter 6 Uc Finder

    UC Finder comes in handy if you forget the IP address, for troubleshooting field problems, and for testing. UC Finder works by sending a broadcast message over the LAN to search for UC-7408 MAC addresses. It will then query the UC-7408’s for their IP addresses. Two versions of UC Finder are provided.
  • Page 96: Windows Uc Finder

    UC-7408 User’s Manual UC Finder Windows UC Finder The UC Finder utility is used to search the LAN or intranet for Moxa Universal Communicators. Installing the Software 1. Once the Setup program starts running, click on Next to proceed. 2. Click on Next when the Select Additional Tools window opens to proceed with the...
  • Page 97 UC-7408 User’s Manual UC Finder 3. Click on Next to install program files in the default directory, or select an alternative location. 4. Click on Finish to complete the installation of UC Finder.
  • Page 98: Broadcast Search

    UC Finder Broadcast Search The Broadcast Search function is used to locate all UC-7408 units that are connected to the same LAN as your Windows computer. Since the Broadcast Search function searches by MAC address and not IP address, all UC-7408s connected to the LAN will be found, regardless of whether or not they are on the same subnet as the host.
  • Page 99: Linux Ucfinder

    Linux ucfinder Copy ucfinder from the Documentation and Software CD to your Linux PC, and then use the following command to start the program. UC Finder will automatically locate all UC-7408 units on the LAN, and then report their IP addresses.
  • Page 100: Appendix A System Commands

    System Commands Appendix A busybox (V0.60.4): Linux normal command utility collection File manager 1. cp copy file 2. ls list file 3. ln make symbolic link file 4. mount mount and check file system 5. rm delete file 6. chmod change file owner &...
  • Page 101: Process

    UC-7408 User’s Manual System Commands Process 1. kill kill process 2. ps display now running process Other 1. dmesg dump kernel log message 2. sty to set serial port 3. zcat dump .gz file context 4. mknod make device node 5.
  • Page 102: Appendix B Windows Tool Chain Introduction

    Windows Tool Chain Introduction Appendix B UC-7408’s Windows Tool Chain is a cross development environment that simulates the Linux root file system, allowing users to develop applications on a Windows PC. The following topics are covered in this appendix. Introduction...
  • Page 103: Introduction

    Windows Tool Chain Introduction Introduction UC-7408’s Windows Tool Chain is a cross development environment that simulates the Linux root file system, allowing users to develop applications in a Windows environment. Install the Windows tool chain to set up a Linux-like environment on your Windows machine. The following figure shows an example of what the Windows Tool Chain environment looks like.
  • Page 104: Installation Procedure

    UC-7408 User’s Manual Windows Tool Chain Introduction Installation Procedure 1. Insert the CD into your PC’s CD-ROM drive, and run \\tool-chain\windows\compiler\setup.exe to start installation. Once the Setup program starts running, click on Next to proceed. 2. Select the Root Directory.
  • Page 105 UC-7408 User’s Manual Windows Tool Chain Introduction 3. By default, the Local Package Directory is the same as on the CD-ROM: \\tool-chain\windows\compiler. Click on Next to proceed. Note: It may take anywhere from 5 to 20 minutes to check the packages in the CD-ROM after you click on Next.
  • Page 106 UC-7408 User’s Manual Windows Tool Chain Introduction Category column: Shows a hierarchical display of packages with category name highest and package name lowest. Click the plus sign (+)next to category name to open the category and see the packages within that category.
  • Page 107 UC-7408 User’s Manual Windows Tool Chain Introduction 6. Checkmark Create icon on Desktop to place a Moxa BASH Shell icon on your desktop, and then click on Finish. 7. Click on OK to close the Installation Complete window.
  • Page 108 UC-7408 User’s Manual Windows Tool Chain Introduction Uninstalling the Windows Tool Chain 1. Insert the Moxa CD into the CD-ROM drive and enter the \tool-chain\Windows\compiler directory. Next, double click on the setup.exe program and select the Root Install Directory. 2. Select the local package directory.
  • Page 109 UC-7408 User’s Manual Windows Tool Chain Introduction 3. Double click on the Default item and change it to the Uninstall item.
  • Page 110: Using The Bash Shell

    UC-7408 User’s Manual Windows Tool Chain Introduction 4. The tool chain will begin to unstall. 5. The Uninstalls complete window will appear when the uninstallation process is complete. Using the BASH Shell A command-line interface is used to develop applications with the tool chain. To access the command line, you need to launch a BASH shell window.
  • Page 111: Compilation

    UC-7408 User’s Manual Windows Tool Chain Introduction -rwxr—xr-x 1 stephen_ mkpasswd 53 Jan 10 22:03 moxa.bat -rw-r--r-- 1 stephen_ mkpasswd 3262 Jan 10 22:03 moxa.ico drwxr—xr-x 2 stephen_ mkpasswd 0 Jan 10 19:48 tmp drwxr—xr-x 14 stephen_ mkpasswd 0 Jan 10 19:48 usr drwxr—xr-x 6 stephen_ mkpasswd...
  • Page 112 UC-7408 User’s Manual Windows Tool Chain Introduction Next, enter the hello directory and invoke the make program that will execute the compilation instructions written in the Makefile to compile the hello project. /hello drwxrwx--- 7 Jared_Wu 4294967295 0 Nov 4 11:10 etc...
  • Page 113: Gdb Debug Tool-Insight

    UC-7408 User’s Manual Windows Tool Chain Introduction GDB debug tool—Insight Insight is a graphical user interface that accompanies GDB, the GNU Debugger written in Tcl/Tk by people working at Red Hat, Inc., and Cygnus Solutions. Red Hat was generous enough to make Insight available for public use, and continues to maintain the program.

Table of Contents