W406-LX User’s Manual Second Edition, November 2009 www.moxa.com/product © 2009 Moxa Inc. All rights reserved. Reproduction without permission is p
W406-LX User’s Manual Getting Started 2-2Powering on the W406-LX Connect the SG wire to the shielded contact located in the upper left corner of the
W406-LX User’s Manual Getting Started 2-3Once the connection is established, the following window will open. Acquiring the IP Address of the W406-L
W406-LX User’s Manual Getting Started 2-4Please note that when you turn on a computer that is not connected to the local network or there is no DHCP
W406-LX User’s Manual Getting Started 2-5SSH Console The W406-LX supports an SSH Console to provide users with better security options. Windows User
W406-LX User’s Manual Getting Started 2-6NOTE SSH provides better security compared to Telnet for accessing the W406-LX’s console utility over the
W406-LX User’s Manual Getting Started 2-7NOTE After changing the IP settings, use the networking restart command to activate the new IP address. Mo
W406-LX User’s Manual Getting Started 2-8Setting Up the Wireless Module Before using the W406, make sure the SIM card is properly installed and the
W406-LX User’s Manual Getting Started 2-9Verifying the SIM Card Status Use the sim_get_pin_status command to check the SIM card status. Four possib
W406-LX User’s Manual Getting Started 2-10 To disable PIN code authentication, use sim_enable_pin-d –p command.
W406-LX User’s Manual Getting Started 2-11Changing the PIN Code Use sim_change_pin -o old PIN code –n new PIN code command to change the PIN code.
W406-LX 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
W406-LX User’s Manual Getting Started 2-12Unlocking the SIM Card When your SIM has been locked, you will need to enter the PUK code to unlock your S
W406-LX User’s Manual Getting Started 2-13Connecting to the Internet To create a connection, use the gprs_connect command. For more detailed comman
W406-LX User’s Manual Getting Started 2-14Reconnecting to the Internet When an internet connection has been broken, use the gprs_reconnect –t seco
W406-LX User’s Manual Getting Started 2-15Detecting an Internet Connection Error To diagnose a connection problem, use the gprs_diagnose command. Th
W406-LX User’s Manual Getting Started 2-16Sending and Reading an SMS Message To send an SMS message, use the sms_send_text_msg command. For example,
W406-LX User’s Manual Getting Started 2-17Deleting an SMS Message To delete an SMS message, use the sms_remove_msg command. For example, the sms_rem
W406-LX User’s Manual Getting Started 2-18Installing the Tool Chain (Linux) The Linux Operating System must be pre-installed in the PC before instal
W406-LX User’s Manual Getting Started 2-19Compiling Hello.c The package CD contains several example programs. Here we use hello.c as an example to s
33 Chapter 3 Managing Embedded Linux This chapter includes information about version control, deployment, updates, and peripherals. The informatio
W406-LX User’s Manual Managing Embedded Linux 3-2System Version Information To determine the hardware capability of your W406-LX, and what kind of s
Table of Contents Chapter 1 Introduction ...1-1 Overv
W406-LX User’s Manual Managing Embedded Linux 3-3Since different Flash disks have different sizes, it’s a good idea to check the size of your Flash
W406-LX User’s Manual Managing Embedded Linux 3-4150 Opening data connection for W406-x.x.x.hfm 226 Transfer complete. 13167772 bytes received in 2
W406-LX User’s Manual Managing Embedded Linux 3-5Type the command “ps” to list all processes currently running. 192.168.3.127 – PuTTY root@Moxa:~
W406-LX User’s Manual Managing Embedded Linux 3-6The enabled daemons will be available after you reboot the system. 192.168.3.127 – PuTTY root@Mo
W406-LX User’s Manual Managing Embedded Linux 3-7 192.168.3.127 – PuTTY root@Moxa:/ect/rc.d/rc3.d# ls S19nfs-common S25nfs-user-server S99showre
W406-LX User’s Manual Managing Embedded Linux 3-8The following figure illustrates how to update the system time and set the RTC time. 192.168.3.1
W406-LX User’s Manual Managing Embedded Linux 3-9Updating the Time Automatically In this subsection, we show how to use a shell script to update the
W406-LX User’s Manual Managing Embedded Linux 3-10STEP5: Enable cron when the system boots up. Add the following line in the file /etc/rc.d/rc.local
44 Chapter 4 Managing Communications In this chapter, we explain how to configure the W406-LX’s various communication functions. The following top
W406-LX User’s Manual Managing Communications 4-2Telnet / FTP In addition to supporting Telnet client/server and FTP client/server, the W406-LX also
Chapter 4 Managing Communications ...4-1 Telnet / FTP ...
W406-LX User’s Manual Managing Communications 4-3Web Service—Apache The Apache web server’s main configuration file is /etc/apache/conf/httpd.conf,
W406-LX User’s Manual Managing Communications 4-4To open the default CGI page, type http://192.168.13.23/cgi-bin/test-cgi in your browser’s address
W406-LX User’s Manual Managing Communications 4-5Install PHP for Apache Web Server This embedded computer supports the PHP option. However, since th
W406-LX User’s Manual Managing Communications 4-6IPTABLES IPTABLES is an administrative tool for setting up, maintaining, and inspecting the Linux k
W406-LX User’s Manual Managing Communications 4-7The following figure shows the IPTABLES hierarchy. Incoming Packets Mangle Table PREROUT
W406-LX User’s Manual Managing Communications 4-8 The W406-LX supports the following sub-modules. Be sure to use the module that matches your applic
W406-LX User’s Manual Managing Communications 4-9Since the IPTABLES command is very complex, to illustrate the IPTABLES syntax we have divided our d
W406-LX User’s Manual Managing Communications 4-10Append or delete rules: Usage: # iptables [-t table] [-AI] [INPUT, OUTPUT, FORWARD] [-io interface
W406-LX User’s Manual Managing Communications 4-11NAT Example The IP address of LAN1 is changed to 192.168.3.127 (you will need to load the module i
W406-LX User’s Manual Managing Communications 4-12echo “1” > /proc/sys/net/ipv4/ip_forward /bin/iptables -F /bin/iptables -X /bin/iptables -Z
11 Chapter 1 Introduction The W406-LX is an embedded computer that features 2 software selectable RS-232/422/485 ports, 1 Ethernet port, and quad-
W406-LX User’s Manual Managing Communications 4-13Double quotes—don’t wait for a prompt, but proceed with the following instead (note that you must
W406-LX User’s Manual Managing Communications 4-14How to check the connection Once you’ve set up a PPP connection, there are some steps you can take
W406-LX User’s Manual Managing Communications 4-15Setting up a Machine for Incoming PPP Connections This first example applies to using a modem, and
W406-LX User’s Manual Managing Communications 4-164. Edit the file /etc/ppp/pap-secrets and add the following: “[email protected]” * “password” *
W406-LX User’s Manual Managing Communications 4-176. Add the following files: /etc/ppp/options.eth0. The file context is shown below: 7. Set up D
W406-LX User’s Manual Managing Communications 4-18NFS (Network File System) The Network File System (NFS) is used to mount a disk partition on a rem
W406-LX User’s Manual Managing Communications 4-19SNMP The W406-LX has built-in SNMP V1 (Simple Network Management Protocol) agent software. It supp
W406-LX User’s Manual Managing Communications 4-20192.168.3.120 – Putty Installing libmysqlclient5 (5.1.23) to root... Stopping web server: apache.
W406-LX User’s Manual Managing Communications 4-21Setup 1: Ethernet Bridging for Private Networks on Different Subnets 1. Set up four machines, as
W406-LX User’s Manual Managing Communications 4-22 address ) IPADDR=$f2 ;; netmask ) NETMASK=$f2 ;; broadcast ) BROADCAST
W406-LX User’s Manual Introduction 1-2Overview The W406-LX embedded computers, which are designed for industrial automation applications, feature 2
W406-LX User’s Manual Managing Communications 4-23 ifconfig tap${i} 0.0.0.0 promisc up i=`expr $i + 1` if [ $i -ge $maxtap ]; then break
W406-LX User’s Manual Managing Communications 4-243. Create a configuration file named A-tap0-br.conf and an executable script file named A-tap0-br
W406-LX User’s Manual Managing Communications 4-25Interface eth1 is connected to the bridging interface br0, to which device tap0 also connects, whe
W406-LX User’s Manual Managing Communications 4-26Setup 3: Routed IP 1. Set up the four machines as shown in the following diagram: OpenVPN AOpenVP
W406-LX User’s Manual Managing Communications 4-27Note that the parameter “ifconfig” defines the first argument as the local internal interface and
55 Chapter 5 Development Tool Chains This chapter describes how to install a tool chain in the host computer that you use to develop your applicat
W406-LX Linux User’s Manual Development Tool Chains 5-2Linux Tool Chain The Linux tool chain contains a suite of cross compilers and other tools, as
W406-LX Linux User’s Manual Development Tool Chains 5-3The following cross compiler tools are provided with a prefix “arm-linux-“. ar Manages archiv
66 Chapter 6 Programmer’s Guide This chapter includes important information for programmers. The following functions are covered in this chapter:
W406-LX Linux User’s Manual Programmer’s Guide 6-2Flash Memory Map Partition sizes are hard coded into the kernel binary. To change the partition si
W406-LX User’s Manual Introduction 1-3The W406-LX’s built-in Flash ROM is partitioned into Boot Loader, Linux Kernel, Root File System, and User dir
W406-LX Linux User’s Manual Programmer’s Guide 6-3Buzzer The device node is located at /dev/console. The W406-LX supports Linux standard buzzer cont
W406-LX Linux User’s Manual Programmer’s Guide 6-4Example to set the baudrate #include <moxadevice.h> #include <termios.h> struct termio
W406-LX Linux User’s Manual Programmer’s Guide 6-5Digital I/O Digital Output channels can be set to high or low. The channels are controlled by the
W406-LX Linux User’s Manual Programmer’s Guide 6-6int set_din_event(int diport, void (*func)(int diport), int mode, long int duration) Description:
W406-LX Linux User’s Manual Programmer’s Guide 6-7(1): from high to low DIN_EVENT_LOW_TO_HIGH(0): from low to high DIN_EVENT_CLEAR(-1): clear this e
W406-LX Linux User’s Manual Programmer’s Guide 6-82. get now data. \n\ 3. set low to high event \n\ 4. clear event \n\ 5. set high data. \n\ 6. set
W406-LX Linux User’s Manual Programmer’s Guide 6-9scanf("%d", &i); retval=set_dout_state(i, 1); } else if ( i == 6 ) { // set low data
W406-LX Linux User’s Manual Programmer’s Guide 6-10case DIO_ERROR_DURATION: printf("DIO error duratoin\n"); case DIO_ERROR_DURATION_20MS:
W406-LX Linux User’s Manual Programmer’s Guide 6-11 Closes a cellular modem handle. void cellular_modem_close(unsigned int fd); Inputs: <fd>
W406-LX Linux User’s Manual Programmer’s Guide 6-12 Aborts a GPRS connection. int cellular_modem_gprs_abort_connection(unsigned int fd); Inputs: <
W406-LX User’s Manual Introduction 1-4 Although JFFS2 is a journaling file system, this does not preclude the loss of data. The file system will rem
W406-LX Linux User’s Manual Programmer’s Guide 6-13 Gets the storage base of SIM messages. int cellular_modem_sms_get_storage_base(unsigned int fd);
W406-LX Linux User’s Manual Programmer’s Guide 6-14 Receives an indexed SMS message. int cellular_modem_sms_recv_message(unsigned int fd, int index,
W406-LX Linux User’s Manual Programmer’s Guide 6-15 When the SIM card status is set to PIN (2), this function retrieves the available PIN code attem
W406-LX Linux User’s Manual Programmer’s Guide 6-16 When the SIM card status is ready (0) and the PIN code is enabled, this function assigns a PIN c
W406-LX Linux User’s Manual Programmer’s Guide 6-17 Sets the UART interface. BOOL uart_setmode(int port, int mode); Inputs: <port> the serial
W406-LX Linux User’s Manual Programmer’s Guide 6-18 Gets one of the DIN inputs. int mxdio_get_din(HANDLE hDIO, unsigned int port); Inputs: <hDIO&
W406-LX Linux User’s Manual Programmer’s Guide 6-19Buzzer Turns on the buzzer. void mxbeep_on(void); Inputs: None Return Values: None Remark: Turn
77 Chapter 7 Software Lock “Software Lock” is an innovative technology developed by the Moxa engineering force. It can be adopted by a system inte
AA Appendix A System Commands Linux normal command utility collection File manager 1. cp copy file 2. ls list file 3. ln make symbolic link fi
W406-LX Linux User’s Manual System Commands A-2Process 1. kill kill process 2. ps display now running process Other 1. dmesg dump kernel log me
22 Chapter 2 Getting Started In this chapter, we explain how to connect the W406-LX, how to turn on the power, how to get started programming, and
Comentarios a estos manuales