Moxa Technologies W311 User Manual

Moxa Technologies W311 User Manual

Linux
Hide thumbs Also See for W311:
Table of Contents

Advertisement

Quick Links

W311/321/341 Linux
User's Manual
Seventh Edition, July 2009
www.moxa.com/product
© 2009 Moxa Inc. All rights reserved.
Reproduction without permission is prohibited.

Advertisement

Table of Contents
loading
Need help?

Need help?

Do you have a question about the W311 and is the answer not in the manual?

Questions and answers

Summary of Contents for Moxa Technologies W311

  • Page 1 W311/321/341 Linux User’s Manual Seventh Edition, July 2009 www.moxa.com/product © 2009 Moxa Inc. All rights reserved. Reproduction without permission is prohibited.
  • Page 2: Copyright Notice

    W311/321/341 Linux 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.
  • Page 3: Table Of Contents

    Journaling Flash File System (JFFS2) ................1-3 Software Package ......................1-4 Chapter 2 Getting Started .....................2-1 Powering on the W311/321/341....................2-2 Connecting the W311/321/341 to a PC..................2-2 Serial Console....................... 2-2 Telnet Console......................2-3 SSH Console......................... 2-4 Configuring the Ethernet Interface ..................2-5 Modifying Network Settings with the Serial Console ..........
  • Page 4 NAT Example......................4-11 Enabling NAT at Bootup .................... 4-12 Dial-up Service—PPP......................4-12 PPPoE ............................ 4-16 NFS (Network File System)....................4-18 Setting up the W311/321/341 as an NFS Client ............4-18 Mail............................4-19 SNMP ............................ 4-19 OpenVPN..........................4-27 Chapter 5 Tool Chains for Application Development..........5-1 Linux Tool Chain ........................
  • Page 5: Chapter 1 Introduction

    USB 2.0 hosts, one relay output channel, and pre-installed Linux operating system. The W311/321/341 offer high performance communication and unlimited storage in a super compact, palm-size ARM9 box. The W300 Series is the right solution for embedded applications that are used in hard-to-wire environments and that require a large amount of memory, but that must be housed in a small space without sacrificing performance.
  • Page 6: Overview

    A 16 MB NOR Flash ROM and on-board SDRAM (64 MB for W341 and 32 MB for W311/321) give you enough memory to install your application software directly on the embedded computer. In addition, dual LAN ports are built right into the RISC CPU.
  • Page 7: Journaling Flash File System (Jffs2)

    The W311/321/341’s built-in Flash ROM is partitioned into Boot Loader, Linux Kernel, Root File System, and User directory partitions. In order to prevent user applications from crashing the Root File System, the W311/321/341 use a specially designed Root File System with Protected Configuration for emergency use. This Root File System comes with serial and Ethernet communication capability for users to load the Factory Default Image file.
  • Page 8: Software Package

    W311/321/341 Linux User’s Manual Introduction Software Package Boot Loader Moxa Boot Loader (v1.2) Linux 2.6.9 Kernel Protocol Stack ARP, PPP, CHAP, PAP, IPv4, ICMP, TCP, UDP, DHCP, FTP, SNMP V1/V3, HTTP, NTP, NFS, SMTP, SSH 1.0/2.0, SSL, Telnet, PPPoE, OpenVPN...
  • Page 9: Chapter 2 Getting Started

    Getting Started Chapter 2 In this chapter, we explain how to connect the W311/321/341, how to turn on the power, how to get started programming, and how to use the W311/321/341’s other functions. The following topics are covered in this chapter:...
  • Page 10: Powering On The W311/321/341

    Once the system is ready, the Ready LED will light up. NOTE After connecting the W311/321/341 to the power supply, it will take about 30 to 60 seconds for the operating system to boot up. The green Ready LED will not turn on until the operating system is ready.
  • Page 11: Telnet Console

    PC’s IP address and netmask so that your PC is on the same subnet as one of W311/321/341’s two LAN ports. For example, if you connect to LAN 1, you can set your PC’s IP address to 192.168.3.126 and netmask to 255.255.255.0. If you connect to the WIRLESS LAN, you can set your PC’s IP address to 192.168.4.126 and netmask to 255.255.255.0 using a wirless...
  • Page 12: Ssh Console

    The W311/321/341 support an SSH Console to provide users with better security options. Windows Users Click on the link http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html to download PuTTY (free software) to set up an SSH console for the W311/321/341 in a Windows environment. The following figure shows a simple example of the configuration that is required.
  • Page 13: Configuring The Ethernet Interface

    NOTE SSH provides better security compared to Telnet for accessing the W311/321/341’s console utility over the network. Configuring the Ethernet Interface The network settings of the W311/321/341 can be modified with the serial console port, or online over the network.
  • Page 14: Modifying Network Settings With The Serial Console

    255.255.255.0. Dynamic IP addresses By default, the W311/321/341 are configured for “static” IP addresses. To configure one or both LAN ports to request an IP address dynamically, replace static with dhcp and then delete the address, network, netmask, and broadcast lines.
  • Page 15: Configuring The Wlan

    W311/321/341 unit boots up. You may also use the load_wlan command to force your wireless to run the config file and set up your wireless LAN card after the W311/321/341 unit is already up and running. The /etc/wireless.conf file format is shown below: /etc/wireless.conf Format:...
  • Page 16 The default WIRLESS LAN IP address is 192.168.4.127. Dynamic IP addresses: By default, the W311/321/341 are configured for “static” IP addresses. To configure one or both LAN ports to request an IP address dynamically, replace static with dhcp and then delete the address, network, netmask, and broadcast lines.
  • Page 17 W311/321/341 Linux User’s Manual Getting Started SSID—Sets the softAP SSID Using iwconfig eth1 essid Setting Setting Any 32-byte string NetworkType—Sets the wireless operation mode Using iwconfig eth1 mode Setting Setting Explanation managed Infrastructure mode (uses access points to transmit data)
  • Page 18 W311/321/341 Linux User’s Manual Getting Started 802.11a Channel and Frequency Table Channel Freqence 5180 (K) 5200 (K) 5220 (K) 5240 (K) 5260 (K) 5280 (K) 5300 (K) 5320 (K) 5500 (K) 5520 (K) 5540 (K) 5560 (K) 5580 (K) 5600 (K)
  • Page 19: Using Wpa_Supplicant To Support Wpa And Wpa2

    W311/321/341 Linux User’s Manual Getting Started AuthMode—Sets the authentication mode Using iwpriv eth1 set_auth Setting Setting Explanation OPEN SHARED AUTO (default) KeyStr—Sets Key Support string key and hex key Encryp Type—Just Support NONE, WEP64 and WEP128 depend on your key length...
  • Page 20: Sd Slot And Usb For Storage Expansion

    The following steps show you how to install SD card into the W311/321/341. W311/321 The SD slot is located on the right side of the W311/321 enclosure. To install an SD card, you must first remove the SD slot’s protective cover to access the slot, and then plug the SD card directly into the slot.
  • Page 21: Test Program-Developing Hello.c

    Test Program—Developing Hello.c In this section, we use the standard “Hello” programming example to illustrate how to develop a program for the W311/321/341. In general, program development involves the following seven steps. Step 1: Connect the W311/321/341 to a Linux PC.
  • Page 22: Installing The Tool Chain (Linux)

    GNU Tool Chain. Fedora core or compatible versions are recommended. The Tool Chain requires approximately 100 MB of hard disk space on your PC. The W311/321/341 Tool Chain software is located on the W311/321/341 CD. To install the Tool Chain, insert the CD into your PC and then issue the following commands: #mount/dev/cdrom /mnt/cdrom /mnt/cdrom/tool-chain/W321.341.315.325.345_IA240.241_UC-7112PLUS/linux/install.sh...
  • Page 23: Compiling Hello.c

    [root@localhost hello]# _ Next, execute make to generate hello-release and hello-debug, which are described below: hello-release—an ARM platform execution file (created specifically to run on the W311/321/341) hello-debug—an ARM platform GDB debug server execution file (see Chapter 5 for details about the GDB debug tool).
  • Page 24: Developing Your First Application

    PC 1 and the W311/321/341 through an RS-232 connection. At the remote site, data can be transferred between the W311/321/341’s Ethernet port and PC 2 over an Ethernet connection.
  • Page 25 W311/321/341 Linux User’s Manual Getting Started root@server11:/home/w341/1st_application [root@server11 1st_application]# pwd /home/w341/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/arm-linux/bin/arm-linux-gcc -o tcps2-release tcps2.c...
  • Page 26: Uploading And Running The "Tcps2-Release" Program

    W311/321/341 Linux User’s Manual Getting Started Uploading and Running the “tcps2-release” Program Use the following commands 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 command to set the transfer mode to Binary, and the put command to initiate the file transfer: ftp>...
  • Page 27 W311/321/341 Linux User’s Manual Getting Started 4. The program should start running in the background. Use the command to check if #ps –ef the tcps2 program is actually running in the background. #ps // use this command to check if the program is running 192.168.3.127 - PuTTY...
  • Page 28: Testing Procedure Summary

    3. Check that the process is running (#jobs or #ps -ef) 4. Use a serial cable to connect PC1 to the W311/321/341’s serial port 1. 5. Use an Ethernet cable to connect PC2 to the W311/321/341. 6. On PC1: If running Windows, use HyperTerminal (38400, n, 8, 1) to open COMn.
  • Page 29: 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 W311/321/341 units. The following topics are covered in this chapter:...
  • Page 30: System Version Information

    Managing Embedded Linux System Version Information To determine the hardware capability of your W311/321/341, and what kind of software functions are supported, check the version numbers of your W311/321/341’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 the W311/321/341’s bottom label.
  • Page 31 #upramdisk #cd /mnt/ramdisk 2. Type the following commands to use the W321/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>...
  • Page 32 Wait to write file . . . Compleleted 100% Upgrade the firmware is OK. 4. For W311, use upgradehfm command to upgrade the kernel and root file system. #upgradehfm w3xx-x.x.x.hfm ATTENTION The upfirm utility will reboot your target after the upgrade is OK.
  • Page 33: Loading Factory Defaults

    Ready LED will turn off after 5 seconds, and the factory defaults will be loaded. Enabling and Disabling Daemons The following daemons are enabled when the W311/321/341 unit boots up for the first time. snmpd ..SNMP Agent daemon telnetd ..Telnet Server / Client daemon inetd .....Internet Daemons...
  • Page 34 W311/321/341 Linux User’s Manual Managing Embedded Linux To run a private daemon, you can edit the file rc.local, as follows: #cd /etc/rc.d #vi rc.local 192.168.3.127 - PuTTY root@Moxa:~# cd /etc/rc.d root@Moxa:~# /etc/rc.d# vi rc.local Next, use vi to open your application program. We use the example program tcps2-release, and put it to run in the background.
  • Page 35: Setting The Run-Level

    W311/321/341 Linux 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...
  • Page 36: Adjusting The System Time

    Adjusting the System Time Setting the Time Manually The W311/321/341 have two time settings. One is the system time, and the other is the RTC (Real Time Clock) time kept by the W311/321/341’s hardware. Use the #date command to query the current system time or set a new system time.
  • Page 37: Ntp Client

    Managing Embedded Linux NTP Client The W311/321/341 have a built-in NTP (Network Time Protocol) client that is used to initialize a time request to a remote NTP server. Use #ntpdate <this client utility> to update the system time. #ntpdate time.stdtime.gov.tw #hwclock –w...
  • Page 38: Cron-Daemon To Execute Scheduled Commands

    W311/321/341 Linux 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 in the background. The Cron daemon will search /etc/cron.d/crontab for crontab files, which are named after accounts in /etc/passwd.
  • Page 39: Chapter 4 Managing Communications

    Managing Communications Chapter 4 In this chapter, we explain how to configure the W311/321/341’s various communication functions. The following topics are covered in this chapter: Telnet / FTP Web Service—Apache Installing PHP for Apache Web Server IPTABLES NAT Example Enabling NAT at Bootup Dial-up Service—PPP...
  • Page 40: Telnet / Ftp

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

    W311/321/341 Linux User’s Manual Managing Communications Web Service—Apache The Apache web server’s main configuration file is , with the /etc/apache/conf/httpd.conf default homepage located at . Save your own homepage to the /home/httpd/htdocs/index.html following directory: /home/httpd/htdocs/ Save your CGI page to the following directory:...
  • Page 42: Installing Php For Apache Web Server

    W311/321/341 Linux User’s Manual Managing Communications 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/conf/httpd.conf.
  • Page 43 W311/321/341 Linux User’s Manual Managing Communications Step 2: Type “upramdisk” to get the free space ram disk to save the 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...
  • Page 44 W311/321/341 Linux User’s Manual Managing Communications 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. Start to install PHP. Please wait ...
  • Page 45: Iptables

    A rule (such as a jump to a user-defined chain in the same table) is called a “target.” The W311/321/341 support 3 types of IPTABLES table: Filter tables, NAT tables, and Mangle tables: A. Filter Table—includes three chains:...
  • Page 46 OUTPUT Chain NAT Table OUTPUT Chain Filter Table OUTPUT Chain NAT Table POSTROUTING Chain Outgoing Packets The W311/321/341 support the following sub-modules. Be sure to use the module that matches your application. ip_conntrack ipt_MARK ipt_ah ipt_state ip_conntrack_ftp ipt_MASQUERADE ipt_esp ipt_tcpmss...
  • Page 47 #lsmod #insmod ip_tables #insmod iptable_filter Use lsmod to check if the ip_tables module has already been loaded in the W311/321/341 unit. Use insmod to insert and enable the module. Use the following command to load the modules (iptable_filter, iptable_mangle, iptable_nat):...
  • Page 48 INPUT: For packets coming into the W311/321/341. OUTPUT: For locally-generated packets. FORWARD: For packets routed out through the W311/321/341. PREROUTING: To alter packets as soon as they come in. POSTROUTING: To alter packets as they are about to be sent out.
  • Page 49: Nat

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

    Modem / PPP access is almost identical to connecting directly to a network through the W311/321/341’s Ethernet port. Since PPP is a peer-to-peer system, the W311/321/341 can also use PPP to link two networks (or a local network to the Internet) to create a Wide Area Network (WAN).
  • Page 51 W311/321/341 Linux User’s Manual Managing Communications The pppd daemon is used to connect to a PPP server from a Linux system. For detailed information about pppd see the man page. Example 1: Connecting to a PPP server over a simple dial-up connection The following command is used to connect to a PPP server by modem.
  • Page 52 W311/321/341 Linux User’s Manual Managing Communications modem Indicates that this is a modem device; pppd will hang up the phone before and after making the call. defaultroute Once the PPP link is established, make it the default route; if you have a PPP link to the Internet, this is probably what you want.
  • Page 53 W311/321/341 Linux User’s Manual Managing Communications 64 bytes from 129.67.1.165: icmp_seq=2 ttl=225 time=266 ms --- 129.67.1.165 ping statistics --- 3 packets transmitted, 3 packets received, 0% packet loss round-trip min/avg/max = 247/260/268 ms waddington:~$ Try typing: netstat –nr This should show three routes, something like this:...
  • Page 54: Pppoe

    W311/321/341 Linux User’s Manual Managing Communications PPPoE 1. Connect the W311/321/341’s LAN port to an ADSL modem with a cross-over cable, HUB, or switch. 2. Log in to the W311/321/341 as the root user. 3. Edit the file /etc/ppp/chap-secrets and add the following: “username@hinet.net”*“password”*...
  • Page 55 W311/321/341 Linux User’s Manual Managing Communications 5. Edit the file /etc/ppp/options and add the following line: plugin pppoe 6. Add one of two files: /etc/ppp/options.eth0 or /etc/ppp/options.eth1. 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.eth0.
  • Page 56: Nfs (Network File System)

    NFS allows users to develop applications for the W311/321/341, without worrying about the amount of disk space that will be available. The W311/321/341 supports NFS protocol for client.
  • Page 57: Mail

    You will need to add your hostname to the file /etc/hosts. SNMP The W311/321/341 have built-in SNMP V1 (Simple Network Management Protocol) agent software. It supports RFC1317 RS-232 like group and RFC 1213 MIB-II. The following simple example allows you to use an SNMP browser on the host site to query the W311/321/341, which is the SNMP agent.
  • Page 58 W311/321/341 Linux User’s Manual Managing Communications 28: ifMtu.2 (integer) 1500 29: ifMtu.3 (integer) 30: ifMtu.4 (integer) 31: ifMtu.5 (integer) 32: ifMtu.6 (integer) 33: ifSpeed.1 (gauge) 100000000 34: ifSpeed.2 (gauge) 100000000 35: ifSpeed.3 (gauge) 38400 36: ifSpeed.4 (gauge) 38400 37: ifSpeed.5 (gauge) 38400 38: ifSpeed.6 (gauge)
  • Page 59 W311/321/341 Linux User’s Manual Managing Communications 95: ifInUnknownProtos.3 (counter) 96: ifInUnknownProtos.4 (counter) 97: ifInUnknownProtos.5 (counter) 98: ifInUnknownProtos.6 (counter) 99: ifOutOctets.1 (counter) 51987 100: ifOutOctets.2 (counter) 3832 101: ifOutOctets.3 (counter) 102: ifOutOctets.4 (counter) 103: ifOutOctets.5 (counter) 104: ifOutOctets.6 (counter) 105: ifOutUcastPkts.1 (counter) 106: ifOutUcastPkts.2 (counter)
  • Page 60 W311/321/341 Linux User’s Manual Managing Communications 162: ipReasmFails.0 (counter) 163: ipFragOKs.0 (counter) 164: ipFragFails.0 (counter) 165: ipFragCreates.0 (counter) 166: ipAdEntAddr.192.168.27.139 (ipaddress) 192.168.27.139 167: ipAdEntAddr.192.168.4.127 (ipaddress) 192.168.4.127 168: ipAdEntIfIndex.192.168.27.139 (integer) 169: ipAdEntIfIndex.192.168.4.127 (integer) 170: ipAdEntNetMask.192.168.27.139 (ipaddress) 255.255.255.0 171: ipAdEntNetMask.192.168.4.127 (ipaddress) 255.255.255.0 172: ipAdEntBcastAddr.192.168.27.139 (integer)
  • Page 61 W311/321/341 Linux User’s Manual Managing Communications 229: icmpOutSrcQuenchs.0 (counter) 230: icmpOutRedirects.0 (counter) 231: icmpOutEchos.0 (counter) 232: icmpOutEchoReps.0 (counter) 233: icmpOutTimestamps.0 (counter) 234: icmpOutTimestampReps.0 (counter) 235: icmpOutAddrMasks.0 (counter) 236: icmpOutAddrMaskReps.0 (counter) 237: tcpRtoAlgorithm.0 (integer) other(1) 238: tcpRtoMin.0 (integer) 239: tcpRtoMax.0 (integer) 120000 240: tcpMaxConn.0 (integer)
  • Page 62 W311/321/341 Linux User’s Manual Managing Communications 296: tcpConnLocalPort.192.168.4.127.1026.0.0.0.0.0 (integer) 1026 297: tcpConnLocalPort.192.168.27.139.9.0.0.0.0.0 (integer) 298: tcpConnLocalPort.192.168.4.127.9.0.0.0.0.0 (integer) 299: tcpConnLocalPort.192.168.27.139.111.0.0.0.0.0 (integer) 300: tcpConnLocalPort.192.168.4.127.111.0.0.0.0.0 (integer) 301: tcpConnLocalPort.192.168.27.139.80.0.0.0.0.0 (integer) 302: tcpConnLocalPort.192.168.4.127.80.0.0.0.0.0 (integer) 303: tcpConnLocalPort.192.168.27.139.21.0.0.0.0.0 (integer) 304: tcpConnLocalPort.192.168.4.127.21.0.0.0.0.0 (integer) 305: tcpConnLocalPort.192.168.27.139.22.0.0.0.0.0 (integer) 306: tcpConnLocalPort.192.168.4.127.22.0.0.0.0.0 (integer) 307: tcpConnLocalPort.192.168.27.139.23.0.0.0.0.0 (integer)
  • Page 63 W311/321/341 Linux User’s Manual Managing Communications 363: udpLocalAddress.192.168.27.139.9 (ipaddress) 192.168.27.139 364: udpLocalAddress.192.168.4.127.9 (ipaddress) 192.168.4.127 365: udpLocalAddress.192.168.27.139.161 (ipaddress) 192.168.27.139 366: udpLocalAddress.192.168.4.127.161 (ipaddress) 192.168.4.127 367: udpLocalAddress.192.168.27.139.4800 (ipaddress) 192.168.27.139 368: udpLocalAddress.192.168.4.127.4800 (ipaddress) 192.168.4.127 369: udpLocalAddress.192.168.27.139.854 (ipaddress) 192.168.27.139 370: udpLocalAddress.192.168.4.127.854 (ipaddress) 192.168.4.127 371: udpLocalAddress.192.168.27.139.111 (ipaddress) 192.168.27.139...
  • Page 64 W311/321/341 Linux User’s Manual Managing Communications 430: rs232AsyncPortParity.3 (integer) none(1) 431: rs232AsyncPortParity.4 (integer) none(1) 432: rs232InSigPortIndex.1.2 (integer) 433: rs232InSigPortIndex.2.2 (integer) 434: rs232InSigPortIndex.3.2 (integer) 435: rs232InSigPortIndex.4.2 (integer) 436: rs232InSigPortIndex.1.3 (integer) 437: rs232InSigPortIndex.2.3 (integer) 438: rs232InSigPortIndex.3.3 (integer) 439: rs232InSigPortIndex.4.3 (integer) 440: rs232InSigPortIndex.1.6 (integer) 441: rs232InSigPortIndex.2.6 (integer)
  • Page 65: Openvpn

    Click on the following links for more information about MIB II and RS-232 like groups: http://www.faqs.org/rfcs/rfc1213.html http://www.faqs.org/rfcs/rfc1317.html W311/321/341 do NOT support SNMP trap. OpenVPN OpenVPN provides two types of tunnels for users to implement VPNS: Routed IP Tunnels and Bridged Ethernet Tunnels. To begin with, check to make sure that the system has a virtual device /dev/net/tun.
  • Page 66 W311/321/341 Linux User’s Manual Managing Communications Setup 1: Ethernet Bridging for Private Networks on Different Subnets 1. Set up four machines, as shown in the following diagram. local net OpenVPN A Host A LAN1: 192.168.2.173 LAN1: 192.168.2.171 LAN2: 192.168.8.173 LAN1: 192.168.8.174 LAN1: 192.168.4.172...
  • Page 67 W311/321/341 Linux User’s Manual Managing Communications netmask ) NETMASK=$f2 broadcast ) BROADCAST=$f2 esac done break done < /etc/network/interfaces # get the ip address of the specified interface mname= module_up() oIFS=$IFS IFS=‘ ‘ FOUND=“no” for LINE in `lsmod` TOK=`echo $LINE | cut -d’ ‘ -f1` if [ “$TOK”...
  • Page 68 W311/321/341 Linux User’s Manual Managing Communications i=`expr $i + 1` if [ $i -ge $maxtap ]; then break done # null ip address of internal interface ifconfig $iface 0.0.0.0 promisc up # enable bridge ip ifconfig br0 $IPADDR netmask $NETMASK broadcast $BROADCAST...
  • Page 69 W311/321/341 Linux User’s Manual Managing Communications 3. Create a configuration file named A-tap0-br.conf and an executable script file named A-tap0-br.sh on OpenVPN A. # point to the peer remote 192.168.8.174 dev tap0 secret /etc/openvpn/secrouter.key cipher DES-EDE3-CBC auth MD5 tun-mtu 1500...
  • Page 70 W311/321/341 Linux User’s Manual Managing Communications 6. To create an indirect connection to Host B from Host A, you need to add the following routing item: route add –net 192.168.4.0 netmask 255.255.255.0 dev eth0 To create an indirect connection to Host A from Host B, you need to add the following routing item: route add –net 192.168.2.0 netmask 255.255.255.0 dev eth0...
  • Page 71 W311/321/341 Linux User’s Manual Managing Communications Setup 3: Routed IP 1. Set up four machines as shown in the following diagram: local net OpenVPN A Host A LAN1: 192.168.2.173 LAN1: 192.168.2.171 LAN2: 192.168.8.173 LAN1: 192.168.8.174 LAN1: 192.168.4.172 LAN2: 192.168.4.174 OpenVPN B...
  • Page 72 W311/321/341 Linux User’s Manual Managing Communications #----------------------------------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 gw $5 #---------------------------------- end ------------------------------ Note that the parameter “ifconfig” defines the first argument as the local internal interface and the second argument as the internal interface at the remote peer.
  • Page 73: 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 debugging are also introduced. For clarity, the W311/321/341 embedded computer is called a target computer. The following functions are covered in this chapter:...
  • Page 74: Linux Tool Chain

    Most of the cross compiler tools are the same as their native compiler counterparts, but with an additional prefix that specifies the target system. In the case of x86 environments, the prefix is and in the case of W311/321/341 ARM boards, it is i386-linux-...
  • Page 75: On-Line Debugging With Gdb

    W311/321/341 Linux User’s Manual Tool Chains for Application Development strip Removes symbols and sections from object files (usually debugging information) On-Line Debugging with GDB The tool chain also provides an on-line debugging mechanism to help you develop your program. Before performing a debugging session, add the option -ggdb to compile the program. A debugging session runs on a client-server architecture on which the server gdbserver is installed int the targe computer and the client ddd is installed in the host computer.
  • Page 76: Chapter 6 Programmer's Guide

    Programmer’s Guide Chapter 6 This chapter includes important 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...
  • Page 77: Flash Memory Map

    SD or CF card, for the data log. Device API The W311/321/341 support control devices with the ioctl system API. You will need to include <moxadevice.h>, and use the following ioctl function. int ioctl(int d, int request,…);...
  • Page 78: Buzzer

    Programmer’s Guide Buzzer The device node is located at /dev/console. The W311/321/341 support Linux standard buzzer control, with the W311/321/341’s buzzer running at a fixed frequency of 100 Hz. You must include <sys/kd. h>. Function: KDMKTONE ioctl(fd, KDMKTONE, unsigned int arg);...
  • Page 79 W311/321/341 Linux User’s Manual Programmer’s Guide int swtd_enable(int fd, unsigned long time) Description Enable application sWatchDog. And you must do ack after this process. Input int fd - the file handle, from the swtd_open() return value. unsigned long time - The time you wish to ack sWatchDog periodically. You must ack the sWatchDog before timeout.
  • Page 80 W311/321/341 Linux User’s Manual Programmer’s Guide 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.
  • Page 81 W311/321/341 Linux User’s Manual Programmer’s Guide 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> #include <sys/time.h> #include <moxadevice.h> static void mydelay(unsigned long msec) struct timeval time;...
  • Page 82: Uart

    The normal tty device node is located at /dev/ttyM0 … ttyM3 The W311/321/341 support Linux standard termios control. The Moxa UART Device API allows you to configure ttyM0 to ttyM3 as RS-232, RS-422, 4-wire RS-485, or 2-wire RS-485. The W311/321/341 support RS-232, RS-422, 2-wire RS-485, and 4-wire RS485.
  • Page 83: Special Note

    W311/321/341 Linux User’s Manual Programmer’s Guide Example to get the baudrate #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 } else { ioctl(fd, MOXA_GET_SPECIAL_BAUD_RATE, &speed);...
  • Page 84: Chapter 7 Software Lock

    Software Lock Chapter 7 “Software Lock” is an innovative technology developed by the Moxa engineering team. It can be adopted by a system integrator or developer to protect his applications from being copied. An application is compiled into a binary format bound to the embedded computer and the operating system (OS) that the application runs on.
  • Page 85: Appendix A System Commands

    System Commands Appendix A 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.
  • Page 86: Process

    W311/321/341 Linux User’s Manual System Commands Process kill kill process display now running process Other dmesg dump kernel log message to set serial port zcat dump .gz file context mknod make device node free display system memory usage date print or set the system date and time...

This manual is also suitable for:

W321W341

Table of Contents