UC-7400-LX Plus User’s Manual Third Edition, September 2008 www.moxa.com/product © 2008 Moxa Inc., All rights reserved. Reproduction without permission is prohibited.
UC-7400-LX Plus 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. Trademarks MOXA is a registered trademark of Moxa Inc. All other trademarks or registered marks in this manual belong to their respective manufacturers.
Table of Contents Chapter 1 Introduction ..................................................................................................1-1 Overview.................................................................................................................................. 1-2 Software Architecture .............................................................................................................. 1-2 Journaling Flash File System (JFFS2) ...................................................
Chapter 4 Managing Communications ........................................................................4-1 Telnet / FTP ............................................................................................................................. 4-2 DNS ......................................................................................................................................... 4-2 Web Service—Apache .............................................................................................
1 Chapter 1 Introduction The Moxa UC-7400-LX Plus series of RISC-based commnication platforms are ideal for your embedded applications. All models come with 8 RS-232/422/485 serial ports, dual 10/100 Mbps Ethernet ports, a PCMCIA interface for wireless LAN communication, and CompactFlash and USB ports for mass storage for disk expansion.
UC-7400-LX Plus User’s Manual Introduction Overview The UC-7400-LX Plus series of RISC-based communication platforms are ideal for embedded applications. Features include 8 RS-232/422/485 serial ports, dual 10/100 Mbps Ethernet ports, a PCMCIA interface for wireless LAN communication, and CompactFlash and USB ports for mass storage disk expansion. The UC-7400-LX Plus uses an Intel XScale IXP-425 533 Mhz RISC CPU.
UC-7400-LX Plus User’s Manual Introduction The UC-7400-LX Plus’s built-in Flash ROM is partitioned into Boot Loader, Linux Kernel, Root File System, and User Root File System partitions. In order to prevent user applications from crashing the Root File System, the UC-7400-LX Plus uses a specially designed 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.
UC-7400-LX Plus User’s Manual Introduction Software Package Redboot (v1.92) Monta Vista embedded Linux 2.6.10 ARP, PPP, CHAP, PAP, IPv4, ICMP, TCP, UDP, DHCP, FTP, SNMP V1/V2, HTTP, NTP, NFS, SMTP, SSH 1.0/2.
2 Chapter 2 Getting Started In this chapter, we explain how to connect the UC-7400-LX Plus, turn on the power, and then get started using the programming and other functions.
UC-7400-LX Plus User’s Manual Getting Started Powering on the UC-7400-LX Plus Connect the SG wire to the Shielded Contact located in the upper left corner of the UC-7400-LX Plus, and then power on the computer 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 model name of the computer will appear on the LCM display.
UC-7400-LX Plus User’s Manual Getting Started Telnet Console If you know at least one of the two IP addresses and netmasks, then you can use Telnet to connect to the UC-7400-LX Plus’s console utility. The default IP address and Netmask for each port are given below: LAN 1 LAN 2 Default IP Address 192.168.3.127 192.168.4.127 Netmask 255.255.255.0 255.255.255.0 Use a cross-over Ethernet cable to connect directly from your PC to the UC-7400-LX Plus.
UC-7400-LX Plus User’s Manual Getting Started SSH Console UC-7400-LX Plus supports an SSH console to provide users with better security options. Windows Users Click on the link http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html to download PuTTY (free software) to set up an SSH console for the UC-7400-LX Plus in a Windows environment. The following figure shows a simple example of the configuration that is required.
UC-7400-LX Plus User’s Manual Getting Started Modifying Network Settings with the Serial Console In this section, we use the serial console to configure the network settings of the target computer. 1. Follow the instructions given in a previous section to access the Console Utility of the target computer via the serial Console port, and then type #cd /etc/network to change directories. root@Moxa:# cd /etc/network/ root@Moxa:/etc/network/# 2.
UC-7400-LX Plus User’s Manual NOTE Getting Started After changing the IP settings, use the networking restart command to activate the new IP address. However, the LCM display will still show the old IP address. To update the LCM display, you will need to reboot the UC-7400-LX Plus. 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.
UC-7400-LX Plus User’s Manual Getting Started 3. 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 command #vi /etc/Wireless/RT2500STA/RT2500STA.dat to edit the file with vi editor. Settings options for the various parameters are listed below the figure.
UC-7400-LX Plus User’s Manual Getting Started Channel—sets the channel Setting Explanation 0 auto 1 to 14 the channel you want to use AuthMode—sets the authentication mode Setting OPEN SHARED WPAPSK WPANONE EncrypType—Sets encryption type Setting NONE WEP TKIP AES DefaultKeyID—sets default key ID Setting 1 to 4 Key1Str, Key2Str, Key3Str, Key4Str—sets strings Key1 to Key4 Setting The keys can be input as 5 ascii characters, 10 hex numbers, 13 ascii characters, or 26 hex numbers TxBurst—WPA pre-shared key S
UC-7400-LX Plus User’s Manual Getting Started ShortSlot—enables or disables the short slot time Setting Explanation 0 disable 1 enable TxRate—sets the TxRate Setting Explanation 0 Auto 1 1 Mbps 2 2 Mbps 3 5.
UC-7400-LX Plus User’s Manual Getting Started Example 1: Configure wireless LAN to link to AP that is OPEN/NONE (Authentication/Encryption) [Default] CountryRegion=0 WirelessMode=0 SSID=DN_3Com NetworkType=Infra Channel=0 AuthMode=OPEN EncrypType=NONE DefaultKeyID=1 Key1Str=0123456789 Key2Str= Key3Str= Key4Str= WPAPSK=1111111111 TXBurst=0 TurboRate=0 BGProtection=0 ShortSlot=0 TxRate=0 RTSThreshold=2312 FragThreshold=2312 PSMode=CAM Example 2: Configure wireless LAN to link to AP that is SHARED/WEP (Auth
UC-7400-LX Plus User’s Manual Getting Started Example 3: Configure wireless LAN to link to AP that is WPAPSK/TKIP (Authentication/Encryption) [Default] CountryRegion=0 WirelessMode=0 SSID=DN_3Com NetworkType=Infra Channel=0 AuthMode=WPAPSK EncrypType=TKIP DefaultKeyID=1 Key1Str=0123456789 Key2Str= Key3Str= Key4Str= WPAPSK=1111111111 TXBurst=0 TurboRate=0 BGProtection=0 ShortSlot=0 TxRate=0 RTSThreshold=2312 FragThreshold=2312 PSMode=CAM Example 4: Configure wireless LAN to link to AP that is WPAPSK/AES (
UC-7400-LX Plus User’s Manual Getting Started Plug the 3G Card into the Cardbus Slot The UC-7400-LX Plus supports plug-and-play feature for the supported 3G datacards. When the 3G datacard is inserted, the UC-7400-LX Plus will detect the card automatically. You may use the command “dmesg” to see the kernel ring buffer message. The kernel ring buffer message will show the following message if the UC-7400-LX Plus detects the 3G card.
UC-7400-LX Plus User’s Manual Getting Started Connecting to the 3G Network You can connect to 3G networks over a ppp connection. #/etc/init.d/3g.sh nozomi start After the connection is established, you can type ifconfig to check the ppp0 interface. 192.168.3.127 – PuTTY root@Moxa:~# ifconfig ppp0 ppp0 Link encap:Point-to-Point Protocol inet addr: 221.120.39.32 P-t-P:10.64.64.64 Mask:255.255.255.
UC-7400-LX Plus User’s Manual Getting Started Installing the Tool Chain (Linux) The PC must have the Linux Operating System pre-installed before installing the UC-7400-LX Plus GNU Tool Chain. Fedora core, and compatible versions are recommended. The Tool Chain requires about 100 MB of hard disk space on your PC. The UC-7400-LX-Plus Tool Chain software is located on the UC-7400-LX Plus CD.
UC-7400-LX Plus User’s Manual Getting Started You should receive the following response: [root@localhost hello]# make xscale_be-gcc –o hello-release hello.c xscale_be-strip –s hello-release xscale_be-gcc –ggdb -o hello-debug hello.
UC-7400-LX Plus User’s Manual Getting Started PC 1 PC 2 RS-232 LAN tcps2.c Read serial data Write data to PC1 Serial Rx Buffer LAN Rx Buffer Send data to PC2 Receive LAN data Compiling tcps2.c The source code for the tcps2 example is located on the CD-ROM at CD-ROM://example/TCPServer2/tcps2.c. Use the following commands to copy the file to a specific directory on your PC. We use the direrctory /home/1st_application/. Note that you need to copy 3 files—Makefile, tcps2.c, tcpsp.
UC-7400-LX Plus User’s Manual Getting Started root@server11:/home/1st_application [root@server11 1st_application]# pwd /home/uc7400/1st_application [root@server11 1st_application]# 11 total 20 -rw-r—r-- 1 root root 514 Nov 27 11:52 Makefile -rw-r—r-- 1 root root 4554 Nov 27 11:52 tcps2.c -rw-r—r-- 1 root root 6164 Nov 27 11:55 tcps2.c [root@server11 1st_application]# make_ xscale_be-gcc -o tcps2-release tcps2.c xscale_be-strip –s tcps2-release xscale_be-gcc -o tcpsp-release tcpsp.
UC-7400-LX Plus User’s Manual Getting Started root@server11:/home/1st_application [root@server11 1st_application]# ftp 192.168.3.127 Connected to 192.168.3.127 220 Moxa FTP server (Version wu-2.6.1(2) Mon Nov 24 12:17:04 CST 2003) ready. 530 Please login with USER and PASS. 530 Please login with USER and PASS. KERBEROS_V4 rejected as an authentication type Name (192.168.3.127:root): root 331 Password required for root. Password: 230 User root logged in. Remote system type is UNIX.
UC-7400-LX Plus User’s Manual Getting Started 192.168.3.127 - PuTTY root@Moxa:~# ls –al drwxr—xr-x 2 root root 0 Jun 12 drwxr—xr-x 15 root root 0 Jan 1 -rw------- 1 root root 899 Jun 10 -rw-r--r-- 1 root root 4996 Jun 12 root@Moxa:~# chmod +x tcps2-release root@Moxa:~# ls –al drwxr—xr-x 2 root root 0 Jun 12 drwxr—xr-x 15 root root 0 Jan 1 -rw------- 1 root root 899 Jun 10 -rwxr-xr-x 1 root root 4996 Jun 12 root@Moxa:~# ./tcps2-release & [1] 187 start root@Moxa:~# jobs [1]+ Running .
UC-7400-LX Plus User’s Manual NOTE Getting Started Use the kill -9 command for PID 187 to terminate this program: #kill -9 187 Testing Procedure Summary 1. 2. 3. 4. 5. 6. 7. 8. 9. Compile tcps2.c (#make). Upload and run tcps2-release in the background (#./tcps2-release &). Check that the process is running (#jobs or #ps -ef). Use a serial cable to connect PC1 to the UC-7400-LX Plus serial port 1. Use an Ethernet cable to connect PC2 to the UC-7400-LX Plus.
3 Chapter 3 Managing Embedded Linux This chapter includes information about version control, deployment, updates, and peripherals. The information in this chapter will be particularly useful when you need to run the same application on several UC-7400-LX Plus units.
UC-7400-LX Plus User’s Manual Managing Embedded Linux System Version Information To determine the hardware capability of your UC-7400-LX Plus, and what kind of software functions are supported, check the version numbers of your UC-7400-LX Plus firmware version. Contact Moxa to determine the hardware version. You will need the Production S/N (Serial number), which is located on the UC-7400-LX Plus bottom label. To check the kernel version, type: #kversion 192.168.3.
UC-7400-LX Plus User’s Manual Managing Embedded Linux 192.168.3.127 - PuTTY root@Moxa:/# df –h Filesystem Size Used Available /dev/mtdblock2 14.0M 11.2M 2.8M /dev/ram15 1.7M 18.0k 1.6M /dev/ram0 499.0k 34.0k 440.0k /dev/mtdblock3 15.8M 2.6M 13.1M /dev/mtdblock3 15.8M 2.6M 13.1M /dev/mtdblock3 15.8M 2.6M 13.1M root@Moxa:/# upramdisk root@Moxa:/# df –h Filesystem Size Used Available /dev/mtdblock2 14.0M 11.2M 2.8M /dev/ram15 1.7M 18.0k 1.6M /dev/ram0 499.0k 34.0k 440.0k /dev/mtdblock3 15.8M 2.6M 13.
UC-7400-LX Plus User’s Manual Managing Embedded Linux 192.168.3.127 - PuTTY root@Moxa:/mnt/ramdisk# ftp 192.168.3.193 Connected to 192.168.3.193 (192.168.3.193). 220 TYPSoft FTP Server 1.10 ready… Name (192.168.3.193:root): root 331 Password required for root. Password: 230 User root logged in. Remote system type is UNIX. Using binary mode to transfer files. ftp> cd newsw 250 CWD command successful. “/C:/ftproot/newsw/” is current directory. ftp> bin 200 Type set to I. ftp> ls 200 Port command successful.
UC-7400-LX Plus User’s Manual Managing Embedded Linux Loading Factory Defaults To load the system’s factory default settings, press the reset-to-default button for at least 5 seconds. Doing so will destroy all of the files in the /home and /etc directories. While holding the button for the first 5 seconds, the ready LED will blink once each second. After holding the button continuously for more than 5 seconds, the ready LED will switch off, indicating that the factory defaults have been loaded.
UC-7400-LX Plus User’s Manual Managing Embedded Linux 192.168.3.127 - PuTTY root@Moxa:/mnt/ramdisk# ls –al drwxr-xr-x 3 root root 1024 Jan 2 22:27 . drwxr-xr-x 4 root root 0 Jun 17 2006 .. drwx-----2 root root 12288 Jan 2 22:17 lost+found -------r-1 root root 16515236 Jan 2 22:28 usrfs-backup root@Moxa:/mnt/ramdisk# upfirm usrfs-backup UC-7400 Upgrade firmware utility version 1.0. To check source firmware file context. The source firmware file conext is OK. This step will upgrade firmware.
UC-7400-LX Plus User’s Manual 698 nobody 701 root 714 root 726 root 727 root 783 root root@Moxa:/ect# 3012 352 1176 436 1180 628 Managing Embedded Linux S S S S S R /usr/bin/httpd –k start –d /etc/apache /bin/reportip -bash /bin/telnetd -bash ps -ef Type the following commands to see all the daemons that are set to run at bootup. #cd /etc/rc.d/rc3.d #1s 192.168.3.127 - PuTTY root@Moxa:/ect/rc.d/rc3.d#1s S19nfs-common S25nfs-user-server S20snmpd s55ssh S24pcmcia S99rmnologin root@Moxa:/etc/rc.d/rc3.
UC-7400-LX Plus User’s Manual Managing Embedded Linux KxxRUNFILE stands for: K: start the run file when linux shuts down or halts. xx: a number between 00-99. Smaller numbers have a higher priority. RUNFILE: the file name. To remove the daemon, remove the run file from the /etc/rc.d/rc3.d directory by using the following command: #rm –f /etc/rc.d/rc3.d/S60tcps2 Starting a Program Automatically at Run-Level To configure a program to run automatically at run-level, add the following lines to the file rc.
UC-7400-LX Plus User’s Manual 698 nobody 701 root 714 root 726 root 727 root 783 root root@Moxa:~# 3012 S 352 S 1176 S 436 S 1180 S 628 R Managing Embedded Linux /usr/bin/httpd -k start -d /etc/apache /bin/reportip -bash /bin/telnetd -bash ps -ef Adjusting the System Time Setting the Time Manually The UC-7400-LX Plus has two time settings. One is the system time, and the other is the RTC (Real-time Clock) time kept by the UC-7400-LX Plus hardware.
UC-7400-LX Plus User’s Manual Managing Embedded Linux NTP Client The UC-7400-LX Plus has a built-in NTP (Network Time Protocol) client that is used to initialize a time request to a remote NTP server. Use #ntpdate to update the system time. #ntpdate time.stdtime.gov.tw #hwclock –w Visit http://www.ntp.org for more information about NTP and NTP server addresses. 10.120.53.100 - PuTTY root@Moxa:~# date ; hwclock Sat Jan 1 00:00:36 CST 2000 Sat Jan 1 00:00:37 2000 -0.
UC-7400-LX Plus User’s Manual Managing Embedded Linux Crontab is located in the /etc/cron.d directory. Modify the file /etc/cron.d/crontab to set up your scheduled applications. Crontab has the following format: mm min 0-59 h hour 0-23 dom date 1-31 mon month 1-12 dow week 0-6 (0 is Sunday) user user command command The following example demonstrates how to use Cron. How to use cron to update the system time and RTC time every day at 8:00. STEP1: Write a shell script named fixtime.
UC-7400-LX Plus User’s Manual Managing Embedded Linux Connecting Peripherals USB Mass Storage The UC-7420-LX Plus supports PNP (plug-n-play), and hot pluggability for connecting USB mass storage devices. The UC-7420-LX Plus has a built-in auto mount utility that eases the mounting procedure. The first USB mass storage device to be connected will be mounted automatically by mount to /mnt/sda, and the second device will be mounted automatically to /mnt/sdb.
UC-7400-LX Plus User’s Manual Managing Embedded Linux ATTENTION Remember to type the #sync command before you unplug the CF mass storage device. If you don’t issue the command, you may lose some data. Remember to exit the /mnt/hda directory when you disconnect the CF mass storage device. If you stay in /mnt/hda, the auto un-mount process will fail. If that happens, type #umount /mnt/hda to un-mount the CF device manually. The UC-7400-LX Plus only supports certain types of CF mass storage device.
4 Chapter 4 Managing Communications In this chapter, we explain how to configure the UC-7400-LX Plus’s various communication functions.
UC-7400-LX Plus User’s Manual Managing Communications Telnet / FTP In addition to supporting Telnet client/server and FTP client/server, the UC-7400-LX Plus also supports SSH and sftp client/server. To enable or disable the Telnet/ftp server, you first need to edit the file /etc/inetd.conf. Enabling the Telnet/ftp server The following example shows the default content of the file /etc/inetd.conf.
UC-7400-LX Plus User’s Manual Managing Communications Web Service—Apache The Apache web server’s main configuration file is /etc/apache/conf/httpd.conf, with the default homepage located at /home/httpd/www/html/index.html.
UC-7400-LX Plus User’s Manual NOTE Managing Communications The CGI function is enabled by default. If you want to disable the function, modify the file /etc/apache/conf/httpd.conf. When you develop your own CGI application, make sure your CGI file is executable. 192.168.3.
UC-7400-LX Plus User’s Manual Managing Communications sub-tables Source NAT (SNAT)—changes the first source packet IP address Destination NAT (DNAT)—changes the first destination packet IP address MASQUERADE—a special form for SNAT. If one host can connect to internet, then other computers that connect to this host can connect to the Internet when it the computer does not have an actual IP address.
UC-7400-LX Plus User’s Manual Managing Communications The UC-7400-LX Plus supports the following sub-modules. Be sure to use the module that matches your application.
UC-7400-LX Plus User’s Manual Managing Communications Examples: # iptables -L -n In this example, since we do not use the -t parameter, the system uses the default ‘filter’ table. Three chains are included: INPUT, OUTPUT, and FORWARD. INPUT chains are accepted automatically, and all connections are accepted without being filtered.
UC-7400-LX Plus User’s Manual Managing Communications Example 4: Drop TCP packets from 192.168.1.25. # iptables –A INPUT –i eth0 –p tcp –s 192.168.1.25 –j DROP Example 5: Drop TCP packets addressed for port 21. # iptables –A INPUT –i eth0 –p tcp --dport 21 –j DROP Example 6: Accept TCP packets from 192.168.0.24 to UC-7400-LX Plus’s port 137, 138, 139 # iptables –A INPUT –i eth0 –p tcp –s 192.168.0.
UC-7400-LX Plus User’s Manual Managing Communications Enabling NAT at Bootup In most real world situations, you will want to use a simple shell script to enable NAT when the UC-7400-LX Plus boots up. The following script is an example. #!/bin/bash # If you put this shell script in the /home/nat.sh # Remember to chmod 744 /home/nat.sh # Edit the rc.local file to make this shell startup automatically. # vi /etc/rc.d/rc.local # Add a line in the end of rc.local /home/nat.
UC-7400-LX Plus User’s Manual Managing Communications 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. Use this command for old ppp servers that prompt for a login name (replace username with the correct name) and password (replace password with the correct password).
UC-7400-LX Plus User’s Manual Managing Communications modem Indicates that this is a modem device; pppd will hang up the phone before and after making the call. 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.
UC-7400-LX Plus User’s Manual Managing Communications 64 bytes from 129.67.1.165: icmp_seq=2 ttl=225 time=266 ms ^C --- 129.67.1.165 ping statistics --3 packets transmitted, 3 packets received, 0% packet loss round-trip min/avg/max = 247/260/268 ms waddington:~$ Try typing: netstat –nr This should show three routes, similar to the following: Kernel routing table Destination iface 129.67.1.165 ppp0 127.0.0.0 0.0.0.0 ppp0 Gateway 0.0.0.0 0.0.0.0 129.67.1.165 Genmask 255.255.255.255 255.0.0.0 0.0.0.
UC-7400-LX Plus User’s Manual 4. Managing Communications Edit the file /etc/ppp/pap-secrets and add the following: “username@hinet.net” * “password” * 192.168.3.127 - PuTTY support hostname stats hostname “*” “*” - # OUTBOUND connections # ATTENTION: The definitions here can allow users to login without a # package already provides this option; make sure you don’t change that.
UC-7400-LX Plus User’s Manual 7. Managing Communications Set up DNS If you are using DNS servers supplied by your ISP, edit the file /etc/resolv.conf by adding the following lines of code: nameserver ip_addr_of_first_dns_server nameserver ip_addr_of_second_dns_server For example: nameserver 168.95.1.1 nameserver 139.175.10.20 8. Use the following command to create a pppoe connection: pppd eth0 The eth0 is what is connected to the ADSL modem LAN port. The example above uses LAN1.
UC-7400-LX Plus User’s Manual Managing Communications ro Read only. This is the default. rw Readable and Writeable. no_root_squash If no_root_squash is selected, then the root on the client machine will have the same level of access to files on the system as the root on the server. This can have serious security implications, although it may be necessary if you want to do administrative work on the client machine that involves the exported directories.
UC-7400-LX Plus User’s Manual Managing Communications Step 1: #showmount –e showmount: -e: HOST: HOST Show the mount information for an NFS Server. Show the NFS Server’s export list. IP address or DNS address. Steps 2 & 3: #mkdir –p /home/nfs/public #mount –t nfs NFS_Server(IP):/directory /mount/point Example: #mount –t nfs 192.168.3.100/home/public /home/nfs/public Mail smtpclient is a minimal SMTP client that takes an email message body and passes it on to an SMTP server.
UC-7400-LX Plus User’s Manual Managing Communications 12: system.9.1.2.5 (object identifier) mib-2.50 13: system.9.1.2.6 (object identifier) internet.6.3.16.2.2.1 14: system.9.1.2.7 (object identifier) internet.6.3.10.3.1.1 15: system.9.1.2.8 (object identifier) internet.6.3.11.3.1.1 16: system.9.1.2.9 (object identifier) internet.6.3.15.2.1.1 17: system.9.1.3.1 (octet string) The MIB module to describe generic objects for network interface sub-layers 18: system.9.1.3.
UC-7400-LX Plus User’s Manual Managing Communications Setup 1: Ethernet Bridging for Private Networks on Different Subnets 1. Set up four machines, as shown in the following diagram. Host A local net OpenVPN A LAN1: 192.168.2.173 LAN1: 192.168.2.171 Internet LAN2: 192.168.8.173 LAN1: 192.168.8.174 LAN1: 192.168.4.172 LAN2: 192.168.4.174 Host B local net OpenVPN B Host A (B) represents one of the machines that belongs to OpenVPN A (B).
UC-7400-LX Plus User’s Manual Managing Communications ;; netmask ) NETMASK=$f2 ;; broadcast ) BROADCAST=$f2 ;; esac done break fi done < /etc/network/interfaces } # get the ip address of the specified interface mname= module_up() { oIFS=$IFS IFS=‘ ‘ FOUND=“no” for LINE in `lsmod` do TOK=`echo $LINE | cut -d’ ‘ -f1` if [ “$TOK” = “$mname” ]; then FOUND=“yes”; break; fi done IFS=$oIFS if [ “$FOUND” = “no” ]; then modprobe $mname fi } start() { ifcfg_vpn if [ ! \( -d “/dev/net” \) ]; then mkdir /dev/net fi i
UC-7400-LX Plus User’s Manual Managing Communications i=`expr $i + 1` if [ $i -ge $maxtap ]; then break fi done # null ip address of internal interface ifconfig $iface 0.0.0.0 promisc up # enable bridge ip ifconfig br0 $IPADDR netmask $NETMASK broadcast $BROADCAST ipf=/proc/sys/net/ipv4/ip_forward # enable IP forwarding echo 1 > $ipf echo “ip forwarding enabled to” cat $ipf } stop() { echo “shutdown openvpn bridge.
UC-7400-LX Plus User’s Manual 3. Managing Communications On machine OpenVPN A, modify the remote address in the configuration file, /etc/openvpn/tap0-br.conf. # /etc/openvpn/tap0-br.conf # point to the peer remote 192.168.8.174 dev tap0 secret /etc/openvpn/secrouter.key cipher DES-EDE3-CBC auth MD5 tun-mtu 1500 tun-mtu-extra 64 ping 40 up /etc/openvpn/tap0-br.sh Then modify the routing table in /etc/openvpn/tap0-br.sh script file.
UC-7400-LX Plus User’s Manual 5. Managing Communications On each OpenVPN machine, check the routing table by typing the command: # route Destination 192.168.4.0 192.168.2.0 192.168.8.0 Gateway * * * Genmsk 255.255.255.0 255.255.255.0 255.255.255.0 Flags U U U Metric 0 0 0 Ref 0 0 0 Use 0 0 0 Iface br0 br0 eth0 Interface eth1 is connected to the bridging interface br0, to which device tap0 also connects, whereas the virtual device tun sits on top of tap0.
UC-7400-LX Plus User’s Manual 2. Managing Communications The configuration procedure is almost the same as for the previous example. The only difference is that you will need to comment out the parameter “up” in “/etc/openvpn/tap0-br.conf” and “/etc/openvpn/tap0-br.conf”. Setup 3: Routed IP 1. Set up four machines as shown in the following diagram: Host A local net OpenVPN A LAN1: 192.168.2.173 LAN1: 192.168.2.171 Internet LAN2: 192.168.8.173 LAN1: 192.168.8.174 LAN1: 192.168.4.172 LAN2: 192.168.
UC-7400-LX Plus User’s Manual Managing Communications tun-mtu-extra 64 ping 40 ifconfig 192.168.4.174 192.168.2.173 up /etc/openvpn/tun.sh Then modify the routing table in /etc/openvpn/tun.sh script file. #----------------------------------Start-----------------------------#!/bin/sh # value after “-net” is the subnet behind the remote peer route add -net 192.168.2.0 netmask 255.255.255.
5 Chapter 5 Programmer’s Guide This chapter includes important information for programmers.
UC-7400-LX Plus User’s Manual Programmer’s Guide Before Programming Your Embedded System Caution When Using File Systems We recommend placing only your programs into the on-board NOR Flash. For the log data generated by your programs, please store them into an external storage such as Compact Flash or Network File System. The latter has larger space than the former. In addition, it is easier replacing a full or damaged Compact Flash than an on-board NOR Flash.
UC-7400-LX Plus User’s Manual Programmer’s Guide UC-7400-LX Plus. The host environment must be running Linux to install the UC-7400-LX Plus GNU Tool Chain. We have confirmed that the following Linux distribution can be used to install the tool chain: Fedora core 1/2/3/4/5. The Tool Chain will need about 900 MB of hard disk space on your PC. The UC-7400-LX Plus Tool Chain is located on the UC-7400-LX Plus CD.
UC-7400-LX Plus User’s Manual objdump ranlib readelf size strings strip Programmer’s Guide Displays information about object files Generates indexes to archives (static libraries) Displays information about ELF files Lists object file section sizes Prints strings of printable characters from files (usually object files) Removes symbols and sections from object files (usually debugging information) Debugging with GDB Before you debug with GDB, you must compile your program with the option -ggdb.
UC-7400-LX Plus User’s Manual Programmer’s Guide RTC (Real-time Clock) The device node is located at /dev/rtc. The UC-7400-LX Plus supports Linux standard simple RTC control. You must include . 1. Function: RTC_RD_TIME int ioctl(fd, RTC_RD_TIME, struct rtc_time *time); Description: read time information from RTC. It will return the value on argument 3. 2. Function: RTC_SET_TIME int ioctl(fd, RTC_SET_TIME, struct rtc_time *time); Description: set RTC time. Argument 3 will be passed to RTC.
UC-7400-LX Plus User’s Manual Programmer’s Guide int swtd_open(void) Description Open a file handle to control the watchdog. This is the first step to using the watchdog in your application. Input None Output The return value is the file handle. If there is an error, it will return a negative value. You can use errno() to retrieve the error. int swtd_enable(int fd, unsigned long time) Description This function enables the watchdog function in an application.
UC-7400-LX Plus User’s Manual Programmer’s Guide 0 if OK. An error occurs if you see a non-zero value. Use the function errno () to retrieve the error code. int swtd_ack(int fd) Description: Acknowledge the watchdog. When the user application enables the watchdog, it needs to call this function periodically with time predefined by the user in the application program. Input: int fd — the file handle from the swtd_open() return value. Output: 0 if OK. An error occurs if you see a non-zero value.
UC-7400-LX Plus User’s Manual Programmer’s Guide exit(0); } The makefile is shown below: all: arm-elf-gcc –Wl, -elf2flt –o xxxx xxxx.c –lmoxalib Example 2: #include #include #include #include #include #include #include #include #include static void mydelay(unsigned long msec) { struct timeval time; time.tv_sec = msec / 1000; time.
UC-7400-LX Plus User’s Manual Programmer’s Guide exit(1); } The makefile is shown below: all: arm-elf-gcc –Wl, -elf2flt –o xxxx xxxx.c –lmoxalib UART The normal tty device node is located at /dev/ttyM0 … ttyM15, and the modem tty device node is located at /dev/cum0 … cum15. The UC-7400-LX Plus 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-7400-LX Plus User’s Manual Programmer’s Guide struct termios term; int fd, speed; fd = open(“/dev/ttyM0”, O_RDWR); tcgetattr(fd, &term); if ( (term.c_cflag & (CBAUD|CBAUDEX)) != B4000000 ) { // follow the standard termios baudrate define } else { ioctl(fd, MOXA_GET_SPECIAL_BAUD_RATE, &speed); } Baudrate inaccuracy Divisor = 921600/Target Baudrate. (Only Integer part) ENUM = 8 * (921600/Targer - Divisor) ( Round up or down) Inaccuracy = (Target Baudrate – 921600/(Divisor + (ENUM/8))) * 100% E.g.
UC-7400-LX Plus User’s Manual Programmer’s Guide Turns the LCM backlight off. KeyPad The device node is /dev/keypad. The key value is defined in moxadevice.h. int ioctl(fd, IOCTL_KEYPAD_HAS_PRESS, int *flag); Checks how many keys have been pressed. Argument 3 returns the number of pressed keys. 0 means no keys were pressed. int ioctl(fd, IOCTL_KEYPAD_GET_KEY, int *key); Gets the value of the last key that was pressed. This function only reads one key value for each function call.
6 Chapter 6 Software Lock “Software Lock” is an innovative technology developed by Moxa’s engineers. It can be adopted by a system integrator or developer to protect applications from being copied. An applicaion is compiled into a binary format bound to the embedded computer and the operating system (OS) that the application runs on. As long as one obtains it from the computer, he/she can install it on the same hardware and the same operating system.
UC-7400-LX Plus User’s Manual NOTE Software Lock 3. If you try to run an encrypted program on an embedded computer that does not have an encryption key installed, you will get the following error message. Error => Inconsistency detected by ld.so: dynamic-link.h: 62: elf_get_dynamic_info: Assertion `! “bad dynamic tag”‘ failed! 4.
A Appendix A System Commands busybox (V1.6.0): Linux normal command utility collection System 1. 2. 3. 4. 5. 6. 7. 8. 9. hwclock klogd logger mesg poweroff umount uname syslogd uptime query and set the hardware clock (RTC) Kernel Log Daemon a shell command interface to the syslog(3) system log module control write access to your terminal stop the system unmount file systems print system information Linux system logging utilities tell how long the system has been running File Manager 1. 2. 3. 4. 5. 6.
UC-7400-LX Plus User’s Manual System Commands Editor 1. 2. 3. 4. 5. 6. 7. 8. 9. 10. 11. 12. 13. 14. 15.
UC-7400-LX Plus User’s Manual 12. 13. 14. 15. 16. 17. 18. 19. 20. 21. 22. 23. 24. 25. 26. 27. 28. 29. 30. 31.