UC-7408 User’s Manual Sixth Edition, February 2009 www.moxa.com/product © 2009 Moxa Inc. All rights reserved. Reproduction without permission is prohibited.
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 © 2009 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 Package Checklist....................................................................................................... 1-2 Product Features ...................................................................................
Compiling tcps2.c..................................................................................................... 2-16 Uploading tcps2-release and Running the Program ................................................. 2-17 Testing Procedure Summary .................................................................................... 2-20 Chapter 3 Managing Embedded Linux ........................................................................3-1 System Version Information...............................
Network..................................................................................................................... A-1 Process....................................................................................................................... A-2 Other.......................................................................................................................... A-2 Moxa special utilities.................................................................................................
1 Chapter 1 Introduction Welcome to Moxa UC-7408, a data acquisition embedded computer that features 8 RS-232/422/485 serial ports, dual 10/100 Mbps Ethernet ports, a PCMCIA interface for wireless LAN communication, 8 digital inputs and 8 digital outputs, and CompactFlash for mass storage disk expansion. 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 User’s Manual Introduction Overview UC-7408 data acquisition embedded computers are ideal for embedded applications. UC-7408 has 8 RS-232/422/485 serial ports, dual 10/100 Mbps Ethernet ports, 8 digital input and 8 digital outputs, a PCMCIA interface for wireless LAN communication, and CompactFlash for mass storage flash disk expansion. UC-7408 uses an Intel XScale IXP422 266 Mhz RISC CPU.
UC-7408 User’s Manual Introduction Product Features y y y y y y y y y Intel XScale IXP422 266 MHz Processor On-board 128 MB RAM, 32 MB Flash ROM Eight RS-232/422/485 serial ports Separate 8-ch digital input and 8-ch digital output Dual 10/100 Mbps Ethernet PCMCIA/CompactFlash wireless LANexpansion (supports 802.11b/802.
UC-7408 User’s Manual Introduction Regulatory Approvals Warranty EMC: FCC Class A, CE Class A Safety: UL, CUL, TÜV 5 years 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 CF V+ V- CF x 1 USB 1.
UC-7408 User’s Manual Introduction 44 mm [1.73"] 125 mm [4.92"] Dimensions 197 mm [7.76"] Hardware Block Diagram The following block diagram shows the layout of UC-7408’s internal components.
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 Ready LAN1, LAN2 Console P1, P2, P3, P4, P5, P6, P7, P8 Color Green Yellow Green Yellow Green Yellow Green Meaning Power is ON, and system is ready (after booting up) 10 Mbps Ethernet connection 100 Mbps Ethernet connection Console port is receiving RX data from the serial device. Console port is transmitting TX data to the serial device.
UC-7408 User’s Manual Introduction Real Time Clock UC-7408’s real time clock is powered by a lithium battery. We strongly recommend that you do not replace the lithium battery without help from a qualified Moxa support engineer. If you need to change the battery, contact Moxa RMA service team. WARNING There is a risk of explosion if the battery is replaced by an incorrect type.
UC-7408 User’s Manual Introduction 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. 1. Insert the top of the DIN-Rail into the slot just below the stiff metal spring. 2. The DIN-Rail attachment unit will snap into place as shown below.
UC-7408 User’s Manual Introduction You should also observe the following common wiring rules: y Use separate paths to route wiring for power and devices. If power wiring and device wiring paths must cross, make sure the wires are perpendicular at the intersection point. NOTE: Do not run signal or communication wiring and power wiring in the same wire conduit. To avoid interference, wires with different signal characteristics should be routed separately.
UC-7408 User’s Manual Introduction Connecting to the Network Connect one end of the Ethernet cable to one of UC-7408’s 10/100M Ethernet ports (8-pin RJ45) and the other end of the cable to the Ethernet network. If the cable is properly connected, UC-7408 will indicate a valid connection to the Ethernet in the following ways: 1 1 The bottom right corner LED indicator maintains a solid green color when the cable is properly connected to a 100 Mbps Ethernet network.
UC-7408 User’s Manual Introduction CompactFlash UC-7408 provides one CompactFlash slot that supports CompactFlash type I/II card expansion. Currently, Moxa provides a CompactFlash disk for plug & play mass storage expansion. You may also use flash disks available from most computer supply outlets. The CompactFlash will be mounted at /mnt/hda If you need device drivers for other kinds of mass storage cards, contact Moxa for information on how to initiate a cooperative development project.
UC-7408 User’s Manual Introduction User AP User Directory (User Configuration) Mini Root File System Configuration Linux Kernel & Root Boot Loader HW 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. During this time, the kernel will start searching for system configuration parameters via rc or inittab.
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. Additional information about JFFS2 is available at: http://sources.redhat.com/jffs2/jffs2.pdf http://www.
2 Chapter 2 Getting Started 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 ¾ Serial Console ¾ Telnet Console ¾ SSH Console Configuring the Ethernet Interface ¾ Modifying Network Settings with the Serial Console ¾ Modifying Network Settings over the Network Configuring the WLAN via the PCMCIA Interface ¾ IEEE802.
UC-7408 User’s Manual Getting Started 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.
UC-7408 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 UC-7408’s console utility. The default IP address and Netmask for each of the two ports 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 UC-7408.
UC-7408 User’s Manual Getting Started ATTENTION Serial Console Reminder Remember to choose VT100 as the terminal type. Use cable CBL-RJ45F9-150, which comes with UC-7408, to connect to the serial console port. Telnet Reminder 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.
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. RSA key fingerprint is 8b:ee:ff:84:41:25:fc:cd:2a:f2:92:8f:cb:1f:6b:2f.
UC-7408 User’s Manual 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. Default Setting for LAN1 iface ixp0 inet static address 192.168.3.127 network: 192.168.3.0 netmask 255.255.255.0 broadcast 192.168.3.
UC-7408 User’s Manual 3. Getting Started After the boot settings of the LAN interface have been modified, issue the following command to activate the LAN settings immediately: #/etc/init.d/networking restart NOTE After changing the IP settings, use the networking restart command to activate the new IP address.
UC-7408 User’s Manual 3. Getting Started 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. #cp /etc/wlan/wlancfg-DEFAULT /etc/wlan/wlancfg-any // Copy configuration profile “DEFAULT” to new configuration profile “any”// 5.
UC-7408 User’s Manual Getting Started IEEE802.11g The following IEEE802.11g wireless modules are supported: y y y y y y 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. 2. Use the command #vi /etc/networking/interfaces to open the “interfaces” configuration file with vi editor, and then edit the 802.
UC-7408 User’s Manual 3. 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.
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 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
UC-7408 User’s Manual Getting Started TurboRate—Enables or disables TurboRate Setting Explanation 0 disable 1 enable BGProtection—Sets 11b/11g protection (this function is for engineering testing only) Setting Explanation 0 auto 1 always on 2 always off 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-7408 User’s Manual Getting Started Test Program—Developing Hello.c In this section, we use the standard “Hello” programming example to illustrate how to develop a program for UC-7408. In general, program development involves the following seven steps. Step 1: Connect UC-7408 to a Linux PC. Step 2: Install Tool Chain (GNU Cross Compiler & glibc). Step 3: Set the cross compiler and glibc environment variables. Step 4: Code and compile the program. Step 5: Download the program to UC-7408 Via FTP or NFS.
UC-7408 User’s Manual Getting Started Checking the Flash Memory Space If the flash memory is full, you will not be able to save data to the Flash ROM. Use the following command to calculate the amount of “Available” flash memory: />df –h 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.
UC-7408 User’s Manual NOTE Getting Started Be sure to type the #make command from within the /tmp/example/hello directory, since UC’s tool chain puts a specially designed Makefile in that directory. This special Makefile uses the mxscale-gcc compiler to compile the hello.c source code for the Xscale environment. If you type the #make command from any other directory, Linux will use the x86 compiler (for example, cc or gcc). Refer to Chapter 5 to see a Make file example.
UC-7408 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/uc7400/1st_application/. Note that you need to copy 3 files—Makefile, tcps2.c, tcpsp.
UC-7408 User’s Manual Getting Started root@server11:/home/uc7400/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_ /usr/local/mxscaleb/bin/mxscaleb-gcc -o tcps2-release tcps2.
UC-7408 User’s Manual Getting Started root@server11:/home/uc7400/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-7408 User’s Manual 4. Getting Started 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.
UC-7408 User’s Manual Getting Started 158 root 162 root 163 root 169 root 187 root 188 root root@Moxa:~# NOTE 1532 3652 2208 2192 1264 1592 S S S S S S /sbin/getty 115200 ttyS1 /usr/sbin/sshd -bash ftpd: 192.168.3.110: root: IDLE ./tcps2-release ps -ef 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 &).
UC-7408 User’s Manual NOTE Getting Started The tcps2.c application is a simple example designed to give users a basic understanding of the concepts involved in combining Ethernet communication and serial port communication. However, the example program has some limitations that make it unsuitable for real-life applications. 1. 2. The serial port is in canonical mode and block mode, making it impossible to send data from the Ethernet side to the serial side (i.e., from PC 2 to PC 1 in the above example).
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-7408 units.
UC-7408 User’s Manual Managing Embedded Linux System Version Information To determine the hardware capability of your UC-7408, and what kind of software functions are supported, check the version numbers of your UC-7408’s hardware, kernel, and user file system. Contact Moxa to determine the hardware version. You will need the Production S/N (Serial number), which is located on UC-7408’s bottom label. To check the kernel version, type: #kversion To check the user file system version, type: #fsversion 192.
UC-7408 User’s Manual Managing Embedded Linux Since different Flash disks have different sizes, it’s a good idea to check the size of your Flash disk before upgrading the firmware, or before using the disk to store your application and data files. Use the #df –h command to list the size of each memory block, and how much free space is available in each block. 192.168.3.127 – PuTTY root@Moxa:~# df -h Filesystem Size Used Available Use% Mounted on /dev/mtdblock3 26.0M 8.9M 17.1M 34% / /dev/mtdblock3 26.
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 192.168.3.127 – PuTTY root@Moxa:/mnt/ramdisk# upfirm UC7420-1.5.frm Upgrade firmware utility version 1.0. To check source firmware file context.
UC-7408 User’s Manual Managing Embedded Linux Loading Factory Defaults The easiest way to load factory defaults is to update the firmware (follow the instructions in the previous section to upgrade the firmware). Note that if your user file is not working properly, the system will mount the Mini File System. In this case, you will need to load factory defaults to resume normal operation. Enabling and Disabling Daemons The following daemons are enabled when UC-7408 boots up for the first time. snmpd .....
UC-7408 User’s Manual Managing Embedded Linux Type the command “ps –ef” to list all processes currently running. 192.168.3.
UC-7408 User’s Manual Managing Embedded Linux Then you will find the enabled daemons after you reboot the system. 192.168.3.
UC-7408 User’s Manual Managing Embedded Linux Setting the Run-Level In this section, we outline the steps you should take to set the Linux run-level and execute requests. Use the following command to enable or disable settings: 192.168.3.127 – PuTTY root@Moxa:/ect/rc.d/rc3.d# ls S19nfs-common S25nfs-user-server S99showreadyled S20snmpd S55ssh S24pcmcia S99rmnologin root@Moxa:/etc/rc.d/rc3.d# #cd /etc/rc.d/init.d Edit a shell script to execute /root/tcps2-release and save to tcps2 as an example.
UC-7408 User’s Manual Managing Embedded Linux 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. Use #hwclock to query the current RTC time or set a new RTC time.
UC-7408 User’s Manual Managing Embedded Linux 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 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-7408 User’s Manual Managing Embedded Linux Cron—daemon to Execute Scheduled Commands Start Cron from the directory /etc/rc.d/rc.local. It will return immediately, so you don’t need to start it with ‘&’ to run the background. The Cron daemon will search /etc/cron.d/crontab for crontab files, which are named after accounts in /etc/passwd. Cron wakes up every minute, and checks each command to see if it should be run in the current minute. Modify the file /etc/cron.
4 Chapter 4 Managing Communications In this chapter, we explain how to configure UC-7408’s various communication functions.
UC-7408 User’s Manual Managing Communication Telnet / FTP In addition to supporting Telnet client/server and FTP client/server, the UC-7408 system 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-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: /usr/www/cgi-bin/ Before you modify the homepage, use a browser (such as Microsoft Internet Explore or Mozilla Firefox) from your PC to test if the Apache Web Server is working.
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. 192.168.3.
UC-7408 User’s Manual Managing Communication Saving a Web Page to the CF Card Since some applications will have web pages that take up a lot of memory space, you will need to be able to run the homepage and other pages from the CF card. In this section, we use a simple example to illustrate how to save web pages to the CF card, and then configure the Apache web server to open the pages. The files used in this example can be downloaded from Moxa’s website. Step 1: Prepare web page and put pages to CF card.
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. IPTABLES IPTABLES is an administrative tool for setting up, maintaining, and inspecting the Linux kernel’s IP packet filter rule tables.
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. C. Mangle Table—includes two chains PREROUTING chain—pre-processes packets before the routing process. OUTPUT chain—processes packets after the routing process. It has three extensions—TTL, MARK, TOS.
UC-7408 User’s Manual Managing Communication UC-7408 supports the following sub-modules. Be sure to use the module that matches your application.
UC-7408 User’s Manual Managing Communication 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-7408 User’s Manual Managing Communication Examples: Example 1: Accept all packets from lo interface. # iptables –A INPUT –i lo –j ACCEPT Example 2: Accept TCP packets from 192.168.0.1. # iptables –A INPUT –i ixp0 –p tcp –s 192.168.0.1 –j ACCEPT Example 3: Accept TCP packets from Class C network 192.168.1.0/24. # iptables –A INPUT –i ixp0 –p tcp –s 192.168.1.0/24 –j ACCEPT Example 4: Drop TCP packets from 192.168.1.25. # iptables –A INPUT –i ixp0 –p tcp –s 192.168.1.
UC-7408 User’s Manual Managing Communication NAT Example The IP address of all packets leaving LAN1 are changed to 192.168.3.127 (you will need to load the module ipt_MASQUERADE): IP/Netmask: 192.168.3.100/24 Gateway: 192.168.3.127 PC1 (Linux or Windows) LAN1 LAN1:ixp0 192.168.3.127/24 LAN2:ixp1 192.168.4.127/24 UC-7408 LAN2 PC2 (Linux or Windows) IP/Netmask: 192.168.4.100/24 Gateway: 192.168.4.127 NAT Area / Private IP 1. #ehco 1 > 2. #modprobe 3. #modprobe 4. #modprobe 5. #iptables or 6.
UC-7408 User’s Manual Managing Communication /sbin/iptables -F -t nat /sbin/iptables -X -t nat /sbin/iptables -Z -t nat /sbin/iptables -P INPUT ACCEPT /sbin/iptables -P OUTPUT ACCEPT /sbin/iptables -P FORWARD ACCEPT /sbin/iptables -t nat -P PREROUTING ACCEPT /sbin/iptables -t nat -P POSTROUTING ACCEPT /sbin/iptables -t nat -P OUTPUT ACCEPT # Step 3. Enable IP masquerade. Dial-up Service—PPP PPP (Point to Point Protocol) is used to run IP (Internet Protocol) and other network protocols over a serial link.
UC-7408 User’s Manual Managing Communication Dial the modem, and then ... CONNECT Wait for an answer. “ “ Send a return (null text followed by the usual return) ogin: username word: password Log in with username and password. Refer to the chat man page, chat.8, for more information about the chat utility. /dev/ Specify the callout serial port. 115200 The baud rate. debug Log status in syslog. crtscts Use hardware flow control between computer and modem (at 115200 this is a must).
UC-7408 User’s Manual Managing Communication lo Link encap Local Loopback inet addr 127.0.0.1 Bcast 127.255.255.255 Mask 255.0.0.0 UP LOOPBACK RUNNING MTU 2000 Metric 1 RX packets 0 errors 0 dropped 0 overrun 0 ppp0 Link encap Point-to-Point Protocol inet addr 192.76.32.3 P-t-P 129.67.1.165 Mask 255.255.255.0 UP POINTOPOINT RUNNING MTU 1500 Metric 1 RX packets 33 errors 0 dropped 0 overrun 0 TX packets 42 errors 0 dropped 0 overrun 0 Now, type: ping z.z.z.z where z.z.z.
UC-7408 User’s Manual Managing Communication The first star (*) lets everyone login. The second star (*) lets every host connect. The pair of double quotation marks (“”) is to use the file /etc/passwd to check the password. The last star (*) is to let any IP connect. The following example does not check the username and password: pppd/dev/ttyM0 115200 crtscts modem 192.168.16.1:192.168.16.2 PPPoE How to use PPPoE on UC-7408: 1. Update two files: /usr/sbin/pppd and /usr/lib/pppd/2.4.1/pppoe.
UC-7408 User’s Manual 5. Managing Communication Edit the file /etc/ppp/pap-secrets and add the following: “username@hinet.net” * “password” * “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. 6.
UC-7408 User’s Manual 7. Managing Communication 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. If you use LAN2 to connect to the ADSL modem, then add /etc/ppp/options.ixp1. The file context is shown below: Type your username (the one you set in the /etc/ppp/pap-secrets and /etc/ppp/chap-secrets files) after the “name” option.
UC-7408 User’s Manual NOTE Managing Communication Click on the following links for more information about NFS: http://www.tldp.org/HOWTO/NFS-HOWTO/index.html http://nfs.sourceforge.net/nfs-howto/client.html http://nfs.sourceforge.net/nfs-howto/server.html Setting up UC-7408 as an NFS Server By default, UC-7408 enables the service /etc/init.d/nfs-user-server. The service link file S25nfs-user-server is located in the directory /rc.d/rc2.d-rc5.d.
UC-7408 User’s Manual Managing Communication Example 2 /home/public 192.168.0.0/24(rw) *(ro) In this example, UC-7408 shares the directory /home/public to a local network 192.168.0.0/24, with read and write authority. NFS clients can just read /home/public; they do not have write authority. Example 3 /home/test 192.168.3.100(rw) In this example, UC-7408 shares the directory /home/test to an NFS Client 192.168.3.100, with both read and write authority.
UC-7408 User’s Manual Managing Communication To send an email message, use the ‘smtpclient’ utility, which uses SMTP protocol. Type #smtpclient –help to see the help message. Example: smtpclient –s test –f sender@company.com < mail-body-message -s: -f: -S: –S IP_address receiver@company.com The mail subject. Sender’s mail address SMTP server IP address The last mail address receiver@company.com is the receiver’s e-mail address. mail-body-message is the mail content.
UC-7408 User’s Manual NOTE Managing Communication Click on the following links for more information about MIB II and RS-232 like group: http://www.faqs.org/rfcs/rfc1213.html http://www.faqs.org/rfcs/rfc1317.html Æ 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).
UC-7408 User’s Manual 2. Managing Communication Generate a preset shared key by typing the command: # openvpn --genkey --secret secrouter.key Copy the file that is generated to the OpenVPN machine. 3. Generate a script file named openvpn-bridge on each OpenVPN machine. This script reconfigures interface “ixp1” as IP-less, creates logical bridge(s) and TAP interfaces, loads modules, enables IP forwarding, etc.
UC-7408 User’s Manual Managing Communication if [ “$FOUND” = “no” ]; then modprobe $mname fi } start() { ifcfg_vpn if [ ! \( -d “/dev/net” \) ]; then mkdir /dev/net fi if [ ! \( -r “/dev/net/tun” \) ]; then # create a device file if there is none mknod /dev/net/tun c 10 200 fi # load modules “tun” and “bridge” mname=tun module_up mname=bridge module_up # create an ethernet bridge to connect tap devices, internal interface brctl addbr br0 brctl addif br0 $iface # the bridge receives data from any port and
UC-7408 User’s Manual Managing Communication i=`expr $i + 1` if [ $i -ge $maxtap ]; then break fi done brctl delif br0 $iface brctl delbr br0 ifconfig br0 down ifconfig $iface $IPADDR netmask $NETMASK broadcast $BROADCAST killall -TERM openvpn } case “$1” in start) start ;; stop) stop ;; restart) stop start ;; *) echo “Usage: $0 [start|stop|restart]” exit 1 esac exit 0 #---------------------------------- end ----------------------------- Create link symbols to enable this script at boot time: # ln -s /et
UC-7408 User’s Manual Managing Communication #!/bin/sh # value after “-net” is the subnet behind the remote peer route add -net 192.168.2.0 netmask 255.255.255.0 dev br0 #---------------------------------- end ----------------------------- Note: Select cipher and authentication algorithms by specifying “cipher” and “auth”. To see with algorithms are available, type: # openvpn --show-ciphers # openvpn --show--auths 5. Start both of OpenVPN peers, # openvpn --config A-tap0-br.
UC-7408 User’s Manual Managing Communication Setup 2: Ethernet Bridging for Private Networks on the Same Subnet 1. Set up four machines as shown in the following diagram: Host A local net OpenVPN A eth1: 192.168.2.173 eth0: 192.168.2.171 Internet eth0: 192.168.8.173 ixp0: 192.168.8.174 eth0: 192.168.2.172 ixp1: 192.168.2.174 Host B 2. OpenVPN B local net The configuration procedure is almost the same as for the previous example.
UC-7408 User’s Manual 2. Managing Communication Create a configuration file named “A-tun.conf” and an executable script file named “A-tun.sh”. # point to the peer remote 192.168.8.174 dev tun secret /etc/openvpn/secrouter.key cipher DES-EDE3-CBC auth MD5 tun-mtu 1500 tun-mtu-extra 64 ping 40 ifconfig 192.168.2.173 192.168.4.174 up /etc/openvpn/A-tun.sh #--------------------------------#!/bin/sh # value after “-net” is the subnet route add -net 192.168.4.
5 Chapter 5 Programmer’s Guide This chapter includes important information for programmers.
UC-7408 User’s Manual Programmer’s Guide Flash Memory Map Partition sizes are hard coded into the kernel binary. To change the partition sizes, you will need to rebuild the kernel. The flash memory map is shown in the following table.
UC-7408 User’s Manual Programmer’s Guide Obtaining help Use the Linux man utility to obtain help on many of the utilities provided by the tool chain. For example to get help on the armv5b-linux-gcc compiler, issue the command: #man armv5b-linux-gcc Cross Compiling Applications and Libraries To compile a simple C application, just use the cross compiler instead of the regular compiler: #mxscaleb-gcc –o example –Wall –g –O2 example.c #mxscaleb-strip –s example #mxscaleb-gcc -ggdb –o example-debug example.
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.
UC-7408 User’s Manual Programmer’s Guide Debugging with GDB First compile the program must with option -ggdb. Use the following steps: 1. To debug a program called hello-debug on the target, use the command: #gdbserver 192.168.4.142:2000 hello-debug This is where 2000 is the network port number on which the server waits for a connection from the client. This can be any available port number on the target.
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 . 1. Function: KDMKTONE ioctl(fd, KDMKTONE, unsigned int arg); Description: The buzzer’s behavior is determined by the argument arg. The “high word” part of arg gives the length of time the buzzer will sound, and the “low word” part gives the frequency.
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. If you do not ack, the system will be reboot automatically. The minimal time is 50 msec, the maximum time is 60 seconds. The time unit is msec.
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. Output: OK will be zero. The other has some error, to get error code from errno(). int swtd_close(int fd) Description: Close the file handle.
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 #include #include #include #include #include #include #include #include static void mydelay(unsigned long msec) { struct timeval time; time.tv_sec = msec / 1000; time.
UC-7408 User’s Manual Programmer’s Guide exit(1); } The makefile is shown below: all: mxscaleb-gcc –o xxxx xxxx.c –lmoxalib 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.
UC-7408 User’s Manual Programmer’s Guide Example to get the baud rate #include #include 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 baud rate define } else { ioctl(fd, MOXA_GET_SPECIAL_BAUD_RATE, &speed); } Baud rate inaccuracy Divisor = 921600/Target Baud Rate.
UC-7408 User’s Manual Programmer’s Guide The definition for DIN and DOUT: #define DIO_HIGH 1 #define DIO_LOW 0 int set_dout_state(int doport, int state) Description: Input: Output: Return: To set the DOUT port to high or low state. int doport - which DOUT port you want to set. Port starts from 0 to 7. int state - to set high or low state; DIO_HIGH (1) for high, DIO_LOW (0) for low. none. reference the error code.
UC-7408 User’s Manual Programmer’s Guide duration - Not 0 > detect the din event DIN_EVENT_HIGH_TO_LOW or DIN_EVENT_LOW_TO_HIGH with 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 200 ms, this event will be generated when the DIN pin stays in the same state for a time between 176 ms and 200 ms. Output: Return: none.
UC-7408 User’s Manual #ifdef DEBUG #define dbg_printf(x...) #else #define dbg_printf(x...) #endif Programmer’s Guide printf(x) #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.
UC-7408 User’s Manual Programmer’s Guide } else if ( i == 5 ) { // set high data printf("Please keyin the DOUT number : "); scanf("%d", &i); retval=set_dout_state(i, 1); } else if ( i == 6 ) { // set low data printf("Please keyin the DOUT number : "); 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
UC-7408 User’s Manual Programmer’s Guide #include #include #include #ifdef DEBUG #define dbg_printf(x...) #else #define dbg_printf(x...
UC-7408 User’s Manual Programmer’s Guide // configure the dout frequency. When the timer timeouts, dout_control() will be called to change the dout state value.it_value.tv_sec = duration[0][nDuration]/1000; value.it_value.tv_usec = (duration[0][nDuration]%1000) *1000 ; value.it_interval = value.
UC-7408 User’s Manual Programmer’s Guide act.sa_flags=0; sigemptyset(&act.
A Appendix A System Commands Linux normal command utility collection File manager 1. 2. 3. 4. 5. 6. 7. 8. 9. 10. 11. 12. 13. 14.
UC-7408 User’s Manual System Commands Process 1. 2. kill ps kill process display now running process 1. 2. 3. 4. 5. 6. 7. 8. 9. 10. 11. 12. 13. dmesg sty zcat mknod free date env clear reboot halt du gzip, gunzip hostname dump kernel log message to set serial port dump .