ThinkCore IA241/240 Linux User’s Manual First Edition, July 2006 www.moxa.com/product MOXA Systems Co., Ltd. Tel: +886-2-8919-1230 Fax: +886-2-8919-1231 Web: www.moxa.com MOXA Technical Support Worldwide: support@moxa.
ThinkCore IA241/240 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 © 2006 Moxa Systems Co., Ltd. All rights reserved. Reproduction without permission is prohibited. Trademarks MOXA is a registered trademark of The Moxa Group. 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)....................................................
IPTABLES ............................................................................................................................... 4-6 NAT.........................................................................................................................................4-11 NAT Example ........................................................................................................... 4-11 Enabling NAT at Bootup ..............................................................................
Problem Report Form ..............................................................................................................B-3 Product Return Procedure ........................................................................................................
1 Chapter 1 Introduction The MOXA ThinkCore IA241 and IA240 are RISC-based ready-to-run embedded computers. Available features include four RS-232/422/485 serial ports, dual 10/100 Mbps Ethernet ports, PCMCIA, SD socket for storage expansion and USB 2.0 host making IA241/240 ideal for your embedded applications.
ThinkCore IA241/240 Linux User’s Manual Introduction Overview The ThinkCore IA241/IA240 embedded computers, which are designed for industrial automation applications, feature 4 RS-232/422/485 serial ports, dual Ethernet ports, 4 digital input channels, 4 digital output channels, and a PCMCIA cardbus and SD socket. The computers come in a compact, IP30 protected, industrial-strength rugged chassis.
ThinkCore IA241/240 Linux User’s Manual AP API OS Kernel Protocol Stack Device Driver Microkernel Hardware Introduction User Application Daemon (Apache, Telnet, FTPD, SNMP) Application Interface (POSIX, Socket, Secure Socket) TCP, IP, UDP, CMP, ARP, HTTP, SNMP, SMTP PCMCIA, CF, WLAN, USB, UART, RTC, LCM, Keypad File System Memory control, Schedule, Process RS-232/422/485, Ethernet, PCMCIA, CompactFlash, USB The IA241/240’s built-in Flash ROM is partitioned into Boot Loader, Linux Kernel, Root
ThinkCore IA241/240 Linux User’s Manual Introduction inside the file system design, and support for hard links. The key features of JFFS2 are: y Targets the Flash ROM Directly y Robustness y Consistency across power failures y No integrity scan (fsck) is required at boot time after normal or abnormal shutdown y Explicit wear leveling y Transparent compression Although JFFS2 is a journaling file system, this does not preclude the loss of data.
2 Chapter 2 Getting Started In this chapter, we explain how to connect the IA241/240, how to turn on the power, how to get started programming, and how to use the IA241/240’s other functions.
ThinkCore IA241/240 Linux User’s Manual Getting Started Powering on the IA241/240 Connect the SG wire to the shielded contact located in the upper left corner of the IA241/240, 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. NOTE After connecting the IA241/240 to the power supply, it will take about 30 to 60 seconds for the operating system to boot up.
ThinkCore IA241/240 Linux 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 two IP addresses and netmasks, then you can use Telnet to connect to the IA241/240’s console utility. The default IP address and Netmask for each of the two ports are given below: LAN 1 LAN 2 Default IP Address 192.
ThinkCore IA241/240 Linux User’s Manual Getting Started You can proceed with configuring the 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 the cable CBL-RJ45F9-150, which comes with the IA241/240, to connect to the serial console port.
ThinkCore IA241/240 Linux User’s Manual Getting Started Linux Users From a Linux machine, use the “ssh” command to access the IA241/240’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.
ThinkCore IA241/240 Linux User’s Manual Getting Started Configuring the Ethernet Interface The network settings of the IA241/240 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 the network settings of the target computer. 1.
ThinkCore IA241/240 Linux User’s Manual Getting Started 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.255 3. Dynamic Setting using DHCP iface eth0 inet dhcp After the boot settings of the LAN interface have been modified, issue the following command to activate the LAN settings immediately: #/etc/init.
ThinkCore IA241/240 Linux User’s Manual 3. Getting Started Additional WLAN parameters are contained in the file RT2500STA.dat. To open the file, navigate to the RT2500STA folder and invoke vi, or type the command #vi /etc/Wireless/RT2500STA/RT2500STA.dat to edit the file with vi editor. Options for the various parameters are listed below the figure.
ThinkCore IA241/240 Linux User’s Manual Getting Started CountryRegion—Sets the channels for your particular country / region Setting Explanation 0 use channels 1 to 11 1 use channels 1 to 11 2 use channels 1 to 13 3 use channels 10, 11 4 use channels 10 to 13 5 use channel 14 6 use channels 1 to 14 7 use channels 3 to 9 WirelessMode—Sets the wireless mode Setting Explanation 0 11b/g mixed 1 11b only 2 11g only SSID—Sets the softAP SSID Setting Any 32-byte string NetworkType—Sets the
ThinkCore IA241/240 Linux User’s Manual Getting Started EncrypType—Sets encryption type Setting NONE WEP TKIP AES DefaultKeyID—Sets default key ID Setting 1 to 4 Key1Str, Key2Str, Key3Str, Key4Str—Sets strings Key1 to Key4 Setting The keys can be input as 5 ascii characters, 10 hex numbers, 13 ascii characters, or 26 hex numbers TxBurst—WPA pre-shared key Setting 8 to 64 ascii characters WpaPsk—Enables or disables TxBurst Setting Explanation 0 disable 1 enable TurboRate—Enables or disables TurboRate S
ThinkCore IA241/240 Linux User’s Manual Getting Started TxRate—Sets the TxRate Setting Explanation 0 Auto 1 1 Mbps 2 2 Mbps 3 5.5 Mbps 4 11 Mbps 5 6 Mbps 6 9 Mbps 7 12 Mbps 8 18 Mbps 9 24 Mbps 10 36 Mbps 11 48 Mbps 12 54 Mbps RTSThreshold—Sets the RTS threshold Setting 1 to 2347 FragThreshold—Sets the fragment threshold Setting 256 to 2346 SD Socket and USB for Storage Expansion Both the IA241 and IA240 provide an SD socket for storage expansion.
ThinkCore IA241/240 Linux User’s Manual Getting Started Test Program—Developing Hello.c In this section, we use the standard “Hello” programming example to illustrate how to develop a program for the IA241/240. In general, program development involves the following seven steps. Step 1: Connect the IA241/240 to a Linux PC. Step 2: Install Tool Chain (GNU Cross Compiler & glibc). Step 3: Set the cross compiler and glibc environment variables. Step 4: Code and compile the program.
ThinkCore IA241/240 Linux User’s Manual Getting Started Checking the Flash Memory Space If the flash memory is full, you will not be able to save data to the Flash ROM. Use the following command to calculate the amount of “Available” flash memory: />df –h If there isn’t enough “Available” space for your application, you will need to delete some existing files.
ThinkCore IA241/240 Linux User’s Manual Getting Started the GDB debug tool). NOTE Since Moxa’s tool chain places a specially designed Makefile in the directory /tmp/example/hello, be sure to type the #make command from within that directory. This special Makefile uses the mxscale-gcc compiler to compile the hello.c source code for the Xscale environment. If you type the #make command from within any other directory, Linux will use the x86 compiler (for example, cc or gcc).
ThinkCore IA241/240 Linux User’s Manual Getting Started Testing Environment The tcps2 example demonstrates a simple application program that delivers transparent, bi-directional data transmission between the IA241/240’s serial and Ethernet ports. As illustrated in the following figure, the purpose of this application is to transfer data between PC 1 and the IA241/240 via an RS-232 connection.
ThinkCore IA241/240 Linux User’s Manual Getting Started root@server11:/home/ia240241/1st_application [root@server11 1st_application]# pwd /home/ia240241/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.
ThinkCore IA241/240 Linux User’s Manual Getting Started 530 Please login with USER and PASS. KERBEROS_V4 rejected as an authentication type Name (192.168.3.127: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> bin 200 Type set to I. ftp> put tcps2-release local: tcps2-release remote: tcps2-release 277 Entering Passive Mode (192.168.3.127.82.253) 150 Opening BINARY mode data connection for tcps2-release.
ThinkCore IA241/240 Linux User’s Manual Getting Started root@Moxa:~# NOTE Use the kill command for job number 1 to terminate this program: #kill %1 #ps -ef // use this command to check if the program is running 192.168.3.127 – PuTTY [1]+ Running .
ThinkCore IA241/240 Linux User’s Manual Getting Started The testing environment is illustrated in the following figure. However, note that there are limitations to the example program tcps2.c. PC 1 PC 2 RS-232 LAN tcps2.c Read serial data Write data to PC1 NOTE Serial Rx Buffer LAN Rx Buffer Send data to PC2 Receive LAN data The tcps2.
3 Chapter 3 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 IA241/240 units.
ThinkCore IA241/240 Linux User’s Manual Managing Embedded Linux System Version Information To determine the hardware capability of your IA241/240, and what kind of software functions are supported, check the version numbers of your IA241/240’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 IA241/240’s bottom label. To check the kernel version, type: #kversion 192.168.3.
ThinkCore IA241/240 Linux User’s Manual Managing Embedded Linux /dev/mtdblock3 6.0M 488.0k 5.5M /dev/mtdblock3 6.0M 488.0k 5.5M /dev/mtdblock3 6.0M 488.0k 5.5M tmpfs 30.4M 0 30.4M /dev/ram1 16.0M 1.0k 15.1M 0% root@Moxa:~# cd /mnt/ramdisk root@Moxa:/mnt/ramdisk# 8% /tmp 8% /home 8% /etc 0% /dev/shm /mnt/ramdisk The following instructions give the steps required to save the firmware file to the IA241/240’s RAM disk and how to upgrade the firmware. 1.
ThinkCore IA241/240 Linux User’s Manual 3. Managing Embedded Linux Next, use the upfirm command to upgrade the kernel and root file system: #upfirm ia240-x.x.x.frm 192.168.3.127 – PuTTY root@Moxa:/mnt/ramdisk# upfirm ia240-1.0.frm Moxa ThinkCore IA240 upgrade firmware utility version 1.0. To check source firmware file context. The source firmware file conext is OK. This step will destroy all your firmware. Continue ? (Y/N) : Y Now upgrade the file [kernel]. Format MTD device [/dev/mtd1] . . .
ThinkCore IA241/240 Linux User’s Manual Managing Embedded Linux Deploying the User Directory to Additional IA241/240 Units For some applications, you may need to ghost one IA241/240 user file system to other IA241/240 units. Back up the user file system to a PC (refer to the previous subsection, Backing Up the User File System, for instructions), and then type the following commands to copy the backup to additional IA241/240 units. #upramdisk #cd /mnt/ramdisk #upfirm usrfs-backup 192.168.3.
ThinkCore IA241/240 Linux User’s Manual Managing Embedded Linux Type the command “ps –ef” to list all processes currently running. 192.168.3.
ThinkCore IA241/240 Linux User’s Manual 25 root 27 root 26 root 604 root 609 root 611 root 625 root 673 root 674 root 679 root 682 bin 685 root 690 root 694 nobody 695 nobody 696 nobody 697 nobody 698 nobody 701 root 714 root 726 root 727 root 783 root root@Moxa:~# SW SW< SW SW SW SW SWN 500 S 1264 S 3004 S 380 S 1176 S 464 S 3012 S 3012 S 3012 S 3012 S 3012 S 352 S 1176 S 436 S 1180 S 628 R Managing Embedded Linux [pdflush] [aio/0] [kswapd0] [mtdblockd] [pccardd] [pccardd] [jffs2_gcd_mtd3] /bin/inetd /r
ThinkCore IA241/240 Linux User’s Manual Managing Embedded Linux KxxRUNFILE stands for K: start the run file while linux shuts down or halts. xx: a number between 00-99. Smaller numbers have a higher priority. RUNFILE: the file name. To remove the daemon, remove the run file from the /etc/rc.d/rc3.d directory by using the following command: #rm –f /etc/rc.d/rc3.d/S60tcps2 Adjusting the System Time Setting the Time Manually The IA241/240 has two time settings.
ThinkCore IA241/240 Linux User’s Manual Managing Embedded Linux Visit http://www.ntp.org for more information about NTP and NTP server addresses. 10.120.53.100 – PuTTY root@Moxa:~# date ; hwclock Sat Jan 1 00:00:36 CST 2000 Sat Jan 1 00:00:37 2000 -0.772941 seconds root@Moxa:~# ntpdate time.stdtion.gov.tw 9 Dec 10:58:53 ntpdate[207]: step time server 220.130.158.52 offset 155905087.9 84256 sec root@Moxa:~# hwclock -w root@Moxa:~# date ; hwclock Thu Dec 9 10:59:11 CST 2004 Thu Dec 9 10:59:12 2004 -0.
ThinkCore IA241/240 Linux User’s Manual mm min 0-59 h hour 0-23 dom date 1-31 mon month 1-12 Managing Embedded Linux dow week 0-6 (0 is Sunday) user user command command The following example demonstrates how to use Cron. How to use cron to update the system time and RTC time every day at 8:00. STEP1: Write a shell script named fixtime.sh and save it to /home/. #!/bin/sh ntpdate time.nist.gov hwclock –systohc exit 0 STEP2: Change mode of fixtime.sh #chmod 755 fixtime.sh STEP3: Modify /etc/cron.
4 Chapter 4 Managing Communications In this chapter, we explain how to configure the IA241/240’s various communication functions.
ThinkCore IA241/240 Linux User’s Manual Managing Communication Telnet / FTP In addition to supporting Telnet client/server and FTP client/server, the IA241/240 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.
ThinkCore IA241/240 Linux User’s Manual Managing Communication /home/httpd/cgi-bin/ Before you modify the homepage, use a browser (such as Microsoft Internet Explore or Mozilla Firefox) from your PC to test if the Apache Web Server is working. Type the LAN1 IP address in the browser’s address box to open the homepage. E.g., if the default IP address is still active, type http://192.168.3.127 in the address box. To open the default CGI page, type http://192.168.3.
ThinkCore IA241/240 Linux User’s Manual Managing Communication 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. When you develop your own CGI application, make sure your CGI file is executable. 192.168.3.
ThinkCore IA241/240 Linux User’s Manual Managing Communication 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 /dev/mtdblock2 8.0M /dev/ram0 499.0k /dev/mtdblock3 6.0M /dev/mtdblock3 6.0M /dev/mtdblock3 6.0M tmpfs 30.4M /dev/ram1 16.0M root@Moxa:/bin# Used Available Use% Mounted on 6.0M 2.0M 75% / 18.0k 456.0k 4% /var 488.0k 5.5M 8% /tmp 488.0k 5.5M 8% /home 488.0k 5.5M 8% /etc 0 30.
ThinkCore IA241/240 Linux User’s Manual Managing Communication Step 5: Run ‘install.sh’ and select to install php 192.168.3.127 – PuTTY root@Moxa:/mnt/ramdisk# ./install.sh Press the number: 1. Install PHP package 2. Uninstall PHP package 3. Exit. 1 Start to install PHP. Please wait ... Starting web server: apache. PHP install sucess. root@Moxa:/mnt/ramdisk# Step 6: Test it. Use the browser to access http://192.168.3.127/phpinfo.
ThinkCore IA241/240 Linux User’s Manual Managing Communication 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. A rule (such as a jump to a user-defined chain in the same table) is called a “target.” The IA241/240 supports 3 types of IPTABLES table: Filter tables, NAT tables, and Mangle tables: A. Filter Table—includes three chains: INPUT chain OUTPUT chain FORWARD chain B.
ThinkCore IA241/240 Linux User’s Manual Managing Communication Incoming Packets Mangle Table PREROUTING Chain NAT Table PREROUTING Chain Local Host Packets Other Host Packets Mangle Table INPUT Chain Mangle Table FORWARD Chain Filter Table INPUT Chain Filter Table FORWARD Chain Local Process Mangle Table POSTROUTING Chain Mangle Table OUTPUT Chain NAT Table OUTPUT Chain Filter Table OUTPUT Chain NAT Table POSTROUTING Chain Outgoing Packets The IA241/240 supports the following sub-modules.
ThinkCore IA241/240 Linux User’s Manual NOTE Managing Communication The IA241/240 does NOT support IPV6 and ipchains. The basic syntax to enable and load an IPTABLES module is as follows: #lsmod #insmod ip_tables #insmod iptable_filter Use lsmod to check if the ip_tables module has already been loaded in the IA241/240. Use insmod to insert and enable the module.
ThinkCore IA241/240 Linux User’s Manual Managing Communication Define policy for chain rules Usage: # iptables [-t tables] [-P] [INPUT, OUTPUT, FORWARD, PREROUTING, OUTPUT, POSTROUTING] [ACCEPT, DROP] -P: Set the policy for the chain to the given target. INPUT: For packets coming into the IA241/240. OUTPUT: For locally-generated packets. FORWARD: For packets routed out through the IA241/240. PREROUTING: To alter packets as soon as they come in.
ThinkCore IA241/240 Linux User’s Manual Managing Communication # iptables –A INPUT –i eth0 –p tcp --dport 25 –j LOG Example 8: Drop all packets from MAC address 01:02:03:04:05:06. # iptables –A INPUT –i eth0 –p all –m mac –mac-source 01:02:03:04:05:06 –j DROP NOTE: In Example 8, remember to issue the command #modprobe ipt_mac first to load module ipt_mac. NAT NAT (Network Address Translation) protocol translates IP addresses used on one network to different IP addresses used on another network.
ThinkCore IA241/240 Linux 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 IA241/240 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.
ThinkCore IA241/240 Linux User’s Manual Managing Communication #pppd connect ‘chat -v “ “ ATDT5551212 CONNECT” “ ogin: username word: password’ /dev/ttyM0 115200 debug crtscts modem defaultroute If the PPP server does not prompt for the username and password, the command should be entered as follows. Replace username with the correct username and replace password with the correct password.
ThinkCore IA241/240 Linux User’s Manual Managing Communication Example 2: Connecting to a PPP server over a hard-wired link If a username and password are not required, use the following command (note that noipdefault is optional): #pppd connect ‘chat –v” “ “ “ ‘ noipdefault /dev/ttyM0 19200 crtscts If a username and password is required, use the following command (note that noipdefault is optional, and root is both the username and password): #pppd connect ‘chat –v” “ “ “ ‘ user root password root noipd
ThinkCore IA241/240 Linux User’s Manual ppp0 127.0.0.0 0.0.0.0 ppp0 0.0.0.0 129.67.1.165 255.0.0.0 0.0.0.0 Managing Communication U UG 0 0 0 0 0 lo 6298 If your output looks similar but doesn’t have the destination 0.0.0.0 line (which refers to the default route used for connections), you may have run pppd without the ‘defaultroute’ option. At this point you can try using Telnet, ftp, or finger, bearing in mind that you’ll have to use numeric IP addresses unless you’ve set up /etc/resolv.
ThinkCore IA241/240 Linux User’s Manual 5. Managing Communication “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.
ThinkCore IA241/240 Linux User’s Manual 6. Managing Communication 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. If you use LAN2 to connect to the ADSL modem, then add /etc/ppp/options.eth1.
ThinkCore IA241/240 Linux User’s Manual NOTE Managing Communication Click on the following links for more information about NFS: http://www.tldp.org/HOWTO/NFS-HOWTO/index.html http://nfs.sourceforge.net/nfs-howto/client.html http://nfs.sourceforge.net/nfs-howto/server.html Setting up the IA241/240 as an NFS Client The following procedure is used to mount a remote NFS Server. 1. 2. 3. To know the NFS Server’s shared directory. Establish a mount point on the NFS Client site.
ThinkCore IA241/240 Linux User’s Manual 3: sysUpTime.0 (timeticks) 0 days 03h:50m:11s.00th (1381100) 4: sysContact.0 (octet string) Moxa Systems Co., LDT. 5: sysName.0 (octet string) Moxa 6: sysLocation.0 (octet string) Unknown 7: sysServices.0 (integer) 6 8: ifNumber.0 (integer) 6 9: ifIndex.1 (integer) 1 10: ifIndex.2 (integer) 2 11: ifIndex.3 (integer) 3 12: ifIndex.4 (integer) 4 13: ifIndex.5 (integer) 5 14: ifIndex.6 (integer) 6 15: ifDescr.1 (octet string) eth0 16: ifDescr.
ThinkCore IA241/240 Linux User’s Manual 70: ifInUcastPkts.2 (counter) 28224 71: ifInUcastPkts.3 (counter) 0 72: ifInUcastPkts.4 (counter) 0 73: ifInUcastPkts.5 (counter) 0 74: ifInUcastPkts.6 (counter) 0 75: ifInNUcastPkts.1 (counter) 0 76: ifInNUcastPkts.2 (counter) 0 77: ifInNUcastPkts.3 (counter) 0 78: ifInNUcastPkts.4 (counter) 0 79: ifInNUcastPkts.5 (counter) 0 80: ifInNUcastPkts.6 (counter) 0 81: ifInDiscards.1 (counter) 0 82: ifInDiscards.2 (counter) 0 83: ifInDiscards.3 (counter) 0 84: ifInDiscards.
ThinkCore IA241/240 Linux User’s Manual Managing Communication 137: ifSpecific.3 (object identifier) (null-oid) zeroDotZero 138: ifSpecific.4 (object identifier) (null-oid) zeroDotZero 139: ifSpecific.5 (object identifier) (null-oid) zeroDotZero 140: ifSpecific.6 (object identifier) (null-oid) zeroDotZero 141: atIfIndex.1.192.168.27.139 (integer) 1 142: atIfIndex.2.192.168.4.127 (integer) 2 143: atPhysAddress.1.192.168.27.139 (octet string) 00.90.E8.10.02.41 (hex) 144: atPhysAddress.2.192.168.4.
ThinkCore IA241/240 Linux User’s Manual Managing Communication 204: ipNetToMediaPhysAddress.1.192.168.27.139 (octet string) 00.90.E8.10.02.41 (hex) 205: ipNetToMediaPhysAddress.2.192.168.4.127 (octet string) 00.90.E8.10.02.40 (hex) 206: ipNetToMediaNetAddress.1.192.168.27.139 (ipaddress) 192.168.27.139 207: ipNetToMediaNetAddress.2.192.168.4.127 (ipaddress) 192.168.4.127 208: ipNetToMediaType.1.192.168.27.139 (integer) static(4) 209: ipNetToMediaType.2.192.168.4.
ThinkCore IA241/240 Linux User’s Manual Managing Communication 271: tcpConnLocalAddress.192.168.27.139.1025.0.0.0.0.0 (ipaddress) 192.168.27.139 272: tcpConnLocalAddress.192.168.4.127.1025.0.0.0.0.0 (ipaddress) 192.168.4.127 273: tcpConnLocalAddress.192.168.27.139.2049.0.0.0.0.0 (ipaddress) 192.168.27.139 274: tcpConnLocalAddress.192.168.4.127.2049.0.0.0.0.0 (ipaddress) 192.168.4.127 275: tcpConnLocalAddress.192.168.27.139.1026.0.0.0.0.0 (ipaddress) 192.168.27.139 276: tcpConnLocalAddress.192.168.4.127.
ThinkCore IA241/240 Linux User’s Manual 338: tcpConnRemPort.192.168.4.127.9.0.0.0.0.0 (integer) 0 339: tcpConnRemPort.192.168.27.139.111.0.0.0.0.0 (integer) 0 340: tcpConnRemPort.192.168.4.127.111.0.0.0.0.0 (integer) 0 341: tcpConnRemPort.192.168.27.139.80.0.0.0.0.0 (integer) 0 342: tcpConnRemPort.192.168.4.127.80.0.0.0.0.0 (integer) 0 343: tcpConnRemPort.192.168.27.139.21.0.0.0.0.0 (integer) 0 344: tcpConnRemPort.192.168.4.127.21.0.0.0.0.0 (integer) 0 345: tcpConnRemPort.192.168.27.139.22.0.0.0.0.
ThinkCore IA241/240 Linux User’s Manual 405: rs232PortOutSigNumber.2 (integer) 2 406: rs232PortOutSigNumber.3 (integer) 2 407: rs232PortOutSigNumber.4 (integer) 2 408: rs232PortInSpeed.1 (integer) 38400 409: rs232PortInSpeed.2 (integer) 38400 410: rs232PortInSpeed.3 (integer) 38400 411: rs232PortInSpeed.4 (integer) 38400 412: rs232PortOutSpeed.1 (integer) 38400 413: rs232PortOutSpeed.2 (integer) 38400 414: rs232PortOutSpeed.3 (integer) 38400 415: rs232PortOutSpeed.4 (integer) 38400 416: rs232AsyncPortIndex.
ThinkCore IA241/240 Linux User’s Manual Managing Communication 472: rs232OutSigPortIndex.1.4 (integer) 1 [1] 473: rs232OutSigPortIndex.2.4 (integer) 2 [2] 474: rs232OutSigPortIndex.3.4 (integer) 3 [3] 475: rs232OutSigPortIndex.4.4 (integer) 4 [4] 476: rs232OutSigName.1.1 (integer) rts(1) 477: rs232OutSigName.2.1 (integer) rts(1) 478: rs232OutSigName.3.1 (integer) rts(1) 479: rs232OutSigName.4.1 (integer) rts(1) 480: rs232OutSigName.1.4 (integer) dtr(4) 481: rs232OutSigName.2.
ThinkCore IA241/240 Linux User’s Manual Managing Communication # 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. Each Ethernet corresponds to one physical interface (or port) that is connected to the bridge. On each OpenVPN machine, you should generate a working directory, such as /etc/openvpn, where script files and key files reside.
ThinkCore IA241/240 Linux User’s Manual 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 i
ThinkCore IA241/240 Linux User’s Manual Managing Communication # the bridge receives data from any port and forwards it to other ports. i=`expr 0` while : do # generate a tap0 interface on tun openvpn --mktun --dev tap${i} # connect tap device to the bridge brctl addif br0 tap${i} # 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.
ThinkCore IA241/240 Linux User’s Manual Managing Communication exit 1 esac exit 0 #---------------------------------- end ----------------------------- Create link symbols to enable this script at boot time: # ln -s /etc/openvpn/openvpn-bridge /etc/rc.d/rc3.d/S32vpn-br # for example # ln -s /etc/openvpn/openvpn-bridge /etc/rc.d/rc6.d/K32vpn-br # for example 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.
ThinkCore IA241/240 Linux User’s Manual 5. Managing Communication On each OpenVPN machine, check the routing table by typing the command: # route Destination 192.168.4.0 192.168.2.0 192.168.8.0 Gateway Genmsk * 255.255.255.0 * 255.255.255.0 * 255.255.255.0 Flags U U U Metric 0 0 0 Ref 0 0 0 Use 0 0 0 Iface br0 br0 eth0 Interface eth1 is connected to the bridging interface br0, to which device tap0 also connects, whereas the virtual device tun sits on top of tap0.
ThinkCore IA241/240 Linux User’s Manual 2. Managing Communication 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/A-tap0-br.conf” and “/etc/openvpn/B-tap0-br.conf”. Setup 3: Routed IP 1. Set up four machines as shown in the following diagram: Host A local net OpenVPN A LAN1: 192.168.2.173 LAN1: 192.168.2.171 Internet LAN2: 192.168.8.173 LAN1: 192.168.8.174 LAN1: 192.168.4.
ThinkCore IA241/240 Linux User’s Manual Managing Communication # 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. Note that $5 is the argument that the OpenVPN program passes to the script file.
5 Chapter 5 Development Tool Chains 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 IA241/240 embedded computer is called a target computer.
ThinkCore IA241/240 Linux User’s Manual Development Tool Chains Linux Tool Chain The Linux tool chain contains a suite of cross compilers and other tools, as well as the libraries and header files that are necessary to compile your applications. These tool chain components must be installed in your host computer (PC) running Linux. We have confirmed that the following Linux distributions can be used to install the tool chain. Fefora core 1 & 2.
ThinkCore IA241/240 Linux User’s Manual size Development Tool Chains Lists object file section sizes strings Prints strings of printable characters from files (usually object files) 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.
ThinkCore IA241/240 Linux User’s Manual -rw-r--r-- 1 drwxr—xr-x 5 -rwxr—xr-x 1 -rw-r--r-- 1 drwxr—xr-x 2 drwxr—xr-x 14 drwxr—xr-x 6 stephen_ stephen_ stephen_ stephen_ stephen_ stephen_ stephen_ mkpasswd mkpasswd mkpasswd mkpasswd mkpasswd mkpasswd mkpasswd Development Tool Chains 3262 Jan 10 22:03 insight.ico 0 Jan 10 19:48 lib 53 Jan 10 22:03 moxa.bat 3262 Jan 10 22:03 moxa.
ThinkCore IA241/240 Linux User’s Manual 2. Development Tool Chains Browse to the directory where you prefer to set the root directory for the tool chain. Options of All Users and Unix are recommended. Then, choose Next. If you have installed a tool chain before, its root directory would show up in the Root Directory text field. If you continue the installation, the new tool chain in a previous root directory would override the old one. Choose a different directory to keep both tool chains. 3.
ThinkCore IA241/240 Linux User’s Manual 4. Development Tool Chains All packages are selected by default. Choose Next to continue. y Category column: Shows a hierarchical display of packages with category name highest and package name lowest. Click the plus sign (+) next to a category name to open the category and see the packages within that category. y Base Category: List all packages that will be installed by default (along with any dependencies).
ThinkCore IA241/240 Linux User’s Manual Development Tool Chains 5. The Progress window opens. The installer will install all packages that were selected. This process could take from 5 to 30 minutes, depending on the speed of your system. When the installation completes, the Complete the Installation window will appear. 6. Checkmark Create icon on Desktop to place a Moxa BASH Shell icon on your desktop, and then click on Finish.
ThinkCore IA241/240 Linux User’s Manual 7. Development Tool Chains Click on OK to complete the installation process. Using the BASH Shell A command-line interface is used to develop applications with the tool chain. To access the command line, you need to launch a BASH shell window. To open a BASH shell window, choose Start Menu Æ Programs Æ UC Tool Chain Æ Moxa Bash Shell, or lick on the desktop Moxa Bash Shell icon. / Your group is currently “mkpasswd”.
ThinkCore IA241/240 Linux User’s Manual Development Tool Chains / Mkpasswd –l [-d] > /etc/passwd Mkgroup –l [-d] > /etc/group Note that the –d switch is necessary for domain users.
ThinkCore IA241/240 Linux User’s Manual Development Tool Chains After that, use FTP to upload the executable file to the UC, and then run the executable. /hello ftp> bye Jared_Wu@Jared_Wu /hello $ ftp 192.168.14.9 Connected to 192.168.14.9. 220 Moxa FTP server Mon Nov 24 12:17:04 CST 2003> ready. User <192.168.14.9:>: root 331 Password required for root. Password: 230 User root logged in. ftp> bin 200 PORT command successful.
ThinkCore IA241/240 Linux User’s Manual 5-11 Development Tool Chains
6 Chapter 6 Programmer’s Guide This chapter includes important information for programmers.
ThinkCore IA241/240 Linux User’s Manual Programmer’s Guide Flash Memory Map Partition sizes are hard coded into the kernel binary. To change the partition sizes, you will need to rebuild the kernel. The flash memory map is shown in the following table. Address 0x00000000 – 0x0003FFFF 0x00040000 – 0x001FFFFF 0x00200000 – 0x009FFFFF 0x00A00000 – 0x00FFFFFF Size 256 KB 1.
ThinkCore IA241/240 Linux User’s Manual Programmer’s Guide ioctl(fd, KDMKTONE, unsigned int arg); Description: The buzzer’s behavior is determined by the argument arg. The “high word” part of arg gives the length of time the buzzer will sound, and the “low word” part gives the frequency. The buzzer’s on / off behavior is controlled by software. If you call the “ioctl” function, you MUST set the frequency at 100 Hz. If you use a different frequency, the system could crash. WDT (Watch Dog Timer) 1.
ThinkCore IA241/240 Linux User’s Manual Programmer’s Guide Output OK will be zero. The other has some error, to get the error code from errno(). int swtd_disable(int fd) Description Disable the application to ack sWatchDog. And the kernel will be auto ack it. User does not to do it at periodic. 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.
ThinkCore IA241/240 Linux User’s Manual Programmer’s Guide Output OK will be zero. The other has some error, to get error code from errno(). 4. Special Note 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.
ThinkCore IA241/240 Linux User’s Manual Programmer’s Guide time.tv_sec = msec / 1000; time.
ThinkCore IA241/240 Linux User’s Manual 1. Programmer’s Guide Function: MOXA_SET_OP_MODE int ioctl(fd, MOXA_SET_OP_MODE, &mode) Description Set the interface mode. Argument 3 mode will pass to the UART device driver and change it. 2. Function: MOXA_GET_OP_MODE int ioctl(fd, MOXA_GET_OP_MODE, &mode) Description Get the interface mode. Argument 3 mode will return the interface mode. There are two Moxa private ioctl commands for setting up special baudrates.
ThinkCore IA241/240 Linux User’s Manual Programmer’s Guide Special Note 1. If the target baudrate is not a special baudrate (e.g. 50, 75, 110, 134, 150, 200, 300, 600, 1200, 1800, 2400, 4800, 9600, 19200, 38400, 57600, 115200, 230400, 460800, 921600), the termios cflag will be set to the same flag. 2. If you use stty to get the serial information, you will get speed equal to 0. DI/DO int set_dout_state(int doport, int state) Description Set the digital output state to high or low.
ThinkCore IA241/240 Linux User’s Manual Programmer’s Guide to except the error signal. If you set to zero, it will not detect the duration time. You can set 40 ms to 3600000 ms by increase 20 ms. Output OK will be zero. Digital Input Signal DIN_EVENT_HIGH_TO_LOW duration int get_din_event(int diport, int *mode, long int *duration) Description Get the set event for digital input port. Input int diport - the digital output port number. It is 0 to 3. int *mode - Save the set event.
ThinkCore IA241/240 Linux User’s Manual Programmer’s Guide Example 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, then the detect and count the state changed events from DI1.(OK) #include #include #include #include #ifdef DEBUG #define dbg_printf(x...) printf(x) #else #define dbg_printf(x...
ThinkCore IA241/240 Linux User’s Manual Programmer’s Guide } printf(“\n”); } else if ( i == 3 ) { // set low to high event printf(“Please keyin the DIN number : “); scanf(“%d”, &i); printf(“Please input the DIN duration, this minimun value must be over %d : “,MIN_DURATION); 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_EVE
ThinkCore IA241/240 Linux User’s Manual Programmer’s Guide Example 2 File Name: tduration.c Description: The program indicates to connect DO1 to DI1 and program will change digital output state automatically at the fixed frequency, then detect event change of the digital input state is high or low in different duration. (OK) #include #include #include #include #include #include #include #include
ThinkCore IA241/240 Linux User’s Manual Programmer’s Guide printf(“1.Test for Din duration!=0.\n”); printf(“9.Quit.\n” ); printf(“Please select a choice>“); scanf(“%d”,&nChoice); if( nChoice == 9 ){ // Quit break; } else if( nChoice == 0 ){ //test for din duration==0 for ( nDuration=0; nDuration < DURATION_NUM; nDuration++ ) { // configure the dout frequency. When the timer timeouts, dout_control() will be called to change the dout state value.it_value.tv_sec = duration[0][nDuration]/1000; value.it_value.
ThinkCore IA241/240 Linux User’s Manual Programmer’s Guide } } } while(1); pthread_exit(NULL); } void init_sigaction(void) { struct sigaction act; act.sa_handler=dout_control; act.sa_flags=0; sigemptyset(&act.
ThinkCore IA241/240 Linux User’s Manual clean: rm -f $(OBJS) hello core *.
7 Chapter 7 Software Lock “Software Lock” is an innovative technology developed by the Moxa engineering force. It can be adopted by a system integrator or developer to protect his applications from being copied. An applicaion is compiled into a binary format bound to the embedded computer and the operating system (OS) that the application runs on. As long as one obtains it from the computer, he/she can install it into the same hardware and the same operating system.
8 Chapter 8 UC Finder UC Finder comes in handy if you forget the IP address of the target computer while you have a demand for troubleshooting field problems. This utility works by sending a broadcast message over the LAN to search for IP addresses of target computers. Two versions of UC Finder are provided. The GUI version works in Windows environments, and the command line utility works in Linux environments.
ThinkCore IA241/240 Linux User’s Manual UC Finder Windows UC Finder The UC Finder utility is used to search the LAN or intranet for Moxa embedded computers. Installing the Software 1. Once the Setup program starts running, click on Next to proceed. 2. Click on Next when the Select Additional Tools window opens to proceed with the installation.
ThinkCore IA241/240 Linux User’s Manual UC Finder 3. Click on Next to install program files in the default directory, or select an alternative location. 4. Click on Finish to complete the installation of UC Finder.
ThinkCore IA241/240 Linux User’s Manual UC Finder Broadcast Search The Broadcast Search function is used to locate all IA241/240 units that are connected to the same LAN as your Windows computer. Since the Broadcast Search function searches by MAC address and not IP address, all IA241/240’s connected to the LAN will be found, regardless of whether or not they are on the same subnet as the host. 1. Click o n the Broadcast Search button to start searching. 2.
ThinkCore IA241/240 Linux User’s Manual 3. NOTE UC Finder When the search is complete, the same information is displayed in the UC Finder window. UC Finder is designed to determine the IP addresses of all UC units connected to the same LAN the host that is running UC Finder. To configure UC’s IP addresses or other configuration parameters, use Telnet over the network, or connect directly to the serial Console port to access IA241/240’s Console utility.
A Appendix A System Commands busybox (V0.60.4): Linux normal command utility collection File manager 1. 2. 3. 4. 5. 6. 7. 8. 9. 10. 11. 12. 13. 14.
ThinkCore IA241/240 Linux User’s Manual Process 1. 2. kill ps kill process display now running process 1. 2. 3. 4. 5. 6. 7. 8. 9. 10. 11. 12. 13. dmesg sty zcat mknod free date env clear reboot halt du gzip, gunzip hostname dump kernel log message to set serial port dump .
B Appendix B Service Information This appendix shows you how to contact Moxa for information about this and other products, and how to report problems.
ThinkCore IA241/240 Linux User’s Manual Service Information MOXA Internet Services Customer satisfaction is our number one concern, and to ensure that customers receive the full benefit of our products, Moxa Internet Services has been set up to provide technical support, driver updates, product information, and user’s manual updates. The following services are provided E-mail for technical support................................support@moxa.com World Wide Web (WWW) Site for product information: .........
ThinkCore IA241/240 Linux User’s Manual Service Information Problem Report Form MOXA ThinkCore IA241/240 Customer name: Company: Tel: Fax: Email: Date: 1. Moxa Product: ThinkCore IA241 2. Serial Number: ThinkCore IA240 _________________ Problem Description: Please describe the symptoms of the problem as clearly as possible, including any error messages you see. A clearly written description of the problem will allow us to reproduce the symptoms, and expedite the repair of your product.
ThinkCore IA241/240 Linux User’s Manual Service Information Product Return Procedure For product repair, exchange, or refund, the customer must: Provide evidence of original purchase. Obtain a Product Return Agreement (PRA) from the sales representative or dealer. Fill out the Problem Report Form (PRF). Include as much detail as possible for a shorter product repair time. Carefully pack the product in an anti-static package, and send it, pre-paid, to the dealer.