Moxa UC-7420 manual

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91

Go to page of

A good user manual

The rules should oblige the seller to give the purchaser an operating instrucion of Moxa UC-7420, along with an item. The lack of an instruction or false information given to customer shall constitute grounds to apply for a complaint because of nonconformity of goods with the contract. In accordance with the law, a customer can receive an instruction in non-paper form; lately graphic and electronic forms of the manuals, as well as instructional videos have been majorly used. A necessary precondition for this is the unmistakable, legible character of an instruction.

What is an instruction?

The term originates from the Latin word „instructio”, which means organizing. Therefore, in an instruction of Moxa UC-7420 one could find a process description. An instruction's purpose is to teach, to ease the start-up and an item's use or performance of certain activities. An instruction is a compilation of information about an item/a service, it is a clue.

Unfortunately, only a few customers devote their time to read an instruction of Moxa UC-7420. A good user manual introduces us to a number of additional functionalities of the purchased item, and also helps us to avoid the formation of most of the defects.

What should a perfect user manual contain?

First and foremost, an user manual of Moxa UC-7420 should contain:
- informations concerning technical data of Moxa UC-7420
- name of the manufacturer and a year of construction of the Moxa UC-7420 item
- rules of operation, control and maintenance of the Moxa UC-7420 item
- safety signs and mark certificates which confirm compatibility with appropriate standards

Why don't we read the manuals?

Usually it results from the lack of time and certainty about functionalities of purchased items. Unfortunately, networking and start-up of Moxa UC-7420 alone are not enough. An instruction contains a number of clues concerning respective functionalities, safety rules, maintenance methods (what means should be used), eventual defects of Moxa UC-7420, and methods of problem resolution. Eventually, when one still can't find the answer to his problems, he will be directed to the Moxa service. Lately animated manuals and instructional videos are quite popular among customers. These kinds of user manuals are effective; they assure that a customer will familiarize himself with the whole material, and won't skip complicated, technical information of Moxa UC-7420.

Why one should read the manuals?

It is mostly in the manuals where we will find the details concerning construction and possibility of the Moxa UC-7420 item, and its use of respective accessory, as well as information concerning all the functions and facilities.

After a successful purchase of an item one should find a moment and get to know with every part of an instruction. Currently the manuals are carefully prearranged and translated, so they could be fully understood by its users. The manuals will serve as an informational aid.

Table of contents for the manual

  • Page 1

    UC-7420/7410 User ’ s Manual Seventh Edition, February 2009 www .moxa.com/product © 2009 Moxa Inc. All righ ts reserved. Reproducti on without perm ission is pr ohibited.[...]

  • Page 2

    UC-7420/7410 User’s Manual The software d escribed in thi s manual i s furnished u nder a license agreem ent and m ay be used only in accordance with the term s of that agreement. Copyright Notice Copyright © 2009 Moxa Inc. All rights reserved. Reproducti on without perm ission is pr ohibited. Trademarks MOXA is a re gistered tra demark of M oxa[...]

  • Page 3

    Table of Contents Chapter 1 Introduction .................................................................................................. 1-1 Overview.................................................................................................................................. 1-2 Package Ch ecklis t............................................[...]

  • Page 4

    Compiling tcps2.c..................................................................................................... 2-16 Uploading tcps2-release a n d Running the Pr ogram ................................................. 2- 17 Testing Procedure Summary .................................................................................... 2-19 Cha[...]

  • Page 5

    File manager .............................................................................................................. A-1 Editor ......................................................................................................................... A-1 Network .................................................................................[...]

  • Page 6

    1 1 Chapter 1 Introduction Welcome to M oxa UC-7420/ 7410 RISC- based Comm unication Platf orms. Availabl e features include eight RS-232/422/485 seri al ports, dual 10/100 Mbps Ethe rnet ports, a PCMCIA interface for wireless L AN communi cation, and C ompactFl ash and USB ports for mass storage disk expansion, m aking UC- 7420/7410 ideal for your[...]

  • Page 7

    UC-7420/7410 User’s Manual Introduction 1-2 Overview UC-7420/741 0 RISC-based C ommunicati on Platfo rms are i deal for embedded applications. UC-7420/7 410 has eight RS-232/42 2/485 ser ial ports, dual 10/100 M bps Ethernet p orts, a PCMCIA interface for wireless LAN communicatio n, an d CompactFlash and USB port for m ass storage flash disk e x[...]

  • Page 8

    UC-7420/7410 User’s Manual Introduction 1-3 Product Features y Intel XScale IXP422 266 MHz Processor y On-board 128 MB RAM, 32 MB Flash ROM y Eight RS-2 32/422/485 serial ports y Dual 10/100 Mbps Eth ernet y PCMCIA/CompactFlash expansion (UC-7420 on ly) y USB Host for mass storag e device (UC-7420 o nly) y LCM display an d Keypad for HMI y Linux-[...]

  • Page 9

    UC-7420/7410 User’s Manual Introduction 1-4 Operating temperatur e -10 to 60 °C, (14 to 1 40°F), 5 to 95% RH S torage temperature -20 to 80 °C, (-4 to 1 85°F), 5 to 95% RH Regulatory Approvals EMC: FCC Class A, CE Class A Safety: UL, CUL, TÜV Wa r r a n t y 5 years Hardware Introduction Appearance and Dimensions Appearance UC-7410/7420 Rear [...]

  • Page 10

    UC-7420/7410 User’s Manual Introduction 1-5 Dimensions 197 mm [7.76"] 125 mm [4.92"] 44 mm [1.73"][...]

  • Page 11

    UC-7420/7410 User’s Manual Introduction 1-6 Hardware Block Diagram The following block diagram shows the layou t of UC-7420’s internal componen ts (the layout for UC-7410 is sl ightly di fferent). USB Host USB controller PCI to cardbus Bridge Moxa UART ASIC PCI Bus USB Client PCMCIA & CompactFlash Console LAN2 LAN1 RS-232/422/485 RS-232 Eth[...]

  • Page 12

    UC-7420/7410 User’s Manual Introduction 1-7 Reset-type Buttons UC-7420/7410 ha s two reset-type buttons . The button labeled Reset has the sam e effect as unpluggin g the powe r and then plugging the power back in. The b utton lab eled Reset to defa ult returns UC-7420/7410 to the factory default parameter configuration. Reset Button Pressing the[...]

  • Page 13

    UC-7420/7410 User’s Manual Introduction 1-8 Placement Options W all or Cabinet The two metal brackets that co me standard with UC-7420/7410 are used to attach UC-7420/7410 to a wall, or the inside of a cabinet. Use two scre ws per bracket first to attach the brackets to the bottom of the UC-7420/7410 (Fig. A). Next, us e two screws per bracket to[...]

  • Page 14

    UC-7420/7410 User’s Manual Introduction 1-9 DIN-Rail Mounting The aluminum DIN-Rail attachm ent plate is included in the package. If you need to reattach the DIN-Rail attachment plate to UC-7420/7410, make sure the stiff metal spring is situated towards the top, as shown in the figures b elow. 1. Insert the top of the DIN-Rail into the slot just [...]

  • Page 15

    UC-7420/7410 User’s Manual Introduction 1-10 You should al so observe the following comm on wiring rule s: y Use separate p aths to route wiring for power and devi ces. If powe r wiring and device wiri ng paths must cross, m ake sure the wires are perpendicular at t he intersection point. NOTE: Do not run signal o r communicati on wiring and powe[...]

  • Page 16

    UC-7420/7410 User’s Manual Introduction 1-11 Connecting to the Network Connect one end of the Ethernet cab le to one of UC-7420/7410’s 10/100M Eth ernet ports (8-pin RJ45) and the other end of the cable to th e Ethern et network. If the ca bl e is properly connected, UC-7420/7410 will ind icate a valid connection to the Ethernet in the followin[...]

  • Page 17

    UC-7420/7410 User’s Manual Introduction 1-12 CompactFlash UC-7420 pro vides one CompactFl ash slot that supports Com pactFlash type I/ II card expa nsion. Currently, Mo xa provides a CompactFlash disk for plug & play mass stor age expansi on. You m ay also use flash disks available from most computer su pply outlets. The CompactFlash will be [...]

  • Page 18

    UC-7420/7410 User’s Manual Introduction 1-13 User AP User Directory (User Configuration) Mini Root File System Configuration Linux Kernel & Root HW Boot Loader To improve system reliability, UC-7420/7410 has a bu ilt-in mechanism that prevents th e system from crashing. The procedure is as follows. When the Linux kernel boots up, the kernel w[...]

  • Page 19

    UC-7420/7410 User’s Manual Introduction 1-14 Although JFFS2 is a journaling file system, this does not preclude the loss of data. The file system will remain in a consistent state acros s power fa ilures a nd will always be m ountable. However, if the board is powered down during a write then the inco mplete write will be rolled back on the next [...]

  • Page 20

    2 2 Chapter 2 Getting Started In this chapter, we explain how to conn ect UC-7420/7410, turn on the power, and th en get started using the programm ing and ot her functio ns. The following topics are covered in this chapter:  Powering on UC-7420/7410  Connecting UC-7420 /7410 to a PC ¾ Serial Cons ole ¾ Telnet Cons ole ¾ SSH Cons ole  C[...]

  • Page 21

    UC-7420/7410 User’s Manual Getting Started 2-2 Powering on UC-7420/7410 Connect the SG wire to the Shielded Con tact located in the upper left corner of the UC-7420/741 0, and then power on U C-7420/7410 by connectin g it to the power adap tor. It takes about 30 to 60 seconds for the system to boo t up. Once the system is ready, the Ready LED wil[...]

  • Page 22

    UC-7420/7410 User’s Manual Getting Started 2-3 Telnet Console If you know at least one of the tw o IP addresses an d netmasks, then you can use Telnet to connect to UC-7420/7410’s co nsole utility. The default IP a ddress and Netm ask for each of the two ports are given below: Default IP Address Netmask LAN 1 192.168.3.127 255.255.255 .0 LAN 2 [...]

  • Page 23

    UC-7420/7410 User’s Manual Getting Started 2-4 ATTENTION Serial Console Reminder Remember to choose VT100 as the terminal type. Use cable C BL-RJ45F9-15 0, which com es with UC-7420/7410 , to connect to the serial console port. Telnet Reminder When conn ecting to UC-7420/7410 ov er a LAN, you must configur e your PC’s Ethernet IP address to be [...]

  • Page 24

    UC-7420/7410 User’s Manual Getting Started 2-5 Linux Users From a Linux machine, use t he “ssh” command to access UC-7420/7410’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. R[...]

  • Page 25

    UC-7420/7410 User’s Manual Getting Started 2-6 Dynamic IP addresses : By default, UC-7420/7410 is configured for “static” IP addresses. To configure one or both LAN ports to request an IP address dynami cally, replace static with dhcp and then delete the address, network , netmask, and broa dcast lines. Default Setting for LAN1 Dynamic Settin[...]

  • Page 26

    UC-7420/7410 User’s Manual Getting Started 2-7 NOTE After changing the IP settings, use the networking restart command to activate the new IP address. However, the LCM display will still sh ow the old IP address. To update the LCM display, you will need to reboot the UC-7420 /7410. Modifying Network Settings over the Network IP settings can be ac[...]

  • Page 27

    UC-7420/7410 User’s Manual Getting Started 2-8 3. Configure the W ireless 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_w lan0=y // 4. Duplicate the configuration profile to [...]

  • Page 28

    UC-7420/7410 User’s Manual Getting Started 2-9 IEEE802.11g The following I EEE802.11g wireless modules are supported: y ASUS — WL-1 07g y CNET — CWC-8 54 (181D ve rsion) y Edmiax — EW-7108PCg y Amigo — AWP-914W y GigaByte — GN-WMKG y Other brands that use the Ralin k RT2500 series chip set To configu re the WLAN for IEEE802. 11g: 1. Unp[...]

  • Page 29

    UC-7420/7410 User’s Manual Getting Started 2-10 3. Additional WLAN parameters are contained in the file RT2500STA.dat . To open the file, navigate to t he RT2500ST A folder a nd invoke vi, or type t he followi ng comma nd #vi /etc/Wireless/RT2500STA/RT2500STA.dat to edit the file with vi editor. Settin g options for the various parameters are lis[...]

  • Page 30

    UC-7420/7410 User’s Manual Getting Started 2-11 NetworkT ype —Sets the wireless operation mode Setting Explanation Infra Infrastructure mode (uses acc ess points to transmit data) Adhoc Adhoc m ode (transm its data from host to host ) Channel —Sets the channel Setting Explanation 0 auto 1 to 14 the channel yo u want to use AuthMode —Sets th[...]

  • Page 31

    UC-7420/7410 User’s Manual Getting Started 2-12 T urboR ate —Enables or disables T u rboRate Setting Explanation 0 disable 1 enable BGProtection —Sets 1 1b/1 1g protection (t his function i s for e ngineering t esting only ) Setting Explanation 0 auto 1 always on 2 always off ShortSlot —Enables or disables t he short slot time Setting Expla[...]

  • Page 32

    UC-7420/7410 User’s Manual Getting Started 2-13 Test Program — Developing Hello.c In this section, we use the standard “Hello” programming example to illu strate how to develop a program for UC-7420/7 410. In gene ral, prog ram developm ent involves t he followi ng seven steps . Step 1: Connect UC-7 420/7410 to a Linu x PC. Step 2: Install [...]

  • Page 33

    UC-7420/7410 User’s Manual Getting Started 2-14 If there isn’t enough “Available” space for you r application, you will need to delete some existing files. To do this, connect your PC to the UC-7420 /7410 with the console cable, an d then use the console utility to delete the files from UC-7420/7410 ’s flash memory. NOTE If the flash me m[...]

  • Page 34

    UC-7420/7410 User’s Manual Getting Started 2-15 Uploading “Hello” to UC-742 0/7410 and Running the Program Use the follo wing comm and to upload hello-release to the UC-7420/7410 via FTP. 1. From the PC, type: #ftp 192.168.3.127 2. Use bin command to set the transfer mode to Binary mode, and the put command to in itiate the file transfer: ftp[...]

  • Page 35

    UC-7420/7410 User’s Manual Getting Started 2-16 Compiling tcps2.c The source code for the tcps2 exam ple is located on the CD -ROM at CD-ROM://example/TCPServer2/tcps 2.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 — Ma[...]

  • Page 36

    UC-7420/7410 User’s Manual Getting Started 2-17 Uploading tcps2-release and Running the Program Use the following commands to use FTP to up load tcps2-release to the UC-7420/7410. 1. From the PC, type: #ftp 192.168.3.127 2. Next, use the bin command to set the transfer mode to Binary , and th e put command to initiate the file transfer: ftp> b[...]

  • Page 37

    UC-7420/7410 User’s Manual Getting Started 2-18 4. The program should start running in the background. Use either the #jobs or #ps –ef command to check if the tc ps2 program is actually running in t he backgro und. #jobs // use this command to check if the program is running 192.168.3.127 – PuTTY root@Moxa:~# ls –al drwxr—xr-x 2 root root[...]

  • Page 38

    UC-7420/7410 User’s Manual Getting Started 2-19 158 root 1532 S /sbin/getty 115200 ttyS1 162 root 3652 S /usr/sbin/sshd 163 root 2208 S -bash 169 root 2192 S ftpd: 192.168.3.110: root: IDLE 187 root 1264 S ./tcps2-release 188 root 1592 S ps -ef root@Moxa:~# NOTE Use the kill -9 command for PID 187 to terminate this program: #kill -9 %187 Testing [...]

  • Page 39

    UC-7420/7410 User’s Manual Getting Started 2-20 NOTE The tcps2.c appl ication is a si mple exam ple designed to gi ve users a basic understan ding of the concepts inv olved in com bining Ethe rnet comm unication and seri al port c ommunicati on. However, the example program has some limita tions that make it unsuitab le for real-life applications[...]

  • Page 40

    3 3 Chapter 3 Managing Embedded Linux This chapte r includes inf ormati on about vers ion contr ol, deploym ent, upda tes, and peri pherals. The information in this chapter will be particu larly useful when you need to run the same application on several UC -7420/74 10 units. The following topics are covered in this chapter:  System Version Info[...]

  • Page 41

    UC-7420/7410 User’s Manual Managing Embedded Linux 3-2 System Version Information To determine the hardware capability of your UC-7 420/7410 , and what kind of software functions are supported , check the versio n numbers of your U C-7420/7410’s h ardware, kernel, and u ser file system. Contact Moxa to determine th e hardware version. You will [...]

  • Page 42

    UC-7420/7410 User’s Manual Managing Embedded Linux 3-3 Since different Flash disks have different sizes, it’ s a good idea to check the size of your Flash disk before upgrading the firmware, o r before using the disk to store your application and data files. Use the #df –h command to list the size of each memo ry bl ock, and ho w much free sp[...]

  • Page 43

    UC-7420/7410 User’s Manual Managing Embedded Linux 3-4 -rw-rw-rw- 1 ftp ftp 8778996 Nov 29 10:24 UC7420_usrdisk-1.5.frm 226 Transfer complete. ftp> get UC7420-1.5.frm 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 se[...]

  • Page 44

    UC-7420/7410 User’s Manual Managing Embedded Linux 3-5 Loading Factory Default s The easiest way to load factory defaults is to up d ate the firmware (follow the instructions in the previous section to u pgrade the firm ware). Note that if y our use r file is n ot working p roperly, the sy stem wi ll mount the M ini File S ystem. In this case, yo[...]

  • Page 45

    UC-7420/7410 User’s Manual Managing Embedded Linux 3-6 Type the command “ps –ef” to list all pro cesses currently running. 192.168.3.127 – PuTTY root@Moxa:~# cd /etc root@Moxa:/etc# ps -ef PID Uid VmSize Stat Command 1 root 1296 S init 2 root S [keventd] 3 root S [ksoftirqd_CPU0] 4 root S [kswapd] 5 root S [bdflush] 6 root S [kupdated] 7 [...]

  • Page 46

    UC-7420/7410 User’s Manual Managing Embedded Linux 3-7 Next, use the vi open your a pplication program. We use the exam ple program tcps2-release , and put it to run in the backg round. 192.168.3.127 – PuTTY # !/bin/sh # Add you want to run daemon /root/tcps2-release &~ Then you will find the enab led daemons after you reboot the system. 19[...]

  • Page 47

    UC-7420/7410 User’s Manual Managing Embedded Linux 3-8 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 follow ing comm and to enable or disable settings: 192.168.3.127 – PuTTY root@Moxa:/ect/rc.d/rc3.d# ls S19nfs-common S25nfs-user-server S99showreadyled S20sn[...]

  • Page 48

    UC-7420/7410 User’s Manual Managing Embedded Linux 3-9 Adjusting the System Time Setting the T ime Manually UC-7420/7410 has two time settings. One is the system time, and the other is the RTC (Real Time Clock) tim e kept by the UC-7420/7 410 hard ware. Use the #dat e command to query the cur rent system time or set a ne w system time. Use #hwclo[...]

  • Page 49

    UC-7420/7410 User’s Manual Managing Embedded Linux 3-10 NTP Client UC-7420/7410 has a bu ilt-in NTP (Network Time Protocol) client that is used to initialize a ti me request to a remote NTP server. Use #ntpdate < this client utility > to update the sy stem time. #ntpdate time.stdtime.gov.tw #hwclock –w Visit http://www.ntp.org fo r more i[...]

  • Page 50

    UC-7420/7410 User’s Manual Managing Embedded Linux 3-11 Cron—daemon to Execute Scheduled Commands This function is o nly available for firm ware version V1. 5 (and later version s). 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 backgroun d. The Cron dae[...]

  • Page 51

    UC-7420/7410 User’s Manual Managing Embedded Linux 3-12 Connecting Peripherals USB Mass S torage This function is o nly available for firm ware version V1. 5 (and later version s). The UC-7420/7410 supports PNP (plug -n-play), and hot pluggability for connecting USB mass storage devices. UC-7420/ 7410 has a built-in auto m ount utility that eases[...]

  • Page 52

    4 4 Chapter 4 Managing Communications In this chapt er, we ex plain how to configure UC -7420/7410 ’s various com muni cation functi ons. The following topics are covered in this chapter:  Telnet / FTP  DNS  Web Service—Apache ¾ Saving a W eb Page to the CF Car d  IPTABLES  NAT ¾ NA T Example ¾ Enabling NA T at Bootup  Dial[...]

  • Page 53

    UC-7420/7410 User’s Manual Managing Communication 4-2 Telnet / FTP In addition to suppo rting Telnet client/server and FTP client/server, the UC-7420/7410 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 examp[...]

  • Page 54

    UC-7420/7410 User’s Manual Managing Communication 4-3 Web Service—Apache The Apache web server’s main co nfiguration file is /etc/apache/httpd.conf , with the default homepage loca ted at /usr/www/html/index.html . Save your own hom epage to the following directory: /usr/www/html/ Save your CGI page to the f ollowing direct ory: /usr/www/cgi-[...]

  • Page 55

    UC-7420/7410 User’s Manual Managing Communication 4-4 To open the de fault CGI te st script re port page, ty pe http://192.168.3.127 /cg i-bin/test-cgi in your browser’s address box. NOTE The CGI functi on is enabl ed by defa ult. If yo u want to di sable the functi on, modi fy the file /etc/apache/httpd.conf . When you devel op your own CGI ap[...]

  • Page 56

    UC-7420/7410 User’s Manual Managing Communication 4-5 Saving a W eb 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 r un the homepage a nd other pages from the CF ca rd. In this sect ion, we use a si mple example to illustrate how to save web pages to the CF card, and[...]

  • Page 57

    UC-7420/7410 User’s Manual Managing Communication 4-6 Step4: Open your browser and con nect to the UC-7420/7410 by typing the current LAN1 IP address in the browser’s addr ess box. NOTE Visit the Apache website at http://httpd.ap ache.org/docs/ for more information about setting up an Apache server. IPTABLES IPTABLES is an administrative tool f[...]

  • Page 58

    UC-7420/7410 User’s Manual Managing Communication 4-7 MASQUERA DE — a special form for SNAT. If o ne hos t can connect to internet, th en other computers that c onnect to this host can connect to the Internet whe n it the computer does not have an actual IP address. REDIRECT — a special form of DNAT that re-se nds packet s to a local host ind[...]

  • Page 59

    UC-7420/7410 User’s Manual Managing Communication 4-8 UC-7420/741 0 supports the f ollowing s ub-modules. Be sure to use t he module that m atches your application. ip_conntrack ipt_ MARK ipt_ah ipt_state ip_conntrack_ftp ip t_MASQUERADE ipt_esp ipt_tcpmss ipt_conntrack_irc ipt_ MIRROT ipt_length ipt_tos ip_nat_ftp ipt_ REDIRECT ipt_limit ipt_ttl[...]

  • Page 60

    UC-7420/7410 User’s Manual Managing Communication 4-9 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 incl uded: INPUT, OUT PUT, and FORWARD. INPUT chains are acce pted automatically, and all connections ar e accepted without being filtered. #iptabl[...]

  • Page 61

    UC-7420/7410 User’s Manual Managing Communication 4-10 Example 2: Ac cept TCP pack ets from 192. 168.0.1. # iptables –A INPUT –i ixp0 –p tcp –s 192.168.0.1 –j ACCEPT Example 3: Ac cept TCP pack ets from Cl ass C network 1 92.168.1.0/24. # iptables –A INPUT –i ixp0 –p tcp –s 192.168.1.0/24 –j ACCEPT Example 4: D rop TCP pac ket[...]

  • Page 62

    UC-7420/7410 User’s Manual Managing Communication 4-11 1. #ehco 1 > /proc/sys/net/ipv4/ip_forward 2. # modprobe iptable_nat 3. # modprobe ip_conntract 4. # modprobe ipt_MASQUERADE 5. #iptables -t nat –A POSTROUTING –o ixp0 –j SNAT --to-source 192.168.3.127 or 6. #iptables –t nat –A POSTROUTING –o ixp0 –j MASQUERADE Enabling NA T [...]

  • Page 63

    UC-7420/7410 User’s Manual Managing Communication 4-12 NOTE Click on the following links for more information about ppp: http://tldp.org /HOWTO/PPP-HOWTO/index.html http://axion.physics.ub c.ca/ppp-linux.html The pppd daem on is used to connect to a PPP se rver from a Linux syste m. For detai led informati on about pppd see t he man page. Example[...]

  • Page 64

    UC-7420/7410 User’s Manual Managing Communication 4-13 crtscts Use hardware f low control between comput er and modem (at 115200 t his is a must ). 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 l[...]

  • Page 65

    UC-7420/7410 User’s Manual Managing Communication 4-14 where z.z.z.z is the address of your name server. T his should work. Here ’s what the response could loo k like: waddington :~$p ping 129 .67.1.165 PING 129.67.1.165 (129.67 .1.165): 56 data bytes 64 bytes from 129.67.1.165: i cmp_seq=0 ttl=225 time=268 m s 64 bytes from 129.67.1.165: i cmp[...]

  • Page 66

    UC-7420/7410 User’s Manual Managing Communication 4-15 PPPoE How to use PPPoE on UC-7 408: 1. Update two files: /usr/sbin/pppd and /usr/lib/pppd/2.4.1/pppoe.so on the target UC-7408 for version V1.5 or earlier ve rsions. Copy the files fr om the web or CD-ROM , and directly update it by the c opy command or FTP. 2. Connect UC-7 408’s LAN po rt [...]

  • Page 67

    UC-7420/7410 User’s Manual Managing Communication 4-16 5. Edit the file /etc/ppp/pap-secrets and add t he followi ng: “username@hinet. net” * “passwor d” * “username@hinet.net” is t he username obtai ned from the ISP to log in to the ISP account. “password” is the corresponding password for the account. 6. Edit the file /etc/ppp/o[...]

  • Page 68

    UC-7420/7410 User’s Manual Managing Communication 4-17 7. Add one of two fil es: /etc/ppp/options.ixp0 or /etc/ppp/options.ix p1 . The choice depends on which LAN is connected to t he 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 m odem, then add /etc/ppp/option[...]

  • Page 69

    UC-7420/7410 User’s Manual Managing Communication 4-18 NFS (Network File System) The Network File System (NFS) is used to mount a disk partition on a remote machine, as if it were on a local hard drive, allowing fast, seam less sharing of files across a network. NFS allows users to develop applications fo r UC-7420/7410, without worrying about th[...]

  • Page 70

    UC-7420/7410 User’s Manual Managing Communication 4-19 async The async option instructs the server to lie to th e client, telling the client that all data has been written to the stable storag e. Example 1 /tmp *(rw,no_root_squash) In this example, UC -7420/7410 shares the /tmp directory to e veryone, gi ves everyone b oth read and write authorit[...]

  • Page 71

    UC-7420/7410 User’s Manual Managing Communication 4-20 NOTE Click on the following link for more information about smtpclient: http://www.engelschall.co m/sw/smtpclient/ To send an email message, use the ‘smtpclient’ utility, which uses SMTP protocol. Type #smtpclient –help to see the help m essage. Example: smtpclient –s test –f sender[...]

  • Page 72

    UC-7420/7410 User’s Manual Managing Communication 4-21 ***** SNMP QUERY FINISHED ***** NOTE Click on the following links for more information about MIB II and RS-2 32 like group: http://www.faqs.org/ rfcs/rfc121 3.html http://www.faqs.org/ rfcs/rfc131 7.html Æ UC-7420/7 410 does NOT support SNM P trap. The following tables list the variables sup[...]

  • Page 73

    UC-7420/7410 User’s Manual Managing Communication 4-22 2. Generate a pre set shared key by typing the comma nd: # openvpn --genkey --secret secrouter.key Copy the file that is generated to the OpenVPN machine. 3. Generate a scri pt file nam ed openvpn-bridge on each OpenVPN m achine. This script reconfigures interface “ixp1” as IP-less, crea [...]

  • Page 74

    UC-7420/7410 User’s Manual Managing Communication 4-23 IFS=$oIFS 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 “br[...]

  • Page 75

    UC-7420/7410 User’s Manual Managing Communication 4-24 openvpn --rmtun --dev tap${i} 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 s[...]

  • Page 76

    UC-7420/7410 User’s Manual Managing Communication 4-25 up /etc/openvpn/B-tap0-br.sh #---------------------------------- Start---------------------------- #!/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 -------------------------[...]

  • Page 77

    UC-7420/7410 User’s Manual Managing Communication 4-26 Setup 2: Ethernet Bridging for Pr ivate Networks on the Same Subnet 1. Set up four machines as sho wn in the following diagram: OpenVPN A OpenVPN B Host A eth0: 192.168.2.171 Host B eth0: 192.168.2.172 ixp0: 192.168.8.174 eth1: 192.168.2.173 local net local net Internet Internet ixp1: 192.168[...]

  • Page 78

    UC-7420/7410 User’s Manual Managing Communication 4-27 2. Create a configuration file name d “A-tun.conf” and an execut able script file nam ed “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.1[...]

  • Page 79

    5 5 Chapter 5 Programmer’s Guide This chapter includes importan t information for programmers. This following functions are covered in this chapter:  Flas h Memo ry Map  Linux Tool Chai n Introducti on  Debugging with GDB  Device API  RTC (Real Time Clock)  Buzzer  WDT (Watch Do g Timer)  UART  LCM  KeyPad  Make F[...]

  • Page 80

    UC-7420/7410 User’s Manual Programmer’s Guide 5-2 Flash Memory Map Partition sizes are hard coded into th e kernel bina ry. To chang e the partition sizes, you will need to rebuild the kernel. The flash memory map is shown in the following table. Address Size Contents 0x00000000 – 0x0005FFFF 384 KB Boot Loa der—Read ONLY 0x00060000 – 0x00[...]

  • Page 81

    UC-7420/7410 User’s Manual Programmer’s Guide 5-3 Obtaining help Use the Linux man utility to obtain help on many of the utilities provid ed by the tool chain. For example to get help on the armv5b-linux-gcc com piler, issue the command: #man armv5b-linux-gcc Cross Compiling Applications and Libraries To compile a simple C application , just us[...]

  • Page 82

    UC-7420/7410 User’s Manual Programmer’s Guide 5-4 Debugging with GDB First compile the program must with option -ggdb. Use the following steps: 1. To debug a pro gram called hello-debug on the target, use t he command: #gdbserver 192.168.4.142:2000 hello-debug This is where 2000 is the network port number on which the serv er waits for a connec[...]

  • Page 83

    UC-7420/7410 User’s Manual Programmer’s Guide 5-5 Buzzer The device node is located at /dev/console . UC-7 420/7410 suppor ts Linux standard buzzer con trol, with UC-7420 /7410’s bu zzer running at a fixed frequ ency of 100 H z. You must include <sys/kd.h> . 1. Function: KDMKTONE ioctl(fd, KDMKTONE, unsigned int arg); Description: The b[...]

  • Page 84

    UC-7420/7410 User’s Manual Programmer’s Guide 5-6 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 - Th e time you wish to ack sWatchDog peri odically. Yo u must ack the sWatchDog bef[...]

  • Page 85

    UC-7420/7410 User’s Manual Programmer’s Guide 5-7 int swtd_ack(int fd) Description: Acknowledge sWatchDog. When the user appli cation enable sWatchDog. It need to ca ll this function periodically with user predefined time in the application prog ram. Input : int fd - the file handle from swtd_open() return value. Output: OK will be zero. The ot[...]

  • Page 86

    UC-7420/7410 User’s Manual Programmer’s Guide 5-8 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/selec[...]

  • Page 87

    UC-7420/7410 User’s Manual Programmer’s Guide 5-9 exit(1); } The makefile is shown below: all: mxscaleb-gcc –o xxxx xxxx.c –lmoxalib UART The normal tty de vice node is located at /dev/ttyM0 … ttyM7 , and the m odem tty dev ice node is located at /dev/cum0 … cum7 . UC-7420/7410 suppor ts Linux standard termios contr ol. The Moxa UART De[...]

  • Page 88

    UC-7420/7410 User’s Manual Programmer’s Guide 5-10 Example to get the baud rate #include <moxadevice.h> #include <termios.h> 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 } el[...]

  • Page 89

    UC-7420/7410 User’s Manual Programmer’s Guide 5-11 KeyPad The device node is /dev/keypad . The key value is defin ed in moxade vice.h. int ioctl(fd, IOCTL_KEYPAD_HAS_PRESS, int *flag); Checks how ma ny keys have been pressed. Ar gument 3 ret urns the num ber of pressed keys. 0 means no keys w ere pressed. int ioctl(fd, IOCTL_KEYPAD_GET_KEY, int[...]

  • Page 90

    A A Appendix A System Commands Linux normal command utility collection File manager 1. cp c o p y f i l e 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 & group & user 7. chown c h a n g e f i l e o w n e r 8. chgrp c h a n g e f i l e g r o u p 9. sync sync fi[...]

  • Page 91

    UC-7420/7410 User’s Manual System Commands A-2 Process 1. kill kill process 2. ps display now running process Other 1. dmesg dump kernel log message 2. sty t o s e t s e r i a l p o r t 3. zcat dump .gz file context 4. mknod make device node 5. free display system memory usage 6. date p rint or set the system date and time 7. env run a program in[...]