UC-8410/8416/8418/8430-LX User’s Manual Sixth Edition, June 2011 www.moxa.com/product © 2011 Moxa Inc. All rights reserved. Reproduction without permission is prohibited.
UC-8410/8416/8418/8430 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 ©2011 Moxa Inc. All rights reserved. Reproduction without permission is prohibited. Trademarks The MOXA logo is a registered trademark of Moxa Inc. All other trademarks or registered marks in this manual belong to their respective manufacturers.
Table of Contents 1. Introduction ...................................................................................................................................... 1-1 Overview ........................................................................................................................................... 1-2 Software Architecture ..........................................................................................................................
SRAM .............................................................................................................................................. 5-15 Make File Example ............................................................................................................................ 5-16 Moxa CAN Programming Guide ........................................................................................................... 5-17 Introduction...........................................................
1 1. Introduction Welcome to the Moxa UC-8400 Series of RISC-based communication platforms. The UC-8410/8416/8418/8430 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 channels 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.
UC-8410/8416/8418/8430 Introduction Overview The UC-8410/8416/8418/8430 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/8430 uses an Intel XScale IXP435 533 Mhz RISC CPU.
UC-8410/8416/8418/8430 Introduction and then enable services and daemons. During this time, the kernel will start searching for system configuration parameters via rc or inittab. Normally, the kernel uses the Root File System to boot up the system. The Root File System is protected, and cannot be changed by the user, providing a “safe” zone. For more information about memory map and programming, refer to Chapter 5, “Programmer’s Guide.
UC-8410/8416/8418/8430 Introduction openvpn: virtual private network service manager pppd: dial in/out over serial port daemon snmpd: snmpd agent daemon openssl: open SSL Application Development Software: Moxa Linux API device control Linux Tool Chain: Firmware v1.X: • GCC (V4.2.1): C/C++ PC Cross Compiler • Glibc (V2.2.5): POSIX standard C Library Firmware v2.X: • GCC (V4.4.2): C/C++ PC Cross Compiler • Glibc (V2.10.
2 2. Getting Started In this chapter, we explain how to connect the UC-8410/8416/8418/8430, turn on the power, and then get started with programming and using other functions.
UC-8410/8416/8418/8430 Getting Started Powering on the UC-8410/8416/8418/8430 Connect the SG wire to the Shielded Contact located in the upper left corner of the UC-8410/8416/8418/8430, 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.
UC-8410/8416/8418/8430 Getting Started To connect to a hub or switch connected to your local LAN, use a straight-through Ethernet cable. The default IP addresses and netmasks are shown above. To log in, type the Login name and password as requested. The default values are both root: Login: root Password: root 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.
UC-8410/8416/8418/8430 Getting Started Linux Users From a Linux machine, use the “ssh” command to access the UC-8410/8416/8418/8430’s Console utility via SSH. #ssh 192.168.3.127 Select yes to complete the connection. [root@bee_notebook root]# ssh 192.168.3.127 The authenticity of host ‘192.168.3.127 (192.168.3.127)’ can’t be established. RSA key fingerprint is 8b:ee:ff:84:41:25:fc:cd:2a:f2:92:8f:cb:1f:6b:2f.
UC-8410/8416/8418/8430 Getting Started Static IP addresses: As shown below, 3 network addresses need to be modified: address, network, netmask, and broadcast. The default IP addresses are 192.168.3.127 for LAN1, 192.168.4.127 for LAN2, and 192.168.5.127 for LAN3, with default netmasks of 255.255.255.0. # We always want the loopback interface. auto eth0 eth1 eth2 lo iface lo inet loopback # embedded ethernet LAN1 iface eth0 inet static address 192.168.3.127 network 192.168.3.0 netmask 255.255.255.
UC-8410/8416/8418/8430 Getting Started Modifying Network Settings over the Network IP settings can be activated over the network, but the new settings will not be saved to the flash ROM without modifying the file /etc/network/interfaces. For example, type the command #ifconfig eth0 192.168.1.1 to change the IP address of LAN1 to 192.168.1.1. root@Moxa:# ifconfig eth0 192.168.1.1 root@Moxa:/etc/network/# Test Program─Developing Hello.c 1. Connect the UC-8410/8416/8418/8430/8430 to a Linux PC. 2.
UC-8410/8416/8418/8430 Getting Started ATTENTION If you have an older version of Linux Tool Chain on your Moxa embedded computer (such as the W300 Series, IA240/241, and UC-7112-LX Plus) and would like to install the new Linux Tool Chain for the UC-8410/8416/8418/8430, the old Linux Tool Chain files will be immediately overwritten, and the programs compiled by this new Tool Chain may not work on your old models.
UC-8410/8416/8418/8430 Getting Started [root@localhost hello]# make xscale-linux-gcc –o hello-release hello.c xscale-linux-strip –s hello-release xscale-linux-gcc –ggdb -o hello-debug hello.c [root@localhost hello]# _ Next, execute hello.
3 3. Managing Embedded Linux This chapter includes information about version control, deployment, updates, and peripherals.
UC-8410/8416/8418/8430 Managing Embedded Linux System Version Information To determine the hardware capability of your UC-8410/8416/8418/8430/8430 and what kind of software functions are supported, check which version of the firmware your UC-8410/8416/8418/8430/8430 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/8430’s bottom label. To check the kernel version, type: #kversion 192.168.3.
UC-8410/8416/8418/8430 root@Moxa:/# upramdisk root@Moxa:/# df -h Filesystem Size /dev/mtdblock2 14.0M /dev/ram15 1.7M /dev/ram0 499.0k /dev/mtdblock3 15.8M /dev/mtdblock3 15.8M /dev/mtdblock3 15.8M /dev/ram1 38.7M root@Moxa:/# cd /mnt/ramdisk/ root@Moxa:/mnt/ramdisk# Managing Embedded Linux Used Available 11.2M 2.8M 18.0k 1.6M 34.0k 440.0k 2.6M 13.1M 2.6M 13.1M 2.6M 13.1M 13.0k 36.
UC-8410/8416/8418/8430 Managing Embedded Linux 150 Opening data connection for FWR_uc8400_Va.b.c_Build_YYMMDDHH.hfm 226 Transfer complete. 12904012 bytes received in 2.17 secs (5925.8 kB/s) ftp> 3. Next, use the upgradehfm command to upgrade the kernel and root file system: #upgradehfm FWR_uc8400_Va.b.c_Build_YYMMDDHH.hfm 192.168.3.127 – PuTTY root@Moxa:/mnt/ramdisk# upgradehfm FWR_uc8400_Va.b.c_Build_YYMMDDHH.hfm Moxa UC-8400 Upgrade firmware utility version 1.0. To check source firmware file context.
UC-8410/8416/8418/8430 Managing Embedded Linux ATTENTION Reset-to-default will erase all data stored in /dev/mtdblock4 If you have stored data in the writable partition, you will need to back up these files before resetting the system to default. On the UC-8410/8416/8418/8430, the directories /tmp, /etc, /usr/local/bin, /usr/local/sbin, /usr/local/lib, /usr/local/libexec, and /home are mounted on /dev/mtdblock4.
UC-8410/8416/8418/8430 881 883 884 885 886 887 root nobody nobody nobody nobody nobody 1292 S 12560 S 12560 S 12560 S 12560 S 12560 S Managing Embedded Linux /bin/reportip /usr/bin/httpd /usr/bin/httpd /usr/bin/httpd /usr/bin/httpd /usr/bin/httpd -k -k -k -k -k start start start start start -d -d -d -d -d /etc/apache /etc/apache /etc/apache /etc/apache /etc/apache 2. To run a private daemon, edit the file rc.local, as follows: #cd /etc/rc.d #vi rc.local 192.168.3.
UC-8410/8416/8418/8430 829 root 832 bin 838 root 843 root 867 root 873 root 876 root 878 nobody 879 nobody 880 nobody 881 nobody 882 nobody 883 root 896 root 1360 S 1300 S 2428 S 1360 S 3508 S 7284 S 1292 S 7308 S 7308 S 7308 S 7308 S 7380 S 1264 S 2156 R Managing Embedded Linux /bin/inetd /bin/portmap /bin/sh --login /bin/snmpd -c public /bin/sshd -f/etc/ssh/sshd_config /usr/bin/httpd -k start -d/etc/apache /bin/reportip /usr/bin/httpd -k start -d/etc/apache /usr/bin/httpd -k start -d/etc/apache /usr/bin
UC-8410/8416/8418/8430 Managing Embedded Linux To remove the daemon, use the following command to remove the run file from /etc/rc.d/rc3.d: #rm –f /etc/rc.d/rc3.d/S60tcps2 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.
UC-8410/8416/8418/8430 Managing Embedded Linux 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/8430 Managing Embedded Linux # /etc/resolv.conf file. hwclock –w sleep 100 # Updates every 100 seconds. The min. time is 100 seconds. Change 100 to a larger number to update RTC less often. Save the shell script using any file name. E.g., fixtime How to run the shell script automatically 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 mode. Next, use vi editor to edit the file /etc/inittab.
UC-8410/8416/8418/8430 Managing Embedded Linux Connecting Peripherals USB Mass Storage The UC-8410/8416/8418/8430/8430 supports PNP (plug-n-play), and hot pluggability for connecting USB mass storage devices. The UC-8410/8416/8418/8430/8430 has a built-in auto mount utility that eases the mount procedure. The connected USB mass storage device will be mounted automatically. You can check the location of the USB disk by mount command.
4 4. Managing Communication In this chapter, we explain how to configure the UC-8410/8416/8418/8430’s various communication functions.
UC-8410/8416/8418/8430 Managing Communication Telnet/FTP In addition to supporting Telnet client/server and FTP client/server, the UC-8410/8416/8418/8430/8430 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/8430 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/8430 Managing Communication ATTENTION When you develop your own CGI application, make sure your CGI file is executable. 192.168.3.
UC-8410/8416/8418/8430 Managing Communication Incoming Packets Mangle Table PREROUTING Chain NAT Table PREROUTING Chain Local Host Other Host Packets Packets Mangle Table Mangle Table INPUT Chain FORWARD Chain Filter Table Filter Table INPUT Chain FORWARD Chain Local Mangle Table Process POSTROUTING Chain Mangle Table OUTPUT Chain NAT Table OUTPUT Chain Filter Table OUTPUT Chain NAT Table POSTROUTING Chain Outgoing Packets 4-5
UC-8410/8416/8418/8430 Managing Communication The UC-8410/8416/8418/8430/8430 supports the following sub-modules. Be sure to use the module that matches your application.
UC-8410/8416/8418/8430 Managing Communication # iptables [-t tables] [-FXZ] -F: Flush the selected chain (all the chains in the table if none is listed). -X: Delete the specified user-defined chain. -Z: Set the packet and byte counters in all chains to zero. Examples: # iptables -L -n In this example, since we do not use the -t parameter, the system uses the default ‘filter’ table. Three chains are included: INPUT, OUTPUT, and FORWARD.
UC-8410/8416/8418/8430 Managing Communication --dport: Destination port number. -j: Jump target. Specifies the target of the rules; i.e., how to handle matched packets. For example, ACCEPT the packet, DROP the packet, or LOG the packet. Examples: Example 1: Accept all packets from lo interface. # iptables –A INPUT –i lo –j ACCEPT Example 2: Accept TCP packets from 192.168.0.1. # iptables –A INPUT –i eth0 –p tcp –s 192.168.0.1 –j ACCEPT Example 3: Accept TCP packets from Class C network 192.168.1.
UC-8410/8416/8418/8430 Managing Communication NAT Example The IP address of LAN1 is changed to 192.168.3.127 (you will need to load the module ipt_MASQUERADE): 1. #echo 1 > /proc/sys/net/ipv4/ip_forward 2. #modprobe ip_tables 3. #modprobe iptable_filter 4. #modprobe ip_conntrack 5. #modprobe iptable_nat 6. #modprobe ipt_MASQUERADE 7. #iptables -t nat –A POSTROUTING –o eth0 –j SNAT --to-source 192.168.3.
UC-8410/8416/8418/8430 Managing Communication export PATH echo “1” > /proc/sys/net/ipv4/ip_forward /sbin/iptables -F /sbin/iptables -X /sbin/iptables -Z /sbin/iptables -F -t nat /sbin/iptables -X -t nat /sbin/iptables -Z -t nat /sbin/iptables -P INPUT ACCEPT /sbin/iptables -P OUTPUT ACCEPT /sbin/iptables -P FORWARD ACCEPT /sbin/iptables -t nat -P PREROUTING ACCEPT /sbin/iptables -t nat -P POSTROUTING ACCEPT /sbin/iptables -t nat -P OUTPUT ACCEPT # Step 3. Enable IP masquerade.
UC-8410/8416/8418/8430 Managing Communication -v verbose mode; log what we do to syslog “ “ Double quotes—don’t wait for a prompt, but instead do (note that you must include a space after the second quotation mark) ATDT5551212 Dial the modem, and then ... CONNECT Wait for an answer. “ “ Send a return (null text followed by the usual return) ogin: username word: password Log in with username and password. Refer to the chat man page, chat.8, for more information about the chat utility.
UC-8410/8416/8418/8430 Managing Communication How to check the connection Once you’ve set up a PPP connection, there are some steps you can take to test the connection. First, type: /sbin/ifconfig (The folder ifconfig may be located elsewhere, depending on your distribution.) You should be able to see all of the network interfaces that are UP.
UC-8410/8416/8418/8430 Managing Communication Setting up a Machine for Incoming PPP Connections This first example applies to using a modem, and requires authorization with a username and password. pppd/dev/ttyM0 115200 crtscts modem 192.168.16.1:192.168.16.2 login auth You should also add the following line to the file /etc/ppp/pap-secrets: * * ““ * The first star (*) lets everyone login. The second star (*) lets every host connect.
UC-8410/8416/8418/8430 # other accounts that should guest hostname “*” master hostname “*” root hostname “*” support hostname “*” stats hostname “*” Managing Communication not be able to use pppd! - “username@hinet.net” is the username obtained from the ISP to log in to the ISP account. “password” is the corresponding password for the account. 5. Edit the file /etc/ppp/options and add the following line: plugin pppoe 192.168.3.
UC-8410/8416/8418/8430 Managing Communication 8. Use the following command to create a pppoe connection: pppd eth0 The eth0 is what is connected to the ADSL modem LAN port. The example above uses LAN1. To use LAN2, type: pppd eth1 9. Type ifconfig ppp0 to check if the connection is OK or has failed. If the connection is OK, you will see information about the ppp0 setting for the IP address. Use ping to test the IP. 10. If you want to disconnect it, use the kill command to kill the pppd process.
UC-8410/8416/8418/8430 Managing Communication Example: smtpclient –s test –f < mail-body-message sender@company.com –S -s: The mail subject. -f: Sender’s mail address -S: SMTP server IP address IP_address receiver@company.com The last mail address receiver@company.com is the receiver’s e-mail address. mail-body-message is the mail content. The last line of the body of the message should contain ONLY the period ‘.’ character. You will need to add your hostname to the file /etc/hosts.
UC-8410/8416/8418/8430 Managing Communication 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. If not, issue the following command: # mknod /dev/net/tun c 10 200 An Ethernet bridge is used to connect different Ethernet networks together. The Ethernets are bundled into one bigger, “logical” Ethernet.
UC-8410/8416/8418/8430 Managing Communication { while read f1 f2 f3 f4 r3 do if [ “$f1” = “iface” -a “$f2” = “$iface” -a “$f3” = “inet” -a “$f4” = “static” ];then i=`expr 0` while : do if [ $i -gt 5 ]; then break fi i=`expr $i + 1` read f1 f2 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 T
UC-8410/8416/8418/8430 Managing Communication if [ ! \( -r “/dev/net/tun” \) ]; then # create a device file if there is none mknod /dev/net/tun c 10 200 fi # load modules “tun” and “bridge” 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.
UC-8410/8416/8418/8430 Managing Communication break fi done brctl delif br0 $iface brctl delbr br0 ifconfig br0 down ifconfig $iface $IPADDR netmask $NETMASK broadcast $BROADCAST killall -TERM openvpn } case “$1” in start) start ;; stop) stop ;; restart) stop start ;; *) echo “Usage: $0 [start|stop|restart]” exit 1 esac exit 0 #---------------------------------- end ----------------------------3. On machine OpenVPN A, modify the remote address in the configuration file, /etc/openvpn/tap0-br.conf.
UC-8410/8416/8418/8430 Managing Communication 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. #---------------------------------- Start---------------------------#!/bin/sh # /etc/openvpn/tap0-br.sh # value after “-net” is the subnet behind the remote peer route add -net 192.168.2.0 netmask 255.255.255.
UC-8410/8416/8418/8430 Managing Communication A successful ping indicates that you have created a VPN system that only allows authorized users from one internal network to access users at the remote site. For this system, all data is transmitted by UDP packets on port 5000 between OpenVPN peers. 7. To shut down OpenVPN programs, type the command: # /etc/openvpn/openvpn-bridge stop Setup 2: Ethernet Bridging for Private Networks on the Same Subnet 1.
UC-8410/8416/8418/8430 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/8430 Managing Communication Package Management—ipkg ipkg is a very lightweight package management system. It also allows for dynamic installation/removal of packages on a running system. Because the disk space is limited, we provide the software as extension packages. You can use ipkg-cl to install or remove .ipk packages on the UC-8410/8416/8418/8430-LX. Install an .ipk package via an .ipk file Upload the .ipk package to the Moxa embedded computer: 192.168.3.
UC-8410/8416/8418/8430 Managing Communication Playing a WAVE File vplay: vplay can be used for playing a wave file. It supports playing mono or stereo wave files at a 11025, 22050, or 44100 HZ sampling rate, with 8 or 16 bits. Device File on Linux: /dev/dsp vplay [-qvwrS] [-s speed] [-t seconds] -b bits [filename1 ...] -S Stereo (default is mono). -s speed Sets the speed (default is 11025 kHz). If the speed is less than 300, it will be multiplied by 1000.
5 5. Programmer's Guide This chapter includes important information for programmers.
UC-8410/8416/8418/8430 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 Size Contents 0x00000000 – 0x0009FFFF 640 KB Boot Loader—Read ONLY 0x000A0000 – 0x0027FFFF 1.875 MB Kernel object code—Read ONLY 0x00280000 – 0x00FDFFFF 13.
UC-8410/8416/8418/8430 Programmer's Guide For toolchain v3.x: #export PATH=“/usr/local/arm-linux-4.4.2/bin:$PATH” #export MANPATH=“/usr/local/arm-linux-4.4.2/man:$MANPATH” 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/8430 Programmer's Guide 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. Following this are the name of the program to be debugged (hello-debug), plus that program’s arguments. Output similar to the following will be sent to the console: Process hello-debug created; pid=38 2.
UC-8410/8416/8418/8430 Programmer's Guide Buzzer The device node is located at /dev/console. The UC-8410/8416/8418/8430/8430 supports Linux standard buzzer control, with the UC-8410/8416/8418/8430’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/8430 Programmer's Guide 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. 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/8430 Programmer's Guide When you “kill the application with -9” or “kill without option” or “Ctrl+c” the kernel will change to auto ack the sWatchDog. When your application enables the sWatchDog and does not ack, your application may have a logical error, or your application has made a core dump. The kernel will not change to auto ack. This can cause a serious problem, causing your system to reboot again and again. 5. User application example Example 1: #include
UC-8410/8416/8418/8430 Programmer's Guide static void stop_swatchdog() { stopflag = 1; } static void do_swatchdog(void) { swtd_enable(swtdfd, 500); while ( stopflag == 0 ) { mydelay(250); swtd_ack(swtdfd); } swtd_disable(swtdfd); } int main(int argc, char *argv[]) { pid_t sonpid; signal(SIGUSR1, stop_swatchdog); swtdfd = swtd_open(); if ( swtdfd < 0 ) { printf(“Open sWatchDog device fail !\n”); exit(1); } if ( (sonpid=fork()) == 0 ) do_swatchdog(); // do user application main function ….. ….. …..
UC-8410/8416/8418/8430 Programmer's Guide #define DIO_ERROR_DURATION -4 // The value of duration is not 0 or not in the range, 40 <= duration <= 3600000 milliseconds (1 hour) #define DIO_ERROR_DURATION_20MS -5 // The value of duration must be a multiple of 20 ms #define DIO_OK 0 The definition of DIN and DOUT: #define DIO_HIGH 1 #define DIO_LOW 0 int set_dout_state(int doport, int state) Description: To set the DOUT port to high or low state. Input: int doport - which DOUT port you want to set.
UC-8410/8416/8418/8430 Programmer's Guide int get_din_event(int diport, int *mode, long int *duration) Description: To retrieve the DIN event configuration, including mode (DIN_EVENT_HIGH_TO_LOW or DIN_EVENT_LOW_TO_HIGH), and the value of “duration.” Input: int diport - which DIN port you want to retrieve. - The port whose din event setting we wish to retrieve int *mode - save which event is set. unsigned long *duration - the duration of the DIN port is kept in high or low state.
UC-8410/8416/8418/8430 Programmer's Guide printf(“\nSelect a number of menu, other key to exit. \n\ 1. set high to low event \n\ 2. get now data. \n\ 3. set low to high event \n\ 4. clear event \n\ 5. set high data. \n\ 6. set low data. \n\ 7. quit \n\ 8.
UC-8410/8416/8418/8430 Programmer's Guide for ( j=0; j
UC-8410/8416/8418/8430 Programmer's Guide 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. UART The normal tty device node is located at /dev/ttyM0 … ttyM7, and the modem tty device node is located at /dev/cum0 … cum7. The UC-8410/8416/8418/8430/8430 supports Linux standard termios control.
UC-8410/8416/8418/8430 Programmer's Guide 2 RS-422 3 RS-485 4-wire The following example sets /dev/ttyM0 to RS-422 mode root@Moxa:/# setinterface /dev/ttyM0 2 root@Moxa:~# setinterface /dev/ttyM0 Now setting is RS422 interface. root@Moxa:~# Example for setting the baudrate #include #include struct termios term; int fd, speed; fd = open(“/dev/ttyM0”, O_RDWR); tcgetattr(fd, &term); term.c_cflag &= ~(CBAUD | CBAUDEX); term.
UC-8410/8416/8418/8430 Programmer's Guide 2. If you use stty to get the serial information, you will get a speed equal to 0. SRAM 1. Introduction The UC-8410/8416/8418/8430/8430 provides 256 KB of embedded SRAM. As there is a system battery inside the computer, the SRAM can work and be used to keep data even when the system is crashed. This means that the data stored on the SRAM will not be lost after the UC-8410/8416/8418/8430/8430 is powered off. 2.
UC-8410/8416/8418/8430 Programmer's Guide } /************************************************************** History : Versoin Author Date Comment 1.0 Jared Wu. 09-11-2008 Read from the SRAM and compare with some pattern. **************************************************************/ #include #include #include #include #include #include #include
UC-8410/8416/8418/8430 Programmer's Guide CPP = xscale-linux-gcc SOURCES = hello.c OBJS = $(SOURCES:.c=.o) all: hello hello: $(OBJS) $(CC) -o $@ $^ $(LDFLAGS) $(LIBS) clean: rm -f $(OBJS) hello core *.gdb Moxa CAN Programming Guide Introduction CAN is a broadcast serial bus standard for connecting electronic control units (ECUs).
UC-8410/8416/8418/8430 Programmer's Guide unsigned char byte3; unsigned char byte4; unsigned char byte5; unsigned char byte6; unsigned char byte7; unsigned char 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 w
UC-8410/8416/8418/8430 Programmer's Guide i = write(fd1, &txframe, sizeof(txframe)); printf(“Write port1 data return = %d\n”, i); printf(“Write data contexts are following :\n”); for ( i=0; i
UC-8410/8416/8418/8430 Programmer's Guide NOTE: Use the following command to clear the encryption key on the target computer. #setkey ““ 2. Develop and compile your program on the development PC. 3. On the development PC, run the utility program ‘binencryptor’ to encrypt your program with an encryption key. #binencryptor yourProgram ABigKey 4. Upload the encrypted program file to the target computer by FTP or NFS and test the program. The encryption key is a computer-wise key.
UC-8410/8416/8418/8430 Programmer's Guide int main(int argc, char *argv[]) { QApplication app(argc, argv); QLabel *label = new QLabel("
hello QT
"); QWidget window; label->setWindowTitle("Hello"); label->setAlignment(Qt::AlignCenter); label->resize(200,100); label->show(); window.resize(320, 240); window.show(); window.setWindowTitle( QApplication::translate("toplevel", "Top-level widget")); return app.UC-8410/8416/8418/8430 Programmer's Guide To cross compile: Debian:~# make Upload the binary to target and run it with following command Run the Qt application with assigned input and VGA output: root@Moxa:/tmp# export QWS_MOUSE_PROTO=IntelliMouse:/dev/input/mouse0 ; root@Moxa:/tmp# ./hello -qws -geometry 1024x768 -display voyagerlib:/dev/fb0 & You can also run the second Qt application on another VGA output: root@Moxa:/tmp# export QWS_MOUSE_PROTO=IntelliMouse:/dev/input/mouse1 ; root@Moxa:/tmp# .
A A. 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. There are three steps in the recovery process. A.
UC-8410/8416/8418/8430 Firmware Upgrade Procedure 3. Connect your embedded computer to the power source. The power input is located on the rear panel. 4. Launch a serial communication tool to access your embedded computer. We suggest that you use HyperTerminal, which is built into Windows XP. Click Start Programs Accessories Communications and then select HyperTerminal. 5. After HyperTerminal launches, enter UC-8410 or another name for the connection. 6.
UC-8410/8416/8418/8430 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. 9. 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.
UC-8410/8416/8418/8430 Firmware Upgrade Procedure 10. Click the Settings tab and then select VT100 (for Emulation). Click OK to complete the configuration. 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.
UC-8410/8416/8418/8430 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/8430 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. 5. Next, connect LAN1 of the embedded computer to your PC using a cross-over Ethernet cable.
UC-8410/8416/8418/8430 Firmware Upgrade Procedure 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. 1. In the boot loader utility, select [0] Network Configuration, and then [0] Change IP Setting to configure IP addresses.
UC-8410/8416/8418/8430 Firmware Upgrade Procedure 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. b. Right-click on Local Area Connection, and then select Properties.
UC-8410/8416/8418/8430 Firmware Upgrade Procedure c. Click the General tab and select Internet Protocol (TCP/IP), and then click on Properties. 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/8430 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. Select [z] Quit to command line to exit the IP setting option.
UC-8410/8416/8418/8430 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/8430 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. 9. It will take several minutes for the firmware files to be written to your embedded computer.
UC-8410/8416/8418/8430 Firmware Upgrade Procedure 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. 11. If you cannot reboot your embedded computer (after following all the steps above), contact Moxa’s technical support staff for further assistance.
B B. System Commands Linux Normal Command Utility Collection File Manager cp copy file ls list file ln make symbolic link file mount mount and check file system rm delete file chmod change file owner & group & user chown change file owner chgrp change file group chroot runs a command with a specified root directory.
UC-8410/8416/8418/8430 System Commands awk pattern-directed scanning and processing language expand Converts all tabs to spaces tail Print the last 10 lines of each FILE to standard output. tar The GNU version of the tar archiving utility tr Translate, squeeze, and/or delete characters wc Print byte, word, and line counts, count the number of bytes, whitespace-separated words, and newlines in each given FILE, or standard input if non are given or for a FILE of ‘-’.
UC-8410/8416/8418/8430 System Commands halt halt the server du estimate file space usage gzip, gunzip compress or expand files hostname show system’s host namebasename return filename or directory portion of pathname dirname Convert a full pathname to just a path expr evaluate arguments as an expression false Do nothing, returning a non-zero (false) exit status true Do nothing, successfully fdisk Partition table manipulator for Linux hwclock A tool for accessing the Hardware Clock id