UC-8410/8416/8418 LX User’s Manual Second Edition, September 2009 www.moxa.com/product © 2009 Moxa Inc. All rights reserved. Reproduction without permission is prohibited.
UC-8410/8416/8418-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 of that agreement. Copyright Notice Copyright © 2009 Moxa Inc. All rights reserved. Reproduction without permission is prohibited. Trademarks MOXA is a registered trademark of Moxa Inc. All other trademarks or registered marks in this manual belong to their respective manufacturers.
Table of Contents Chapter 1 Introduction ..................................................................................................1-1 Overview.................................................................................................................................. 1-2 Software Architecture .............................................................................................................. 1-2 Journaling Flash File System (JFFS2) ...................................................
PPPoE .................................................................................................................................... 4-15 NFS (Network File System) Client........................................................................................ 4-17 Setting up the UC-8410/8416/8418 as an NFS Client ................................................ 4-17 Mail......................................................................................................................................
1 Chapter 1 Introduction Welcome to the Moxa UC-8400 Series of RISC-based communication platforms. The UC-8410/8416/8418 embedded computer comes with 8 RS-232/422/485 serial ports, 3 Ethernet ports, 4 digital input channels, 4 digital output channels, (12 digital input channles and 12 digital output channels for UC-8418), 8 10/100 Mbps switch ports (UC-8416 only), a CompactFlash socket, and 2 USB 2.0 ports. The UC-8410/8416/8418 computer uses the Intel XScale IXP435 533 MHz RISC CPU.
UC-8410/8416/8418-LX User’s Manual Introduction Overview The UC-8410/8416/8418 computer, which features a RISC CPU, RAM memory, serial ports for connecting RS-232/422/485 devices, and 3 10/100 Mbps Ethernet ports, is designed for embedded applications. The UC-8410/8416/8418 uses an Intel XScale IXP435 533 Mhz RISC CPU.
UC-8410/8416/8418-LX User’s Manual Introduction The UC-8410/8416/8418’s built-in Flash ROM is divided into Boot Loader, Linux Kernel, Root File System, and User Root File System partitions. In order to prevent user applications from crashing the Root File System, the UC-8410/8416/8418 uses 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.
UC-8410/8416/8418-LX User’s Manual Introduction Software Features Operating System Boot Loader Kernel Protocol Stack File System OS shell command Busybox Utilities tinylogin telnet ftp smtpclient scp Daemons pppd snmpd telnetd inetd ftpd apache sshd openvpn Linux Tool Chain Gcc (V4.2.1) GDB (V6.3) Glibc (V2.2.5) Redboot Linux 2.6.23 ARP, PPP, CHAP, PAP, IPv4, ICMP, TCP, UDP, DHCP, FTP, SNMP V1, HTTP, NTP, NFS, SMTP, SSH 1.0/2.
2 Chapter 2 Getting Started In this chapter, we explain how to connect the UC-8410/8416/8418, turn on the power, and then get started with programming and using other functions. The following topics are covered: Powering on the UC-8410/8416/8418 Connecting the UC-8410/8416/8418 to a PC ¾ Serial Console ¾ Telnet Console ¾ SSH Console Configuring the Ethernet Interface ¾ Modifying Network Settings with the Serial Console ¾ Modifying Network Settings over the Network Test Program─Developing Hello.
UC-8410/8416/8418-LX User’s Manual Getting Started Powering on the UC-8410/8416/8418 Connect the SG wire to the Shielded Contact located in the upper left corner of the UC-8410/8416/8418, and then power on the computer by connecting it to the power adaptor. It takes about 30 to 60 seconds for the system to boot up. Once the system is ready, the Ready LED will light up. ATTENTION After connecting the UC-8410/8416/8418 to the power supply, it will take about 16 seconds for the operating system to boot up.
UC-8410/8416/8418-LX User’s Manual Getting Started Once the connection is established, the following window will open. To log in, type the Login name and password as requested. The default values are both root: Login: root Password: root Telnet Console If you know at least one of the IP addresses and netmasks, you can use Telnet to connect to the UC-8410/8416/8418’s console utility. The default IP address and Netmask for each of the ports are given below: LAN 1 LAN 2 LAN 3 Default IP Address 192.168.3.
UC-8410/8416/8418-LX User’s Manual Getting Started You can proceed with configuring network settings of the target computer when you reach the bash command shell. Configuration instructions are given in the next section. ATTENTION Serial Console Reminder Remember to choose VT100 as the terminal type. Use cable CBL-4PINDB9F-100, which comes with the UC-8410/8416/8418, to connect to the serial console port.
UC-8410/8416/8418-LX User’s Manual Getting Started SSH Console The UC-8410/8416/8418 supports 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 UC-8410/8416/8418 in a Windows environment. The following figure shows a simple example of the configuration that is required.
UC-8410/8416/8418-LX User’s Manual Getting Started Configuring the Ethernet Interface The network settings of the UC-8410/8416/8418 can be modified with the serial console, or online over the network. Modifying Network Settings with the Serial Console In this section, we use the serial console to configure network settings of the target computer. 1.
UC-8410/8416/8418-LX User’s Manual Getting Started Dynamic IP Addresses: By default, the UC-8410/8416/8418 is configured for “static” IP addresses. To configure LAN ports to request an IP address dynamically, replace static with dhcp and then delete the address, network, netmask, and broadcast lines. Default Setting for LAN1 iface eth0 inet static address 192.168.3.127 network: 192.168.3.0 netmask 255.255.255.0 broadcast 192.168.3.
UC-8410/8416/8418-LX User’s Manual Getting Started Test Program─Developing Hello.c Step 1: Connect the UC-8410/8416/8418 to a Linux PC. Step 2: Install the Tool Chain (GNU Cross Compiler & glibc). Step 3: Set the cross compiler and glibc environment variables. Step 4: Code and compile the program. Step 5: Download the program to the UC-8410/8416/8418 via FTP or NFS. Step 6: Debug the program Æ If bugs are found, return to Step 4.
UC-8410/8416/8418-LX User’s Manual Getting Started Checking the Flash Memory Space The UC-8410/8416/8418 uses a specially designed root file system. Only /tmp, /etc, /home, /usr/local/bin, /usr/local/sbin, /usr/local/libexec, and /usr/local/lib directories are writable. Others are read-only. The writable directories are mounted on /dev/mtdblock4. If the /dev/mtdblock4 is full, you will not be able to save data to the Flash ROM.
UC-8410/8416/8418-LX User’s Manual Getting Started ATTENTION Be sure to type the #make command from within the /tmp/example/hello directory, since the UC-8410/8416/8418’s tool chain puts a specially designed Makefile in that directory. This special Makefile uses the xscale-linux-gcc compiler to compile the hello.c source code for the Xscale environment. If you type the #make command from any other directory, Linux will use the x86 compiler (for example, cc or gcc).
3 Chapter 3 Managing Embedded Linux This chapter includes information about version control, deployment, updates, and peripherals.
UC-8410/8416/8418-LX User’s Manual Managing Embedded Linux System Version Information To determine the hardware capability of your UC-8410/8416/8418 and what kind of software functions are supported, check which version of the firmware your UC-8410/8416/8418 is running. Contact Moxa to determine the hardware version. You will need the Production S/N (Serial number), which is located on the UC-8410/8416/8418’s bottom label. To check the kernel version, type: #kversion 192.168.3.
UC-8410/8416/8418-LX User’s Manual Managing Embedded Linux Since different Flash disks have different sizes, it’s a good idea to check the size of your Flash disk before upgrading the firmware, or before using the disk to store your application and data files. Use the #df –h command to list the size of each memory block, and how much free space is available in each block. 192.168.3.127 – PuTTY root@Moxa:/# df -h Filesystem Size rootfs 13.4M /dev/root 13.4M /dev/ram15 1.7M /dev/ram0 499.
UC-8410/8416/8418-LX User’s Manual Managing Embedded Linux 192.168.3.127 – PuTTY root@Moxa:/mnt/ramdisk# ftp 192.168.3.193 Connected to 192.168.3.193 (192.168.3.193). 220 TYPSoft FTP Server 1.10 ready… Name (192.168.3.193:root): root 331 Password required for root. Password: 230 User root logged in. Remote system type is UNIX. Using binary mode to transfer files. ftp> cd newsw 250 CWD command successful. “/C:/ftproot/newsw/” is current directory. ftp> bin 200 Type set to I.
UC-8410/8416/8418-LX User’s Manual Managing Embedded Linux Loading Factory Defaults Press the reset button for more than 5 seconds to force the system to load the factory default settings. All files in the /home, /etc, /usr/local/bin, /usr/local/sbin, /usr/local/lib, /usr/local/libexec, and /tmp directories will be deleted. While pressing the reset button, during the first 5 seconds the ready-light will blink once each second.
UC-8410/8416/8418-LX User’s Manual Managing Embedded Linux Type the command “ps” to list all processes currently running. 192.168.3.
UC-8410/8416/8418-LX User’s Manual Managing Embedded Linux The following daemons will be enabled after you reboot the system. 192.168.3.
UC-8410/8416/8418-LX 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 S20snmpd S55ssh S99showreadyled S25nfs-server S99rmnologin root@Moxa:/etc/rc.d/rc3.d# #cd /etc/rc.d/init.d Edit a shell script to execute /root/tcps2-release and save to tcps2 as an example. #cd /etc/rc.d/rc3.
UC-8410/8416/8418-LX User’s Manual Managing Embedded Linux Setting the System Time There are two ways to support the timezone configuration on a Moxa embedded computer. One is using the TZ variable. The other is using /etc/localtime. TZ variable If you would like to use TZ variable, link to the following URL for all configurations and settings. http://www.mkssoftware.com/docs/man5/timezone.5.
UC-8410/8416/8418-LX User’s Manual Managing Embedded Linux The following figure illustrates how to update the system time and set the RTC time. 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 070910002006 Sun Jul 9 10:00:00 CST 2006 root@Moxa:~# hwclock –w root@Moxa:~# date ; hwclock Sun Jul 9 10:01:07 CST 2006 Sun Jul 9 10:01:08 2006 -0.
UC-8410/8416/8418-LX User’s Manual Managing Embedded Linux Updating the Time Automatically In this subsection, we show how to use a shell script to update the time automatically. Example shell script to update the system time periodically #!/bin/sh ntpdate time.nist.gov # You can use the time server’s ip address or domain # name directly. If you use domain name, you must # enable the domain client on the system by updating # /etc/resolv.conf file. hwclock –w sleep 100 # Updates every 100 seconds. The min.
UC-8410/8416/8418-LX User’s Manual Managing Embedded Linux STEP2: Change mode of fixtime.sh #chmod 755 fixtime.sh STEP3: Modify /etc/cron.d/crontab file to run fixtime.sh at 8:00 every day. Add the following line to the end of crontab: * 8 * * * root /home/fixtime.sh STEP4: Enable the cron daemon manually. #/etc/init.d/cron start STEP5: Enable cron when the system boots up. Add the following line in the file /etc/init.d/rc.local #/etc/init.
4 Chapter 4 Managing Communication In this chapter, we explain how to configure the UC-8410/8416/8418’s various communication functions.
UC-8410/8416/8418-LX User’s Manual Managing Communication Telnet/FTP In addition to supporting Telnet client/server and FTP client/server, the UC-8410/8416/8418 also supports SSH and sftp client/server. To enable or disable the Telnet/ftp server, you first need to edit the file /etc/inetd.conf. Enabling the Telnet/ftp server The following example shows the default content of the file /etc/inetd.conf.
UC-8410/8416/8418-LX User’s Manual Managing Communication Web Service—Apache The Apache web server’s main configuration file is /etc/apache/conf/httpd.conf, with the default homepage located at /home/httpd/htdocs/index.html.
UC-8410/8416/8418-LX User’s Manual Managing Communication To open the default CGI test script report page, type http://host-ip-address/cgi-bin/test-cgi in your browser’s address box. ATTENTION When you develop your own CGI application, make sure your CGI file is executable. 192.168.3.
UC-8410/8416/8418-LX User’s Manual Managing Communication IPTABLES IPTABLES is an administrative tool for setting up, maintaining, and inspecting the Linux kernel’s IP packet filter rule tables. Several different tables are defined, with each table containing built-in chains and user-defined chains. Each chain is a list of rules that apply to a certain type of packet. Each rule specifies what to do with a matching packet.
UC-8410/8416/8418-LX User’s Manual Managing Communication The following figure shows the IPTABLES hierarchy.
UC-8410/8416/8418-LX User’s Manual Managing Communication The UC-8410/8416/8418 supports the following sub-modules. Be sure to use the module that matches your application.
UC-8410/8416/8418-LX User’s Manual Managing Communication Since the IPTABLES command is very complex, to illustrate the IPTABLES syntax we have divided our discussion of the various rules into three categories: Observe and erase chain rules, Define policy rules, and Append or delete rules. Observe and erase chain rules Usage: # iptables [-t tables] [-L] [-n] -t tables: -L [chain]: List -n: Table to manipulate (default: ‘filter’); example: nat or filter. List all rules in selected chains.
UC-8410/8416/8418-LX User’s Manual Managing Communication Append or delete rules: Usage: # iptables [-t table] [-AI] [INPUT, OUTPUT, FORWARD] [-io interface] [-p tcp, udp, icmp, all] [-s IP/network] [--sport ports] [-d IP/network] [--dport ports] –j [ACCEPT. DROP] -A: -I: -i: -o: -p: -s: --sport: -d: --dport: -j: Append one or more rules to the end of the selected chain. Insert one or more rules in the selected chain as the given rule number.
UC-8410/8416/8418-LX User’s Manual Managing Communication NAT NAT (Network Address Translation) protocol translates IP addresses used on one network to different IP addresses used on another network. One network is designated the inside network and the other is the outside network.
UC-8410/8416/8418-LX User’s Manual Managing Communication Enabling NAT at Bootup In most real world situations, you will want to use a simple shell script to enable NAT when the UC-8410/8416/8418 boots up. The following script is an example. #!/bin/bash # If you put this shell script in the /home/nat.sh # Remember to chmod 744 /home/nat.sh # Edit the rc.local file to make this shell startup automatically. # vi /etc/rc.d/rc.local # Add a line in the end of rc.local /home/nat.
UC-8410/8416/8418-LX User’s Manual NOTE Managing Communication Click on the following links for more information about ppp: http://tldp.org/HOWTO/PPP-HOWTO/index.html http://axion.physics.ubc.ca/ppp-linux.html 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.
UC-8410/8416/8418-LX User’s Manual Managing Communication Debug Log status in syslog. Crtscts Use hardware flow control between the computer and modem (at 115200 this 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 link to the Internet, this is probably what you want. 192.1.1.17 This is a degenerate case of a general option of the form x.x.
UC-8410/8416/8418-LX User’s Manual Managing Communication Now, type: ping z.z.z.z where z.z.z.z is the address of your name server. This should work. Here’s what the response could look 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: icmp_seq=0 ttl=225 time=268 ms 64 bytes from 129.67.1.165: icmp_seq=1 ttl=225 time=247 ms 64 bytes from 129.67.1.165: icmp_seq=2 ttl=225 time=266 ms ^C --- 129.67.1.
UC-8410/8416/8418-LX User’s Manual Managing Communication PPPoE 1. Connect the UC-8410/8416/8418’s LAN port to an ADSL modem with a cross-over cable, HUB, or switch. 2. Log in to the UC-8410/8416/8418 as the root user. 3. Edit the file /etc/ppp/chap-secrets and add the following: “username@hinet.net” * “password” * 192.168.3.
UC-8410/8416/8418-LX User’s Manual Managing Communication 5. Edit the file /etc/ppp/options and add the following line: plugin pppoe 192.168.3.127 – PuTTY # Wait for up n milliseconds after the connect script finishes for a valid # PPP packet from the peer. At the end of this time, or when a valid PPP # packet is received from the peer, pppd will commence negotiation by # sending its first LCP packet. The default value is 1000 (1 second).
UC-8410/8416/8418-LX User’s Manual Managing Communication NFS (Network File System) Client 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, seamless sharing of files across a network. NFS allows users to develop applications for the UC-8410/8416/8418, without worrying about the amount of disk space that will be available. The UC-8410/8416/8418 supports NFS protocol for client.
UC-8410/8416/8418-LX User’s Manual Managing Communication SNMP The UC-8410/8416/8418 has the SNMP V1 (Simple Network Management Protocol) agent software built in. It supports RFC1317 RS-232 like groups and RFC 1213 MIB-II. The following simple example allows you to use an SNMP browser on the host site to query the UC-8410/8416/8418, which is the SNMP agent. The UC-8410/8416/8418 will respond. debian:~# snmpwalk -v 1 -c public -Cc 192.168.30.127 SNMPv2-MIB::sysDescr.0 = STRING: Linux version 2.6.23.
UC-8410/8416/8418-LX User’s Manual Managing Communication Setup 1: Ethernet Bridging for Private Networks on Different Subnets 1. Set up four machines, as shown in the following diagram. Host A (B) represents one of the machines that belongs to OpenVPN A (B). The two remote subnets are configured for a different range of IP addresses.
UC-8410/8416/8418-LX User’s Manual Managing Communication case “$f1” in address ) IPADDR=$f2 ;; netmask ) NETMASK=$f2 ;; broadcast ) BROADCAST=$f2 ;; esac done break fi done < /etc/network/interfaces } # get the ip address of the specified interface mname= module_up() { oIFS=$IFS IFS=‘ ‘ FOUND=“no” for LINE in `lsmod` do TOK=`echo $LINE | cut -d’ ‘ -f1` if [ “$TOK” = “$mname” ]; then FOUND=“yes”; break; fi done IFS=$oIFS if [ “$FOUND” = “no” ]; then modprobe $mname fi } start() { ifcfg_vpn if [ ! \( -d “/
UC-8410/8416/8418-LX User’s Manual Managing Communication # null ip address of tap device ifconfig tap${i} 0.0.0.0 promisc up i=`expr $i + 1` if [ $i -ge $maxtap ]; then break fi 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 ipf=/proc/sys/net/ipv4/ip_forward # enable IP forwarding echo 1 > $ipf echo “ip forwarding enabled to” cat $ipf } stop() { echo “shutdown openvpn bridge.
UC-8410/8416/8418-LX User’s Manual Managing Communication 3. On machine OpenVPN A, modify the remote address in the configuration file, /etc/openvpn/tap0-br.conf. # /etc/openvpn/tap0-br.conf # 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 tun-mtu-extra 64 ping 40 up /etc/openvpn/tap0-br.sh Next, modify the routing table in the /etc/openvpn/tap0-br.sh script file.
UC-8410/8416/8418-LX User’s Manual Managing Communication If you see the line “Peer Connection Initiated with 192.168.8.173:5000” on each machine, the connection between OpenVPN machines has been established successfully on UDP port 5000. Note: You can create link symbols to enable the /etc/openvpn/openvpn-bridge script at boot time: # ln -s /etc/openvpn/openvpn-bridge /etc/rc.d/rc3.d/S32vpn-br # ln -s /etc/openvpn/openvpn-bridge /etc/rc.d/rc6.d/K32vpn-br 5.
UC-8410/8416/8418-LX User’s Manual Managing Communication Setup 2: Ethernet Bridging for Private Networks on the Same Subnet 1. Set up four machines as shown in the following diagram: 2. The configuration procedure is almost the same as for the previous example. The only difference is that you will need to comment out the parameter “up” in “/etc/openvpn/tap0-br.conf” and “/etc/openvpn/tap0-br.conf”. Setup 3: Routed IP 1.
UC-8410/8416/8418-LX User’s Manual Managing Communication 2. On machine OpenVPN A, modify the remote address in the configuration file, /etc/openvpn/tun.conf. # point to the peer remote 192.168.8.174 dev tun secret /etc/openvpn/secrouter.key cipher DES-EDE3-CBC auth MD5 tun-mtu 1500 tun-mtu-extra 64 ping 40 ifconfig 192.168.2.173 192.168.4.174 up /etc/openvpn/tun.sh Next, modify the routing table in the /etc/openvpn/tun.sh script file.
UC-8410/8416/8418-LX User’s Manual Managing Communication 3. Check the routing table after you run the OpenVPN programs, by typing the command: # route Destination Gateway Genmsk 192.168.4.174 * 255.255.255.255 192.168.4.0 192.168.4.174 255.255.255.0 192.168.2.0 * 255.255.255.0 192.168.8.0 * 255.255.255.0 Flags UH UG U U Metric 0 0 0 0 Ref 0 0 0 0 Use 0 0 0 0 Iface tun0 tun0 eth1 eth0 Package Management—ipkg ipkg is a very lightweight package management system.
5 Chapter 5 Programmer’s Guide This chapter includes important information for programmers.
UC-8410/8416/8418 LX User’s Manual Programmer’s Guide Flash Memory Map Partition sizes are hard coded into the kernel binary. To change partition sizes, you will need to rebuild the kernel. The flash memory map is shown in the following table. Address 0x00000000 – 0x0005FFFF 0x00060000 – 0x001FFFFF 0x00200000 – 0x00DFFFFF 0x00E00000 – 0x01FCFFFF 0x01FC0000 – 0x01FDFFFF Size 640 KB 1.875 MB 13.375 MB 32 MB 128 KB 256 KB NOTE 1. 2. 3.
UC-8410/8416/8418 LX User’s Manual Programmer’s Guide Alternatively, you can add the same commands to $HOME/.bash_profile to cause it to take effect for all login sessions initiated by this user. Obtaining help Use the Linux man utility to obtain help on many of the utilities provided by the tool chain.
UC-8410/8416/8418 LX User’s Manual Programmer’s Guide Debugging with GDB First use the option -ggdb to compile the program. Use the following steps: 1. To debug a program called hello-debug on the target, use the command: #gdbserver 192.168.4.142:2000 hello-debug This is where 2000 is the network port number on which the server waits for a connection from the client. This can be any available port number on the target.
UC-8410/8416/8418 LX User’s Manual Programmer’s Guide Buzzer The device node is located at /dev/console. The UC-8410/8416/8418 supports Linux standard buzzer control, with the UC-8410/8416/8418’s buzzer running at a fixed frequency of 100 Hz. You must include . 1. Function: KDMKTONE ioctl(fd, KDMKTONE, unsigned int arg); Description: The buzzer’s behavior is determined by the argument arg.
UC-8410/8416/8418 LX User’s Manual Programmer’s Guide int swtd_enable(int fd, unsigned long time) Description Enable the application sWatchDog. You must do an ack after this process. Input int fd - the file handle, from the swtd_open() return value. unsigned long time - The time you wish to ack sWatchDog periodically. You must ack the sWatchDog before timeout. If you do not ack, the system will reboot automatically. The minimum time is 50 msec, and the maximum time is 60 seconds. The time unit is msec.
UC-8410/8416/8418 LX User’s Manual Programmer’s Guide int swtd_ack(int fd) Description: Acknowledge sWatchDog. When the user application enable sWatchDog, it need to call this function periodically with user predefined time in the application program. Input : int fd - the file handle from swtd_open() return value. Output: If you receive 0 (zero), it means the function is working. If you receive any other number, then there is something wrong with this function.
UC-8410/8416/8418 LX User’s Manual Programmer’s Guide exit(0); } The makefile is shown below: all: xscale-linux-gcc –o xxxx xxxx.c –lmoxalib Example 2: #include #include #include #include #include #include #include #include #include static void mydelay(unsigned long msec) { struct timeval time; time.tv_sec = msec / 1000; time.
UC-8410/8416/8418 LX User’s Manual Programmer’s Guide } The makefile is shown below: all: xscale-linux-gcc –o xxxx xxxx.c –lmoxalib Digital I/O Digital Output channels can be set to high or low. The channels are controlled by the function call set_dout_state( ). The Digital Input channels can be used to detect the state change of the digital input signal. The DI channels can also be used to detect whether or not the state of a digital signal changes during a fixed period of time.
UC-8410/8416/8418 LX User’s Manual Programmer’s Guide > Returns the call back function. When the event occurs, the call back function will be invoked.
UC-8410/8416/8418 LX User’s Manual Programmer’s Guide Examples Example 1 File Name: tdio.c Description: The program indicates to connect DO1 to DI1, change the digital output state to high or low by manual input, and then detect and count the state changed events from DI1. #include #include #include #include #ifdef DEBUG #define dbg_printf(x...) printf(x) #else #define dbg_printf(x...
UC-8410/8416/8418 LX User’s Manual Programmer’s Guide scanf(“%lu”, &duration); retval = set_din_event(i, lowtohighevent, DIN_EVENT_LOW_TO_HIGH, duration); } else if ( i == 4 ) { // clear event printf(“Please keyin the DIN number : “); scanf(“%d”, &i); retval=set_din_event(i, NULL, DIN_EVENT_CLEAR, 0); } else if ( i == 5 ) { // set high data printf(“Please keyin the DOUT number : “); scanf(“%d”, &i); retval=set_dout_state(i, 1); } else if ( i == 6 ) { // set low data printf(“Please keyin the DOUT number :
UC-8410/8416/8418 LX User’s Manual Programmer’s Guide DIO Program Make File Example FNAME=tdio CC=xscale-linux-gcc STRIP=xscale-linux-strip release: $(CC) -o $(FNAME) $(FNAME).c -lmoxalib -lpthread $(STRIP) -s $(FNAME) debug: $(CC) -DDEBUG -o $(FNAME)-dbg $(FNAME).cxx -lmoxalib -lpthread clean: /bin/rm -f $(FNAME) $(FNAME)-dbg *.o Note: For the UC-8418, 8 additional digital input channels and 8 additional digital output channels are provided. The port numbers for these go from 4 to 11.
UC-8410/8416/8418 LX User’s Manual Programmer’s Guide Setinterface The Serial Port Expansion Module has 8 serial ports, labeled ttyM0 to ttyM7. The ports support RS-232, RS-422, and RS-485 2-wire and 4-wire operation modes with baudrate settings up to 921600 bps. The default operation mode is set to RS-232. You can use the setinterface command to change the serial port operation mode. Usage: setinterface device-node [interface-no] device-node -- /dev/ttyMn; n = 0,1,2,...
UC-8410/8416/8418 LX User’s Manual Programmer’s Guide Baudrate inaccuracy Divisor = 921600/Target Baud Rate. (Only Integer part) ENUM = 8 * (921600/Target - Divisor) ( Round up or down) Inaccuracy = (Target Baud Rate – 921600/(Divisor + (ENUM/8))) / Target Baud Rate * 100% E.g., To calculate 500000 bps Divisor = 1, ENUM = 7, Inaccuracy = 1.7% *The Inaccuracy should less than 2% for the device to work reliably. Special Note 1. If the target baudrate is not a special baudrate (e.g.
UC-8410/8416/8418 LX User’s Manual Programmer’s Guide char pattern=‘9’; if ( argc > 2 ) { printf(“Usage: %s [pattern]\n”); exit(0); } if ( argc == 2 ) { pattern=argv[1][0]; printf(“pattern:%c\n”, pattern); } fd = open(“/dev/sram”, O_RDWR); if( fd < 0 ) { printf(“Open /dev/sram fail”); exit(0); } // Write the sram with patern memset(sram_buf1, pattern, sizeof(sram_buf1)); len=write(fd, sram_buf1, sizeof(sram_buf1)); if( len < 0 ) { printf(“Write /dev/sram fail”); exit(0); } printf(“The content is written\n
UC-8410/8416/8418 LX User’s Manual Programmer’s Guide printf(“Usage: %s [pattern]\n”); exit(0); } if ( argc == 2 ) { pattern=argv[1][0]; printf(“pattern:%c\n”, pattern); } fd = open(“/dev/sram”, O_RDWR); if( fd < 0 ) { printf(“Open /dev/sram fail”); exit(0); } // Write the sram with pattern memset(sram_buf1, pattern, sizeof(sram_buf1)); // Read from sram and compare with pattern len=read(fd, sram_buf2, sizeof(sram_buf2)); if( len < 0 ) { printf(“Read from /dev/sram fail\n”); exit(0); } if ( memcmp(sram_bu
UC-8410/8416/8418 LX User’s Manual Programmer’s Guide Moxa CAN Programming Guide Introduction CAN is a broadcast serial bus standard for connecting electronic control units (ECUs). Each node is able to send and receive messages, but not simultaneously: a message (consisting primarily of an ID—usually chosen to identify the message-type/sender—and up to eight message bytes) is transmitted serially onto the bus, one bit after another.
UC-8410/8416/8418 LX User’s Manual unsigned char unsigned char unsigned char Programmer’s Guide byte6; byte7; byte8; } byte; } can_data_u; typedef struct user_frame_struct { int id; int info; // RTR & extend ID flag #define USER_RTR BIT(0) #define USER_EXTEND_ID BIT(1) int data_length; can_data_u data; } user_frame_t; // ioctl command code #define MOXACAN_IOCTL_SET_BAUD_RATE 0x100 #define MOXACAN_IOCTL_GET_BAUD_RATE 0x101 #endif // _MOXACAN_IOCTL_H Then we can include this header for CAN programming We
UC-8410/8416/8418 LX User’s Manual Programmer’s Guide memset(&txframe, 0, sizeof(txframe)); memset(&txframe, 0, sizeof(rxframe)); txframe.id = 12; txframe.data_length = MAX_CAN_DATA_LENGTH; txframe.info |= USER_EXTEND_ID; for ( i=0; i
UC-8410/8416/8418 LX User’s Manual Programmer’s Guide $(STRIP) $(TARGET)-release $(TARGET1)-release clean: rm -f *.o $(TARGET)-debug $(TARGET)-release $(TARGET1)-debug $(TARGET1)-release Note: Only UC-8418-LX support CAN port communication. Software Lock “Software Lock” is an innovative technology developed by the Moxa engineering team, and can be used by a system integrator or developer to protect applications from being copied.
A Appendix A Firmware Upgrade Procedure Firmware Upgrade Procedure Moxa provides a boot loader utility for firmware upgrade or recovery. You will need the following items to use this utility. 1. The embedded computer that you would like to upgrade or recover. 2. A PC or a laptop computer. 3. A console port cable for connecting through HyperTerminal. 4. A cross-over Ethernet cable for upgrading the firmware through a TFTP server and LAN port. 5. The firmware for the embedded computer.
UC-8410/8416/8418 LX User’s Manual Firmware upgrade procedure There are three steps in the recovery process. A. Configure HyperTerminal for the console port. B. Download and installation of the TFTP program. C. Download the firmware and upgrade through HyperTerminal. If you are familiar with Moxa embedded computers and the firmware upgrade procedure, you may skip to Step C. However, we suggest that you go through all three steps to ensure the firmware upgrades properly. A.
UC-8410/8416/8418 LX User’s Manual Firmware upgrade procedure 5. After HyperTerminal launches, enter UC-8410 or another name for the connection. 6. Click Cancel when the “Connect To” window opens.
UC-8410/8416/8418 LX User’s Manual Firmware upgrade procedure 7. Select File Æ Properties from the main HyperTerminal screen. 8. You can change the COM port number in the Properties window. Click Configure for additional configuration options.
UC-8410/8416/8418 LX User’s Manual 9. Firmware upgrade procedure Configure the Port Settings with following parameters: Bits per second: 115200 Data bits: 8 Parity: None Stop bit: 1 Flow control: None. Click OK to continue. 10. Click the Settings tab and then select VT100 (for Emulation). Click OK to complete the configuration.
UC-8410/8416/8418 LX User’s Manual Firmware upgrade procedure B. Download and Installation of the TFTP program. 1. You will need to download a free TFTP server package to upgrade the firmware for the boot loader utility. Link to the following URL to download: ftp://papa.indstate.edu/ Download the TFTP program located in the following path. /winsock-1/Windows95/Daemons/TFTPD/ Download the file named tftpd32d.zip. 2. When you have finished downloading, extract the files to your PC.
UC-8410/8416/8418 LX User’s Manual Firmware upgrade procedure C. Download and Upgrade the Firmware through HyperTerminal. 1. Connect to Moxa’s website at http://www.moxa.com, and then select Software from the Support drop-down menu. 2. Under Search for Software, select the product line and then choose the specific product model. Click on Search to continue.
UC-8410/8416/8418 LX User’s Manual Firmware upgrade procedure 3. In the software list, select the firmware for your model. Choose the appropriate OS and then click the download icon to start downloading the new firmware. Note: Check the filename, it may differ from the filename shown below. 4. Put the latest firmware icon in the same directory as the TFTP files.
UC-8410/8416/8418 LX User’s Manual Firmware upgrade procedure 5. Next, connect LAN1 of the embedded computer to your PC using a cross-over Ethernet cable. The LAN1 port is located on the rear panel of the embedded computer. 6. Press and hold down the DEL key on your PC and power on the embedded computer at the same time. You will be guided to the boot loader utility menu, as show below.
UC-8410/8416/8418 LX User’s Manual Firmware upgrade procedure 1. In the boot loader utility, select [0] Network Configuration, and then [0] Change IP Setting to configure IP addresses. 2. You will need to enter the IP address of the embedded computer and your PC. Follow the below to configure the IP addresses. a. From Start Æ Settings, select Network Connections.
UC-8410/8416/8418 LX User’s Manual Firmware upgrade procedure b. Right-click on Local Area Connection, and then select Properties. c. Click the General tab and select Internet Protocol (TCP/IP), and then click on Properties.
UC-8410/8416/8418 LX User’s Manual Firmware upgrade procedure d. Next, select Use the following IP address and enter the IP address and Subnet mask. For example: IP address: 192.168.1.1 (This IP address is only an example; you may assign any IP address of your choice as long as it’s on the same LAN as your PC.) Subnet mask: 255.255.255.
UC-8410/8416/8418 LX User’s Manual Firmware upgrade procedure 3. Go back to the boot load utility menu and assign the local IP address, and then enter the server IP address. The local IP address is the IP address of the embedded computer. Note that the local IP address must be on the same LAN as the server IP address. For example, if the server IP address is 192.168.1.1, you can choose a local IP address between 192.168.1.2 to 192.168.1.254. 4.
UC-8410/8416/8418 LX User’s Manual Firmware upgrade procedure 5. To start the TFPF server, double-click on the tftpd32 icon to launch the TFTP server. 6. When the TFTP server has been launched, the following screen will appear.
UC-8410/8416/8418 LX User’s Manual Firmware upgrade procedure 7. Go back to the boot loader utility menu and enter the file name of the firmware image. 8. The firmware upgrade will then start to run.
UC-8410/8416/8418 LX User’s Manual 9. Firmware upgrade procedure It will take several minutes for the firmware files to be written to your embedded computer. Do not power off your computer! 10. When you see Update OK, the firmware upgrade is finished. At this point, you may reboot the embedded computer to complete the firmware upgrade or recovery from the boot loader utility.
UC-8410/8416/8418 LX User’s Manual Firmware upgrade procedure 11. If you cannot reboot your embedded computer (after following all the steps above), contact Moxa’s technical support staff for further assistance.
B Appendix B System Commands Linux normal command utility collection File manager cp ls ln mount rm chmod chown chgrp chroot sync mv pwd df mkdir rmdir find head mkfifo mknod touch which copy file list file make symbolic link file mount and check file system delete file change file owner & group & user change file owner change file group runs a command with a specified root directory.
UC-8410/8416/8418LX User’s Manual System Commands Editor vi cat grep egrep fgrep cut find more test sleep usleep echo sed awk expand tail tar tr wc text editor dump file context Search string on file search string on file of Extended regular expressions Search file(s) for lines that match a fixed string Get string on file Find file where are there dump file by one page test if file exists or not Sleep (seconds) suspend execution for microsecond intervals echo string Steam editor pattern-directed scanning
UC-8410/8416/8418LX User’s Manual System Commands Modules insmod lsmod modprobe rmmod insert a module into the kernel shows which kernel modules are currently loaded intelligently adds or removes a module from the Linux kernel remove module from kernel dmesg zcat free date env clear reboot halt du gzip, gunzip hostname dump kernel log message Dump .
UC-8410/8416/8418LX User’s Manual System Commands Special Moxa Utilities setkey upgradehfm libmoxalib.