Moxa Technologies W321 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
92
93
94
95
96
97
98
99
100
101
102
103
104

Ir para a página of

Bom manual de uso

As regras impõem ao revendedor a obrigação de fornecer ao comprador o manual com o produto Moxa Technologies W321. A falta de manual ou informações incorretas fornecidas ao consumidor são a base de uma queixa por não conformidade do produto com o contrato. De acordo com a lei, pode anexar o manual em uma outra forma de que em papel, o que é frequentemente utilizado, anexando uma forma gráfica ou manual electrónicoMoxa Technologies W321 vídeos instrutivos para os usuários. A condição é uma forma legível e compreensível.

O que é a instrução?

A palavra vem do latim "Instructio" ou instruir. Portanto, no manual Moxa Technologies W321 você pode encontrar uma descrição das fases do processo. O objetivo do manual é instruir, facilitar o arranque, a utilização do equipamento ou a execução de determinadas tarefas. O manual é uma coleção de informações sobre o objeto / serviço, um guia.

Infelizmente, pequenos usuários tomam o tempo para ler o manual Moxa Technologies W321, e um bom manual não só permite conhecer uma série de funcionalidades adicionais do dispositivo, mas evita a formação da maioria das falhas.

Então, o que deve conter o manual perfeito?

Primeiro, o manual Moxa Technologies W321 deve conte:
- dados técnicos do dispositivo Moxa Technologies W321
- nome do fabricante e ano de fabricação do dispositivo Moxa Technologies W321
- instruções de utilização, regulação e manutenção do dispositivo Moxa Technologies W321
- sinais de segurança e certificados que comprovam a conformidade com as normas pertinentes

Por que você não ler manuais?

Normalmente, isso é devido à falta de tempo e à certeza quanto à funcionalidade específica do dispositivo adquirido. Infelizmente, a mesma ligação e o arranque Moxa Technologies W321 não são suficientes. O manual contém uma série de orientações sobre funcionalidades específicas, a segurança, os métodos de manutenção (mesmo sobre produtos que devem ser usados), possíveis defeitos Moxa Technologies W321 e formas de resolver problemas comuns durante o uso. No final, no manual podemos encontrar as coordenadas do serviço Moxa Technologies na ausência da eficácia das soluções propostas. Atualmente, muito apreciados são manuais na forma de animações interessantes e vídeos de instrução que de uma forma melhor do que o o folheto falam ao usuário. Este tipo de manual é a chance que o usuário percorrer todo o vídeo instrutivo, sem ignorar especificações e descrições técnicas complicadas Moxa Technologies W321, como para a versão papel.

Por que ler manuais?

Primeiro de tudo, contem a resposta sobre a construção, as possibilidades do dispositivo Moxa Technologies W321, uso dos acessórios individuais e uma gama de informações para desfrutar plenamente todos os recursos e facilidades.

Após a compra bem sucedida de um equipamento / dispositivo, é bom ter um momento para se familiarizar com cada parte do manual Moxa Technologies W321. Atualmente, são cuidadosamente preparados e traduzidos para sejam não só compreensíveis para os usuários, mas para cumprir a sua função básica de informação

Índice do manual

  • Página 1

    ThinkCore W31 1/321/341 Linux User ’ s Manual Second Edition, March 2007 www .moxa.com/product MOXA Systems Co., Ltd. Tel: +886-2-2910-1230 Fax: +886-2-2910-1231 Web: www.moxa.com MOXA Technical Support World wide: support@ moxa.com[...]

  • Página 2

    ThinkCore W311/321/341 Linux 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 © 2007 Mo xa Systems Co., Ltd. All rights reserved. Reproducti o n without perm ission is prohi bited. Trademarks MOXA is a [...]

  • Página 3

    Table of Contents Chapter 1 Introduction .................................................................................................. 1-1 Overview.................................................................................................................................. 1-2 Software Arc hitecture ........................................[...]

  • Página 4

    Chapter 4 Managing Communications ........................................................................ 4-1 T elnet / FTP ................................................................................................................... .......... 4-2 DNS ..........................................................................................[...]

  • Página 5

    Appendix A System Commands ..................................................................................... A-1 busybox (V0.60.4): Linux norm al command utility collection ............................................... A-1 File manager ............................................................................................................[...]

  • Página 6

    1 1 Chapter 1 Introduction The MOXA T hinkCore W31 1/321/341 are R ISC-based ready-t o-run wir eless embedde d computers with 802.1 1a/b/g WLAN, one 10/1 00 Mbps Et her net port , an inte rnal SD socket, 1/2/ 4 RS-232/422/ 485 serial ports, two USB 2.0 host s, one relay out put channel , and pre-in stalled Linu x operating sy stem. The W31 1/321/34[...]

  • Página 7

    ThinkCore W311/321/341 Linux User’s Manual Introduction 1-2 Overview The ThinkC ore W311/32 1/341 wirel ess embedded c omputers su pport 802. 11a/b/g wirel ess LANs with data enc ryption f unctions, i ncluding the common WEP and po werful WP A and WP A2, to establish a secure transmission tunnel over a WLAN. ThinkCore W3 00 Series Em bedded Com p[...]

  • Página 8

    ThinkCore W311/321/341 Linux User’s Manual Introduction 1-3 Factory Defaul t Im age file. The use r directory sa ves the user’s settings and application. To improve system reliability, the W311/321/341 have a bu ilt-in mechanism that prevents the system from crashing. When the Li nux kerne l boots up, the kernel will mount the root fil e system[...]

  • Página 9

    ThinkCore W311/321/341 Linux User’s Manual Introduction 1-4 Software Package Boot Loader Moxa Boot Loader (v1.2 ) Kernel Linux 2.6.9 Protocol S tack ARP, PPP, CHAP, PAP, IPv4, ICMP, TCP, UDP, DHCP, FTP, SNMP V1/V3, HTTP, NTP, NFS, SMTP, SSH 1.0/2.0, S SL, Telnet, PPPoE, OpenVPN File System JFFS2, NFS, Ext2, E xt3, VFAT/FAT OS shell command Bash B[...]

  • Página 10

    2 2 Chapter 2 Getting Started In this chapter, we explain how to connect the W311/321/341, how to turn on the power, how to get started progra mming , and how to use the W311 /321/341’s other fun ctions. The following topics are covered in this chapter:  Powering on the W311/321/341  Connecting the W311/321/341 to a PC ¾ Serial Console ¾ [...]

  • Página 11

    ThinkCore W311/321/341 Linux User’s Manual Getting Started 2-2 Powering on the W311/321/341 Connect the SG wire to th e shielded contact located in the upp er lef t corner of the W311/321/341, and then power on the computer by con n ecting it to the power adaptor. It takes about 30 to 60 seconds for the system to boo t up. Once the system is read[...]

  • Página 12

    ThinkCore W311/321/341 Linux User’s Manual Getting Started 2-3 The following window will open when a conn ection has been established. To log in, t ype the Logi n name and password as re quested. The default va lues are both root : Login: root Password: root Telnet Console If you know at least one of the tw o IP addresses an d netmasks, then y ou[...]

  • Página 13

    ThinkCore W311/321/341 Linux User’s Manual Getting Started 2-4 You can proceed with configuring the network settin gs of the target compute r when you reach the bash command sh ell. Configuratio n instru ctions are gi ven in the next section. ATTENTION Serial Console Reminder Remember to choose VT100 as the terminal type. Use the cabl e CBL-4PIND[...]

  • Página 14

    ThinkCore W311/321/341 Linux User’s Manual Getting Started 2-5 Linux Users From a Linux machine, use t he “ssh” command to access the W311/321/ 341’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?[...]

  • Página 15

    ThinkCore W311/321/341 Linux User’s Manual Getting Started 2-6 2. Type #vi interfaces to edit the network configuration file with vi editor. You can configure th e Ethernet ports of the W341 for static or dynamic (DHCP) IP addresses. Static IP addresses As shown i n the table bel ow, 4 networ k addresses m ust be modi fied: address , networ k , n[...]

  • Página 16

    ThinkCore W311/321/341 Linux User’s Manual Getting Started 2-7 /etc/wireless.conf Format: DEVICE=eth1 MODE=managed ESSID=any KEY=any /etc/wireless.conf Item list: DEVICE Æ indicates your wi reless interface MODE Æ in dicates your wi reless m ode, such as ad-hoc, managed, m aster ESSID Æ indicates your wireless ESSID NAME KEY Æ indicates your [...]

  • Página 17

    ThinkCore W311/321/341 Linux User’s Manual Getting Started 2-8 Default Setting for WIRLESS LAN Dynamic Setting using DHCP iface eth1 inet static address 192.168.4 .127 network: 192.168.4 .0 netmask 255.255.255. 0 broadcast 192.168.4.2 55 iface eth1 inet dhcp After the boot settings of the LAN interface have been modified, issue the following comm[...]

  • Página 18

    ThinkCore W311/321/341 Linux User’s Manual Getting Started 2-9 Channel —Sets the channel Using iwconfig eth1 chan n el Setting Note: Infrastruct couldn’t set channel Freq —Sets the channel frequence Using iwconfi g eth1 freq Setting(G ,M,K) Note: Infrastruct coul dn’t set freq 802.1 1b,g Channel an d Frequency T able Channel Freqence 1 24[...]

  • Página 19

    ThinkCore W311/321/341 Linux User’s Manual Getting Started 2-10 140 5700 (K) 184 4920 (K) 188 4940 (K) 192 4960( K) 196 4980 (K) 8 5040 (K) 12 5060 (K) 16 5080 (K) 34 5170 (K) 38 5190 (K) 42 5210 (K) 46 5230 (K) 149 5745 (K) 153 5765 (K) 157 5785 (K) 161 5805 (K) 165 5825 (K) AuthMode —Sets the authenticatio n mode Using iwpriv eth1 set_au th S[...]

  • Página 20

    ThinkCore W311/321/341 Linux User’s Manual Getting Started 2-11 Using WPA_SUPPLICANT to Support WPA and WPA2 This embedde d computer s upports the WPA and WP A2 functions using the /bi n/wpa_suppl icant program. We wrote a shell s cript to hel p you use t his function: Step 1: Edit the ssid and psk variables in the file etc/wpa_supplicant.conf . [...]

  • Página 21

    ThinkCore W311/321/341 Linux User’s Manual Getting Started 2-12 W341 The SD slot is located on the front panel of th e W341. To install an SD card, you must fi rst re move the SD slot’s protective cover t o access the slot, and then plug the SD card direct ly into the slot. The SD card will be mounted at /mnt/sd . Detailed installation instruct[...]

  • Página 22

    ThinkCore W311/321/341 Linux 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 h ow to develop a program for the W311/3 21/341. In general, pr ogram developm ent involv es the followi ng seven steps. Step 1: Connect the W311/321 /341 to a Linu[...]

  • Página 23

    ThinkCore W311/321/341 Linux 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 y our PC to the W3 11/321/3 41 with the co nsole cable, a nd then use t he console utility to delete the file s from the W311/321/341’s flash m emor[...]

  • Página 24

    d e t r a t S g n i t t e G l a u n a M s ’ r e s U x u n i L 1 4 3 / 1 2 3 / 1 1 3 W e r o C k n i h T 2-15 NOTE Since Moxa’s tool c hain places a specially designed Makefil e in the directory /tmp/example/hello , be s ure to type the #make command from wi thin that directory. This special Makefile uses the mxscale-gcc com piler to compile the[...]

  • Página 25

    ThinkCore W311/321/341 Linux User’s Manual Getting Started 2-16 T esting Environment The tcps2 exam ple demonstrates a simple app lication program that delivers transparent, bi-directional data transm ission between t he W311/321/ 341’s serial and Ethernet ports. As illustrated in the following figure, the purpose of th is app lication is to tr[...]

  • Página 26

    ThinkCore W311/321/341 Linux User’s Manual Getting Started 2-17 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/w341/1st_application/ . Note that you need to copy [...]

  • Página 27

    d e t r a t S g n i t t e G l a u n a M s ’ r e s U x u n i L 1 4 3 / 1 2 3 / 1 1 3 W e r o C k n i h T 2-18 Uploading and Running the “tcps2-release” Program Use the following comm ands to upload tcps2-release to the W311/321/341 through an FTP connection. 1. From the PC, type: #ftp 192.168.3.127 2. Next, use the bin comma nd to set the tran[...]

  • Página 28

    ThinkCore W311/321/341 Linux User’s Manual Getting Started 2-19 4. The program should start running in the back ground. Use the #ps –ef command to check if the tcps2 program is actually runn ing in the background. #ps // 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 0 [...]

  • Página 29

    ThinkCore W311/321/341 Linux User’s Manual Getting Started 2-20 NOTE Use the kill -9 command for PID 728 to terminate this p rogram: #kill -9 %728 Testing Procedure Summary 1. Compile tcps2.c (#make ) . 2. Upload and run tcps2-release i n the backgr ound (#./tcps2-release &) . 3. Check that the process is running (#jobs or #ps -ef) . 4. Use a[...]

  • Página 30

    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 W311/321/341 u nits. The following topics are covered in this chapter:  System Version Infor[...]

  • Página 31

    ThinkCore W311/321/341 Linux User’s Manual Managing Embedded Linux 3-2 System Version Information To determine the hardware capability of your W311 /321/341, and wh at kind of software functions are supported , check the version numbers of your W311/321/34 1’s hardware, kernel, and user file system. Contact Moxa to determine th e hardware versi[...]

  • Página 32

    ThinkCore W311/321/341 Linux User’s Manual Managing Embedded Linux 3-3 Since different Flash dis ks ha ve different sizes, it is a good idea to chec k the size of your Flash disk before upgrading the firmware, o r b efore using the disk to store your applicatio n and data files. Use the #df –h command to li st the size of eac h memory block and[...]

  • Página 33

    ThinkCore W311/321/341 Linux User’s Manual Mana ging Embedded Linux 3-4 2. Type the following commands to use the W31 1/321/341’s built-in FTP client to transfer the firmware file (W341 -x.x.x.frm ) from the PC to the W311/321/341: /mnt/ramdisk> ftp <destination PC’s IP> Login Name: xxxx Login Password: xxxx ftp> bin ftp> get -[...]

  • Página 34

    ThinkCore W311/321/341 Linux User’s Manual Managing Embedded Linux 3-5 ATTENTION The upfirm utility will reboot your target after the upgrade is OK. Loading Factory Default s To load the the factory default settings, you must press the reset-to-default button for more than 5 seconds. All files in the /home & /etc directories will be destroyed[...]

  • Página 35

    ThinkCore W311/321/341 Linux User’s Manual Mana ging Embedded Linux 3-6 Deploying the User Directory to Additional W31 1/321/341 Unit s For some applications, you m ay need to ghost one W311/321/ 341 user file system t o other W311/321/341 units. Back up the user file syst em to a PC (refer to the previous subsection, Backing Up the User File Sys[...]

  • Página 36

    ThinkCore W311/321/341 Linux User’s Manual Mana ging Embedded Linux 3-7 Type the command “ps –ef” to list all processes c urrently running. 192.168.3.127 – PuTTY root@Moxa:~# cd /etc root@Moxa:/etc# ps -ef PID Uid VmSize Stat Command 1 root 532 S init [3] 2 root SWN [ksoftirqd/0] 3 root SW< [events/0] 4 root SW< [khelper] 13 root SW[...]

  • Página 37

    ThinkCore W311/321/341 Linux User’s Manual Mana ging Embedded Linux 3-8 The enabled daemons will be available after you reboot the system. 192.168.3.127 – PuTTY root@Moxa:~# ps -ef PID Uid VmSize Stat Command 1 root 532 S init [3] 2 root SWN [ksoftirqd/0] 3 root SW< [events/0] 4 root SW< [khelper] 13 root SW< [kblockd/0] 14 root SW [kh[...]

  • Página 38

    ThinkCore W311/321/341 Linux User’s Manual Mana ging Embedded Linux 3-9 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:/ect/rc.d/rc3.d# ln –s /home/tcps2-release S60tcps2 root@Moxa:/ect/rc.d/rc3.d# ls S19nfs-common S25nfs-user-server S99rmno[...]

  • Página 39

    ThinkCore W311/321/341 Linux User’s Manual Mana ging Embedded Linux 3-10 The following figure illustrates how to update thesystem time and set the RTC tim e. 192.168.3.127 – PuTTY root@Moxa:~# date Fri Jun 23 23:30:31 CST 2000 root@Moxa:~# hwclock Fri Jun 23 23:30:35 2000 -0.557748 seconds root@Moxa:~# date 120910002004 Thu Dec 9 10:00:00 CST 2[...]

  • Página 40

    ThinkCore W311/321/341 Linux User’s Manual Mana ging Embedded Linux 3-11 How to run the shell script automa tically when the kernel boots up Copy the example shell script fixtime to directory /etc/init.d , and then use chmod 755 fixtime to change the shell script m ode. Next, use vi editor to edit the file /etc/inittab . Add the following line to[...]

  • Página 41

    4 4 Chapter 4 Managing Communications In this chapt er, we ex plain how to configure t he W311/321/ 341’s vari ous comm unication functions. The following topics are covered in this chapter:  Telnet / FTP  DNS  Web Service — Apache  Installing PHP for Apache Web Service  IPTABLES  NAT ¾ NAT Example ¾ Enabling NAT at Bootup ?[...]

  • Página 42

    ThinkCore W311/321/341 Linux User’s Manual Managing Communications 4-2 Telnet / FTP In addition to suppo rting Telnet client/server and FTP client/server, the W311/321/341 also support SS H and sftp cli ent/server. To enable or di sable the Telnet/ftp server, you first need to edit the file /etc/inetd.conf . Enabling the Telnet/ftp server The fol[...]

  • Página 43

    ThinkCore W311/321/341 Linux User’s Manual Managing Communications 4-3 /home/httpd/cgi-bin/ Before you modify the homepage, use a browser (such as Microsoft Intern et Explorer or Mozilla Firefox) from your PC to test if the Apach e Web Server is working. Type the LAN1 IP address in the browser’s address box to op en the homepage. E.g. , if the [...]

  • Página 44

    ThinkCore W311/321/341 Linux User’s Manual Managing Communications 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 f unction is e nabled b y default. If y ou want t o disable the f unction, m odify the fil e /etc/apache/conf/httpd.conf . When you d[...]

  • Página 45

    ThinkCore W311/321/341 Linux User’s Manual Mana ging Communications 4-5 Step 2: Type ‘upramdisk’ to get the free space ram disk to save t he package. 192.168.3.127 – PuTTY root@Moxa:/bin# upramdisk root@Moxa:/bin# df -h Filesystem Size Used Available Use% Mounted on /dev/mtdblock2 8.0M 6 .0M 2.0M 75% / /dev/ram0 499.0k 18.0k 456.0k 4% /var [...]

  • Página 46

    ThinkCore W311/321/341 Linux User’s Manual Managing Communications 4-6 Step 5: Run ‘install.sh’ and select to install php 192.168.3.127 – PuTTY root@Moxa:/mnt/ramdisk# ./install.sh Press the number: 1. Install PHP package 2. Uninstall PHP package 3. Exit. 1 Start to install PHP. Please wait ... Starting web server: apache. PHP install suces[...]

  • Página 47

    ThinkCore W311/321/341 Linux User’s Manual Managing Communications 4-7 IPTABLES IPTABLES is an administrative tool for setting up , maintai ning, and inspecting th e Linux kernel’s IP packet filter rule tables. Seve ral different tables are defined, with each table containing bu ilt-in chains and user-defi ned chains. Each chain is a list of ru[...]

  • Página 48

    ThinkCore W311/321/341 Linux User’s Manual Managing Communications 4-8 The W311/321/341 support th e follo wing sub-modules. Be sure to use the m odule that matches 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[...]

  • Página 49

    ThinkCore W311/321/341 Linux User’s Manual Managing Communications 4-9 NOTE The W311/321/341 do NOT suppo rt IPV6 and ipchain s. The basic syntax t o enable an d load an IPT ABLES module is as follows: #lsmod #insmod ip_tables #insmod iptable_filter Use lsmod to check if t he ip_tables m odule has al ready been loade d in the W31 1/321/341 uni t.[...]

  • Página 50

    ThinkCore W311/321/341 Linux User’s Manual Mana ging Communications 4-10 Define policy for chain rules Usage: # iptables [-t tables] [-P] [INPUT, OUTPUT, FORWARD, PREROUTING, OUTPUT, POSTROUTING] [ACCEPT, DROP] -P: Set the policy for the chain to the given target. INPUT: For packets coming into the W311/321/341. OUTPUT: For locally-generated pack[...]

  • Página 51

    ThinkCore W311/321/341 Linux User’s Manual Mana ging Communications 4-11 Example 8: Drop all packets from MAC address 01:02:03:04:05:06. # iptables –A INPUT –i eth0 –p all –m mac -–mac-source 01:02:03:04:05:06 –j DROP NOTE: In Example 8, rem ember to issue the command #insmod ipt_mac first to load module ipt_mac . NAT NAT (Network Add[...]

  • Página 52

    ThinkCore W311/321/341 Linux User’s Manual Mana ging Communications 4-12 Enabling NA T at Bootup In most real world situatio ns, you will want to use a simple shell scri pt to enable NAT when the W341 boots up. The followin g script is an example. #!/bin/bash # If you put this shell script in the /home/nat.sh # Remember to chmod 744 /home/nat.sh [...]

  • Página 53

    ThinkCore W311/321/341 Linux User’s Manual Mana ging Communications 4-13 optional. #pppd connect ‘chat -v “ “ ATDT5551212 CONNECT ogin: username word: password ’ /dev/ttyM0 115200 debug crtscts modem defaultroute If the PPP server does not pr ompt for the usernam e and password, the command sh ould be entered as follows. Replace username [...]

  • Página 54

    ThinkCore W311/321/341 Linux User’s Manual Mana ging Communications 4-14 Example 2: Connecting to a PPP server over a hard-w ired link If a username and password are not re quired, use the following command (note t hat noipdefault is optional): #pppd connect ‘chat –v “ “ “ ‘ noipdefault /dev/ttyM0 19200 crtscts If a username and passw[...]

  • Página 55

    ThinkCore W311/321/341 Linux User’s Manual Managing Communications 4-15 This should show three routes, so mething like this: Kernel routing table Destination Gateway Genmask Flags Metric Ref Use iface 129.67. 1.165 0.0.0. 0 255.255 .255.255 UH 0 0 6 ppp0 127.0.0. 0 0.0.0. 0 255.0.0. 0 U 0 0 0 lo 0.0.0.0 12 9.67.1. 165 0.0.0.0 UG 0 0 6298 ppp0 If [...]

  • Página 56

    ThinkCore W311/321/341 Linux User’s Manual Managing Communications 4-16 4. Edit the file /etc/ppp/pap-secrets and ad d the foll owing: “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. 5. Edit th[...]

  • Página 57

    ThinkCore W311/321/341 Linux User’s Manual Managing Communications 4-17 6. Add one of tw o fil e s: /etc/ppp/options.eth0 or /etc/ppp/options.eth1 . The choice depends on which LAN is connected to t he ADSL modem . If you use LAN1 to connect to th e ADSL modem , then add /etc/ppp/options.eth0 . If you use LAN2 to c onnect to the ADSL modem, then [...]

  • Página 58

    ThinkCore W311/321/341 Linux User’s Manual Managing Communications 4-18 NOTE Click on the following links for more info rmation about NFS: http://www.tldp.org/HOWTO/NFS-HOWTO/index.html http://nfs.sourceforg e.net/nfs-howto/client.html http://nfs.sourceforge.ne t/nfs-h owto/server.html Setting up the W31 1/321/341 as an NFS Client The followin g [...]

  • Página 59

    ThinkCore W311/321/341 Linux User’s Manual Managing Communications 4-19 3: sysUpTime.0 (timeticks) 0 days 03h:50m:11s.00th (1381100) 4: sysContact.0 (octet string) Moxa Systems Co., LDT. 5: sysName.0 (octet string) Moxa 6: sysLocation.0 (octet string) Unknown 7: sysServices.0 (integer) 6 8: ifNumber.0 (int eger) 6 9: ifIndex.1 (integer) 1 10: ifI[...]

  • Página 60

    ThinkCore W311/321/341 Linux User’s Manual Managing Communications 4-20 70: ifInUcastPkts.2 (counter) 28224 71: ifInUcastPkts.3 (counter) 0 72: ifInUcastPkts.4 (counter) 0 73: ifInUcastPkts.5 (counter) 0 74: ifInUcastPkts.6 (counter) 0 75: ifInNUcastPkts.1 (counter) 0 76: ifInNUcastPkts.2 (counter) 0 77: ifInNUcastPkts.3 (counter) 0 78: ifInNUcas[...]

  • Página 61

    ThinkCore W311/321/341 Linux User’s Manual Managing Communications 4-21 137: ifSpecific.3 (object identifier) (null-oid) zeroDotZero 138: ifSpecific.4 (object identifier) (null-oid) zeroDotZero 139: ifSpecific.5 (object identifier) (null-oid) zeroDotZero 140: ifSpecific.6 (object identifier) (null-oid) zeroDotZero 141: atIfIndex.1.192.168. 27.139[...]

  • Página 62

    ThinkCore W311/321/341 Linux User’s Manual Managing Communications 4-22 204: ipNetToMediaPhysAddress.1.192. 168. 27.139 (octet string) 00.90.E8.10. 02.41 (hex) 205: ipNetToMediaPhysAddress.2.192. 168. 4.127 (octet string) 00.90.E8.10. 02.40 (hex) 206: ipNetToMediaNetAddress.1.192.168.27. 13 9 (ipaddress) 192.168.27.139 207: ipNetToMediaNetAddress[...]

  • Página 63

    ThinkCore W311/321/341 Linux User’s Manual Managing Communications 4-23 271: tcpConnLocalAddress.192.168. 27.139.1025.0.0. 0.0.0 (i paddr ess) 192.168.27.139 272: tcpConnLocalAddress.192.168. 4.127.1025.0.0. 0.0.0 (ipaddr ess) 192.168.4.127 273: tcpConnLocalAddress.192.168. 27.139.2049.0.0. 0.0.0 (i paddr ess) 192.168.27.139 274: tcpConnLocalAddr[...]

  • Página 64

    ThinkCore W311/321/341 Linux User’s Manual Managing Communications 4-24 338: tcpConnRemPort. 192.168.4.127. 9. 0.0.0.0.0 (integer) 0 339: tcpConnRemPort. 192.168.27.139. 111. 0.0.0.0.0 (int eger) 0 340: tcpConnRemPort. 192.168.4.127. 111. 0.0.0.0.0 (integer) 0 341: tcpConnRemPort. 192.168.27.139. 80. 0.0.0.0.0 (integer) 0 342: tcpConnRemPort. 192[...]

  • Página 65

    ThinkCore W311/321/341 Linux User’s Manual Managing Communications 4-25 405: rs232PortOutSigNum ber .2 (integer) 2 406: rs232PortOutSigNum ber .3 (integer) 2 407: rs232PortOutSigNum ber .4 (integer) 2 408: rs232PortInSpeed.1 (integer) 38400 409: rs232PortInSpeed.2 (integer) 38400 410: rs232PortInSpeed.3 (integer) 38400 411: rs232PortInSpeed.4 (in[...]

  • Página 66

    ThinkCore W311/321/341 Linux User’s Manual Managing Communications 4-26 472: rs232OutSigPortIndex.1. 4 (integer) 1 [1] 473: rs232OutSigPortIndex.2. 4 (integer) 2 [2] 474: rs232OutSigPortIndex.3. 4 (integer) 3 [3] 475: rs232OutSigPortIndex.4. 4 (integer) 4 [4] 476: rs232OutSigNam e.1.1 (integer) rts(1) 477: rs232OutSigNam e.2.1 (integer) rts(1) 47[...]

  • Página 67

    ThinkCore W311/321/341 Linux User’s Manual Managing Communications 4-27 OpenVPN OpenVPN provides two types of tunn els for users to implement VPNS: Routed IP Tu nnels and Bridged Ethernet Tunnels . T o begin wit h, check to make s ure that the sy stem has a virtual device /dev/net/tun . If not, issue the following command: # mknod /dev/net/tun c [...]

  • Página 68

    ThinkCore W311/321/341 Linux User’s Manual Managing Communications 4-28 NETMASK= BROADCAST= # it is not a great idea but this system doesn’t support # /etc/sysconfig/network-scripts/ifcfg-eth1 ifcfg_vpn() { while read f1 f2 f3 f4 r3 do if [ “$f1” = “iface” -a “$f2” = “$iface” -a “$f3” = “inet” -a “$f4” = “static”[...]

  • Página 69

    ThinkCore W311/321/341 Linux User’s Manual Managing Communications 4-29 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 forwards it to other ports. i=`expr 0` while : do # generate a tap0 interface [...]

  • Página 70

    ThinkCore W311/321/341 Linux User’s Manual Managing Communications 4-30 ;; restart) stop start ;; *) echo “Usage: $0 [start|stop|restart]” exit 1 esac exit 0 #---------------------------------- end ----------------------------- Create link sy mbols to ena ble this scri pt at boot t ime: # ln -s /etc/openvpn/openvpn-bridge /etc/rc.d/rc3.d/S32v[...]

  • Página 71

    ThinkCore W311/321/341 Linux User’s Manual Managing Communications 4-31 5. On each OpenVPN m achine, check the routing table by typing the command: # route Destination Gateway Genmsk Flags Metric Ref Use Iface 192.168 .4.0 * 255.255 .255.0 U 0 0 0 br0 192.168 .2.0 * 255.255 .255.0 U 0 0 0 br0 192.168 .8.0 * 255.255. 255.0 U 0 0 0 eth0 Interface e[...]

  • Página 72

    ThinkCore W311/321/341 Linux User’s Manual Managing Communications 4-32 2. The config uration proced ure is almost t he sa me as for the previous exam ple. The only difference is that you will need to comment out the parameter “up” in “/etc/openvpn/A- tap 0-br.conf” an d “/etc/openvpn/B-t ap0-br.conf”. Setup 3: Routed IP 1. Set up fou[...]

  • Página 73

    ThinkCore W311/321/341 Linux User’s Manual Managing Communications 4-33 # value after “-net” is the subnet behind the remote peer route add -net 192.168.2.0 netmask 255.255.255.0 gw $5 #--------------------------------- end ----------------------------- Note that the param eter “ifconfig” defines t he firs t argument as the local i nterna[...]

  • Página 74

    5 5 Chapter 5 Tool Chains for Application Development This chapter describes how to install a tool chain in the host computer that you use to develop your applications. In addition , the process of performing cross-platform development and debugg ing are also introduce d. For clarity , the W311/32 1/341 embedde d computer i s called a target comput[...]

  • Página 75

    ThinkCore W311/321/341 Linux User’s Manua l Tool Chains for Application Development 5-2 Linux Tool Chain The Linux tool chain contains a su ite of cross compilers and other tools, as well as t he libraries and header files that are nece ss ary to compile your application s . These t ool chain components must be instal led in your h ost computer ([...]

  • Página 76

    ThinkCore W311/321/341 Linux User’s Manua l Tool Chains for Application Development 5-3 The following cross compiler tools are provided: ar Manages archives (static libraries) as Assembler c++, g++ C++ com piler cpp C preprocessor gcc C compiler gdb Debugge r ld Linker nm Lists symbols from object files objcopy Copies and tra nslates object fi le[...]

  • Página 77

    ThinkCore W311/321/341 Linux User’s Manua l Tool Chains for Application Development 5-4 Windows Tool Chain The Windows tool chain is a cross devel opment enviro nment that sim ulates the Linu x root fil e system, allowing users to develop app lications in a Windows PC environment. The following figure shows an exam ple of what the tool chain look[...]

  • Página 78

    ThinkCore W311/321/341 Linux User’s Manua l Tool Chains for Application Development 5-5 1. Double click on the tool chain file to start the installtion process, and choose Next . 2. Browse to the directory where yo u pr efer to set the root directory for th e to ol chain. Options of All Users and Unix are recommended. The n, choose Next . If you [...]

  • Página 79

    ThinkCore W311/321/341 Linux User’s Manua l Tool Chains for Application Development 5-6 3. Navigate t o the direct ory where the packages of t he tool chai n reside. By de fault, it is on the CD-ROM: tool-chainwindows . Choose Next to proceed. It may t ake anywhere from 5 to 20 m inutes to c heck the packages in the CD-R OM. 4. All packages ar[...]

  • Página 80

    ThinkCore W311/321/341 Linux User’s Manua l Tool Chains for Application Development 5-7 y Base Category: List all packages that will be installed by default (along with any dependencies). If you view t he Base column for t he Base cate gory, you sh ould see eve ry package selected for installation. y Packages: In the packages listing field, pack [...]

  • Página 81

    ThinkCore W311/321/341 Linux User’s Manua l Tool Chains for Application Development 5-8 6. Checkmark Create icon o n Desktop t o place a Moxa BASH Shell icon on your desktop, and then click on Finish . 7. Click on OK to complete the installation process.[...]

  • Página 82

    ThinkCore W311/321/341 Linux User’s Manua l Tool Chains for Application Development 5-9 Using the BASH Shell A command-line interface is used to develop app lications with the tool chain. To access the command line, you need t o launch a B ASH shell wi ndow. To open a BASH shell window, choose Start Menu Æ Programs Æ UC Tool C hain Æ Moxa Bash[...]

  • Página 83

    ThinkCore W311/321/341 Linux User’s Manua l Tool Chains for Application Development 5-10 Compilation for Applications Windows tool chain is a cross com piler that can be used to compil e Linux so urce c ode on a Windows operat ing system, al lowing progra mmers to deve lop projects on a Windows-ba sed PC. In this section, we describe the procedur[...]

  • Página 84

    ThinkCore W311/321/341 Linux User’s Manua l Tool Chains for Application Development 5-11 Next, enter the hello directory and invo ke the make program that will execute the compilation instructions written in the Makefile to co mpile the hello project. /hello drwxrwx--- 7 Jared_Wu 4294967295 0 Nov 4 11:10 etc drwx------ 2 Jared_Wu mkpasswd 0 Nov 4[...]

  • Página 85

    ThinkCore W311/321/341 Linux User’s Manua l Tool Chains for Application Development 5-12 On-Line Debugging with Insight Insight is a graphical user inte rface that accompanies GDB , the GNU Debugger was writ ten in Tcl/Tk by pe ople worki ng at Red Hat, Inc., and C ygnus So lutions. Red Hat was ge nerous enough to make Insight available for publi[...]

  • Página 86

    6 6 Chapter 6 Programmer’s Guide This chapter includes importan t information for programmers. The following functions are covered in this chapter:  Flash Memory Map  Device API  RTC (Real Time Clock)  Buzzer  WDT (Watch Dog Timer)  UART  DO[...]

  • Página 87

    ThinkCore W311/321/341 Linux User’s Manual Programmer’s Guide 6-2 Flash Memory Map Partition sizes are hard coded into th e kernel bina ry. To change the partition sizes, you will need to rebuild the kernel. The flash memory map is shown in the following table. Address Size Contents 0x00000000 – 0x0003FFFF 256 KB Boot Loader—Read ONLY 0x000[...]

  • Página 88

    ThinkCore W311/321/341 Linux User’s Manual Programmer’s Guide 6-3 Buzzer The device node is located at /dev/console . The W311/321/341 support Linu x standard buzzer control, with the W311/321/3 41’s buzzer running at a fixe d frequency of 100 Hz. You must include <sys/kd.h> . Function: KD M KTO NE ioctl(fd, KDMKTONE, unsigned int arg);[...]

  • Página 89

    ThinkCore W311/321/341 Linux User’s Manual Programmer’s Guide 6-4 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, fro m the swtd_op en() return valu e. unsigned long time - Th e time you wish to ack sWatchDog periodica lly. You must ack[...]

  • Página 90

    ThinkCore W311/321/341 Linux User’s Manual Programmer’s Guide 6-5 int swtd_ack(int fd) Description Acknowledge sWatchDog. When the user applica tion enable sWatchDog. It need to call this function periodically with user pr ed efined time in the application program. Input int fd - the file handle fro m swtd_open() return value. Output OK will be[...]

  • Página 91

    ThinkCore W311/321/341 Linux User’s Manual Programmer’s Guide 6-6 } The makefile is shown below: all: arm-linux-gcc –o xxxx xxxx.c –lmoxalib Example 2: #include <stdio.h> #include <stdlib.h> #include <signal.h> #include <string.h> #include <sys/stat.h> #include <sys/ioctl.h> #include <sys/select.h> [...]

  • Página 92

    ThinkCore W311/321/341 Linux User’s Manual Programmer’s Guide 6-7 The makefile is shown below: all: arm-linux-gcc –o xxxx xxxx.c –lmoxalib UART The normal tty de vice node is located at /dev/ttyM0 … ttyM3 . The W311/321/341 suppo rt Linux standard termios contro l. Th e Moxa UART Device API allows you to configure ttyM0 to ttyM3 as RS-232[...]

  • Página 93

    ThinkCore W311/321/341 Linux User’s Manual Programmer’s Guide 6-8 if ( (term.c_cflag & (CBAUD|CBAUDEX)) != B4000000 ) { // follow the standard termios baud rate define } else { ioctl(fd, MOXA_GET_SPECIAL_BAUD_RATE, &speed); } Baudrate inaccuracy Divisor = 921600/Targ et Baud Rate. (Only Intege r part) ENUM = 8 * (9 21600/Targer - Div is[...]

  • Página 94

    7 7 Chapter 7 Software Lock “Software Lock” is an innovative technology develop ed by the Moxa engineering team. It can be adopted by a system integrator or developer t o protect his applications fr om being co pied. An application is compile d into a binary format bou nd to the em bedded com puter and the operating system (OS) that the applica[...]

  • Página 95

    8 8 Chapter 8 UC Finder UC Finder c omes in han dy if you for get the IP addre ss of the target c omputer whi le you have a demand for troublesho o ting field problems. This utility works by sending a broadcast message over the LAN to search for IP addresses of targ et computers . Two versions of UC Finde r are provided. The GUI version work s in W[...]

  • Página 96

    ThinkCore W311/321/341 Linux User’s Manual UC Finder 8-2 Windows UC Finder The UC Finder utility is used to search the LAN or intranet for Moxa embedded computers. Installing the Sof tware 1. Once the Setup program starts running, click on Next to proceed. 2. Click on Next when the Select Addi ti onal Tools window opens to proceed with th e insta[...]

  • Página 97

    ThinkCore W311/321/341 Linux User’s Manual UC Finder 8-3 3. Click on Next to install program files in the default dir ectory, or select an alternative location. 4. Click on Finish to complete the installation of UC Finder. Broadcast Search The Broadcast Search function is used to locate all W311/32 1/341 units t hat ar e connected to the same LAN[...]

  • Página 98

    ThinkCore W311/321/341 Linux User’s Manual UC Finder 8-4 1. Click o n the Broadcast Sear ch button to start searching. 2. The Searching window displays the Model , MA C Ad dress , and IP Address of devices that were located.. 3. When the search is complete, the same information is displayed in the UC Finder window. NOTE UC Finde r is designe d to[...]

  • Página 99

    A A Appendix A System Commands busybox (V0.60.4): Linux normal command utility collection File manager 1. cp copy file 2. ls list file 3. ln make symbolic link file 4. mount mount and check file system 5. rm delete file 6. chmod change file owner & group & user 7. chown chan ge file owner 8. chgrp change file group 9. sync sync file system,[...]

  • Página 100

    ThinkCore W311/321/341 Linux 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 to set serial port 3. zcat dump .gz f ile context 4. mknod make device node 5. free display system memory usage 6. date print or set the system date and time 7. env run a progr[...]

  • Página 101

    B B Appendix B Service Information This appen dix shows y ou how to co ntact Moxa for inform ation about t his and othe r product s, and how to repo rt problems. The followin g topics are c overed in thi s appendix:  MOXA Internet Services  Problem Report Form  Product Return Procedure[...]

  • Página 102

    ThinkCore W311/321/341 Linux User’s Manual Service Information B-2 MOXA Internet Services Customer satisfaction is our num b er one concern, and to ensure that customers receive the full benefit of our products, Moxa Internet Services has bee n set up to p rovide technical s upport, dri ver updates, product infor mation, and user’s manual updat[...]

  • Página 103

    ThinkCore W311/321/341 Linux User’s Manual Service Information B-3 Problem Report Form MOXA ThinkCore W31 1/321/341 Customer name: Comp any: T el: Fax: Email: Date: 1. Moxa Product:  ThinkCore W31 1  ThinkCore W3 21  ThinkC ore W34 1 2. Serial Number: _________ __ ______ Problem Desc ription: Please describe the sympt oms of the pro blem[...]

  • Página 104

    ThinkCore W311/321/341 Linux User’s Manual Service Information B-4 Product Return Procedure For product repair, exc hange, or re fund, the customer m ust:  Provide e vidence of origi nal purchase.  Obtain a Product Return Agreement (PRA) from the sales representative or dealer.  Fill out the Problem Report Fo rm (PRF). Include as much de[...]