All other trademarks or registered marks in this manual belong to their respective manufacturers.
Disclaimer
Information in this document is subject to change without notice and does not represent a commitment on the
part of MOXA.
MOXA provides this document “as is,” without warranty of any kind, either expressed or implied, including, but
not limited to, its particular purpose. MOXA reserves the right to make improvements and/or changes to this
manual, or to the products and/or the programs described in this manual, at any time.
Information provided in this manual is intended to be accurate and reliable. However, MOXA assumes no
responsibility for its use, or for any infringements on the rights of third parties that may result from its use.
This product might include unintentional technical or typographical errors. Changes are periodically made to the
information herein to correct such errors, and these changes are incorporated into new editions of the
publication.
The MOXA ThinkCore W311/321/341 are RISC-based ready-to-run wireless embedded computers
with 802.11a/b/g WLAN, one 10/100 Mbps Ethernet port, an internal SD socket, 1/2/4
RS-232/422/485 serial ports, two USB 2.0 hosts, one relay output channel, and pre-installed Linux
operating system. The W311/321/341 offer high performance communication and unlimited
storage in a super compact, palm-size ARM9 box. The ThinkCore W300 Series is the right
solution for embedded applications that are used in hard-to-wire environments and that require a
large amount of memory, but that must be housed in a small space without sacrificing
performance.
The following topics are covered in this chapter:
Overview
Software Architectur e
¾ Journaling Flash File System (JFFS2)
¾ Software Package
ThinkCore W311/321/341 Linux User’s Manual Introduction
Overview
The ThinkCore W311/321/341 wireless embedded computers support 802.11a/b/g wireless LANs
with data encryption functions, including the common WEP and powerful WPA and WPA2, to
establish a secure transmission tunnel over a WLAN.
ThinkCore W300 Series Embedded Computers use a MOXA ART 192 Mhz RISC CPU. Unlike
the X86 CPU, which uses a CISC design, the RISC architecture and modern semiconductor
technology provide these embedded computers with a powerful computing engine and
communication functions, but without generating a lot of heat. A 16 MB NOR Flash ROM and
on-board SDRAM (64 MB for W341 and 32 MB for W311/321) give you enough memory to
install your application software directly on the embedded computer. In addition, dual LAN ports
are built right into the RISC CPU. This network capability, in combination with the ability to
control serial devices, makes the ThinkCore W300 Series ideal as communication platforms for
data acquisition and industrial control applications.
The pre-installed Linux operating system (OS) pr o vi des an open software operating system for
your software program development. Software written for desktop PCs can be easily ported to the
computer with a GNU cross compiler, without needing to modify the source code. The OS, device
drivers (e.g., serial and buzzer control), and your own applications, can all be stored in the NOR
Flash memory.
Software Architecture
The Linux operating system that is pre-installed in the W311/321/341 follows the standard Linux
architecture, making it easy to accept programs that follow the POSIX standard. Program porting
is done with the GNU Tool Chain provided by MOXA. In addition to Standard POSIX APIs,
device drivers for the USB storage, buzzer and Network controls, and UART are also included in
the Linux OS.
AP
API
Protocol
Stack
Device
Driver
Microkernel
OS Kernel
Hardware
The W311/321/341’s built-in Flash ROM is partitioned into Boot Loader, Linux Kernel, Root
File System, and User directory partitions.
In order to prevent user applications from crashing the Root File System, the W311/321/341 use a
specially designed Root File System with Protected Configuration for emergency use. This
Root File System comes with serial and Ethernet communication capability for users to load the
RS-232/422/485, Ethernet, PCMCIA, CompactFlash, USB
Daemon (Apache, Telnet, FTPD, SNMP)
File
System
1-2
ThinkCore W311/321/341 Linux User’s Manual Introduction
Factory Default Image file. The user directory saves the user’s settings and application.
To improve system reliability, the W311/321/341 have a built-in mechanism that prevents the
system from crashing. When the Linux kernel boots up, the kernel will mount the root file system
for read only, and then enable services and daemons. At the same 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. This type of setup creates a “safe” zone.
For more information about the memory map and programming, refer to Chapter 6, Programmer’s Guide.
Journaling Flash File System (JFFS2)
The Root File System and User directory in the flash memory is formatted with the Journaling
Flash File System (JFFS2). The formatting process places a compressed file system in the flash
memory. This operation is transparent to the user.
The Journaling Flash File System (JFFS2), which was developed by Axis Communications in
Sweden, puts a file system directly on the flash, instead of emulating a block device. It is designed
for use on flash-ROM chips and recognizes the special write requirements of a flash-ROM chip.
JFFS2 implements wear-leveling to extend the life of the flash disk, and stores the flash directory
structure in the RAM. A log-structured file system is maintained at all times. The system is always
consistent, even if it encounters crashes or improper power-downs, and does not require fsck (file
system check) on boot-up.
JFFS2 is the newest version of JFFS. It provides improved wear-leveling and garbage-collection
performance, improved RAM footprint and response to system-memory pressure, improved
concurrency and support for suspending flash erases, marking of bad sectors with continued use of
the remaining good sectors (enhancing the write-life of the devices), native data compression
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. The file system
will remain in a consistent state across power failures and will always be mountable. However, if
the board is powered down during a write then the incomplete write will be rolled back on the next
boot, but writes that have already been completed will not be affected.
Additional information about JFFS2 is available at:
ThinkCore W311/321/341 Linux User’s Manual Introduction
Software Package
Boot Loader
Kernel
Protocol Stack
File System
OS shell command
BusyboxLinux normal command utility collection
Utilities
tinylogin login and user manager utility
telnet telnet client program
ftp FTP client program
smtpclient email utility
scp Secure file transfer Client Program
Daemons
pppd dial in/out over serial port daemon
snmpd snmpd agent daemon
telnetd telnet server daemon
inetd TCP server manager program
ftpd ftp server daemon
apache web server daemon
sshd secure shell server
openvpn virtual private network
openssl open SSL
Linux Tool Chain
Gcc (V3.3.2) C/C++ PC Cross Compiler
GDB (V5.3) Source Level Debug Server
Glibc (V2.2.5) POSIX standard C library
Windows Tool Chain
Gcc (V3.3.2) C/C++ PC Cross Compiler
Glibc(V2.2.5) POSIX standard C library
Insight (V6.1) Windows environment source level debug utility
In this chapter, we explain how to connect the W311/321/341, how to turn on the power, how to
get started programming, and how to use the W311/321/341’s other functions.
The following topics are covered in this chapter:
Powering on the W311/321/341
Connecting the W311/321/341 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
Configuring the WLAN
¾ IEEE802.11a/b/g
Using WPA_SUPPLICANT to Support WPA and WPA2
SD Socket and USB for Storage Expansion
Test Progra m—Developing Hello.c
¾ Installing the Tool Chain (Linux)
¾ Checking the Flash Memory Space
¾ Compiling Hello.c
¾ Uploading and Running the “Hello” Program
Developing Your First Application
¾ Testing Environment
¾ Compiling tcps2.c
¾ Uploading and Running the “tcps2-release” Program
¾ Testing Procedure Summary
ThinkCore W311/321/341 Linux User’s Manual Getting Started
Powering on the W311/321/341
Connect the SG wire to the shielded contact located in the upper lef t corner of the W311/321/341,
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 W311/321/341 to the power supply, it will take about 30 to 60 seconds for
the operating system to boot up. The green Ready LED will not turn on until the operating
system is ready.
ATTENTION
This product is intended to be supplied by a Listed Power Unit with output marked “LPS” and
rated for 12-48 VDC, 600 mA (minimum requirements).
Connecting the W311/321/341 to a PC
There are two ways to connect the W311/321/341 to a PC: through the serial console and by
Telnet over the network.
Serial Console
The serial console gives users a convenient way of connecting to the W311/321/341. This method
is particularly useful when using the computer for the first time. The serial console is useful for
connecting the W311/321/341 when you do not know either of the two IP addresses.
Use the serial console port settings shown below.
Baudrate
Parity
Data bits
Stop bits:
Flow Control
Terminal
115200 bps
None
8
1
None
VT100
2-2
ThinkCore W311/321/341 Linux User’s Manual Getting Started
The following window will open when a connection has been established.
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 W311/321/341’s console utility. The default IP address and Netmask for each of the two
ports are given below:
LAN 1
WIRLESS LAN
Use a cross-over Ethernet cable to connect directly from your PC to the W311/321/341. You
should first modify your PC’s IP address and netmask so that your PC is on the same subnet as one
of W311/321/341’s two LAN ports. For example, if you connect to LAN 1, you can set your PC’s
IP address to 192.168.3.126 and netmask to 255.255.255.0. If you connect to the WIRLESS LAN,
you can set your PC’s IP address to 192.168.4.126 and netmask to 255.255.2 55.0 using a wirless
AP router.
Use a straight-through Ethernet cable to connect to a hub or switch that is connected to your local
LAN. 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
Default IP Address Netmask
192.168.3.127 255.255.255.0
192.168.4.127 255.255.255.0
2-3
ThinkCore W311/321/341 Linux User’s Manual Getting Started
You can proceed with configuring the network settings of the target computer when yo u 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-4PINDB9F-100, which
comes with the W311/321/341, to connect to the serial console port.
Telnet Reminder
When connecting to the W311/321/341 over a LAN, you must configure your PC’s Ethernet IP
address to be on the same subnet as the W341 that you wish to contact. If you do not get
connected on the first try, re-check the serial and IP settings, and then unplug and re-plug the
power cord.
SSH Console
The W311/321/341 support an SSH Console to provide users with be tter security options.
Windows Users
Click on the link http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html to download
PuTTY (free software) to set up an SSH console for the W311/321/341 in a Windows environment.
The following figure shows a simple example of the configuration that is required.
2-4
ThinkCore W311/321/341 Linux User’s Manual Getting Started
Linux Users
From a Linux machine, use the “ssh” command to access the W311/321/341’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.
Are you sure you want to continue connection (yes/no)? yes_
NOTE SSH provides better security compared to Telnet for accessing the W311/321/341’s console
utility over the network.
Configuring the Ethernet Interface
The network settings of the W311/321/ 34 1 can be modi fied with the serial console port, 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. Follow the instructions given in a previous section to access the Console Utility of the target
computer via the serial console port, and then type
#cd /etc/network
to change directories.
2-5
ThinkCore W311/321/341 Linux User’s Manual Getting Started
2. Type
3. After the boot settings of the LAN interface have been modified, issue the following
#vi interfaces
configure the Ethernet ports of the W341 for static or dynamic (DHCP) IP addresses.
Static IP addresses
As shown in the table below, 4 network addresses must be modified: address, network,
netmask, and broadcast. The default IP address for LAN1 is 192.168.3.127, with default
netmask of 255.255.255.0.
Dynamic IP addresses
By default, the W311/321/341 are configured for “static” IP addresses. To configure one or
both LAN ports to request an IP address dynamically, replace static with dhcp and then delete
the address, network, netmask, and broadcast lines.
Default Setting for LAN1 Dynamic Setting using DHCP
iface eth0 inet static
to edit the network configuration file with vi editor. You can
iface eth0 inet dhcp
NOTE After changing the IP settings, use the networking restart command to activate the new IP
address.
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
For example, type the command
LAN1 to 192.168.1.1.
/etc/network/interfaces
#ifconfig eth0 192.168.1.1
.
to change the IP address of
Configuring the WLAN
IEEE802.11a/b/g
Use one of the following options to configure the WLAN for IEEE802.11a/b/g:
1. Using the config file to set up your wireless system
The config file is /etc/wireless.conf. The config file is read by the OS when the
W311/321/341 unit boots up. You may also use the load_wlan command to force your
wireless to run the config file and set up your wireless LAN card after the W311/321/341 unit
is already up and running. The /etc/wireless.conf file format is shown below:
2-6
ThinkCore W311/321/341 Linux User’s Manual Getting Started
/etc/wireless.conf Format:
DEVICE=eth1
MODE=managed
ESSID=any
KEY=any
/etc/wireless.conf Item list:
DEVICE Æ indicates your wireless interface
MODE Æ indicates your wireless mode, such as ad-hoc, managed, master
ESSID Æ indicates your wireless ESSID NAME
KEY Æ indicates your wireless WEP key
CHANNEL Æ indicates your wireless channel setting
MACMODE Æ indicates your wireless macmode setting, such as 1 (mixed mode), 2
(pure_g_mode), 3 (pure_b_m ode), 4 (pure_a_mode)
REGION Æ indicates your wireless country region setting
WIRELESS_SUPPLICANT Æ If set to Y, load_wlan will call /etc/init.d/wpa.sh and open
wireless WPA and WPA2
MOXA_REPEAT Æ If set to Y, load_wlan will call ipriv eth1 set_moxa_repeat to establish
ad-hoc mode using repeat function
If you want to use WPA and WPA2, please refer to the subsection “Using
WPA_SUPPLICANT to Support WPA and WPA2” on page 2-11.
2. Use the command
file with vi editor, and then edit the 802.11g network settings
Static IP addresses
As shown in the table below, 4 network addresses need to be modified: address, network,
netmask, and broadcast. The default WIRLESS LAN IP address is 192.168. 4. 127 .
Dynamic IP addresses
By default, the W311/321/341 are configured for “static” IP addresses. To configure one or
both LAN ports to request an IP address dynamically, replace static with dhcp and then delete
the address, network, netmask, and broadcast lines.
#vi /etc/networking/interfaces
:
:
to open the “interfaces”configuration
2-7
ThinkCore W311/321/341 Linux User’s Manual Getting Started
Default Setting for WIRLESS LAN Dynamic Setting using DHCP
iface eth1 inet static
After the boot settings of the LAN interface have been modified, issue the following
command to activate the LAN settings immediately:
#/etc/init.d/networking restart
3. Using iwconfig / iwpriv Utility to set up the wireless configuration Using iwpriv eth1 essid ESSIDNAME
iwconfig eth1 essid ESSIDNAME Æ set up wireless essid
iwconfig eth1 key KEYVALUE open Æ set up wireless wep key
iwconfig eth1 mode infra Æ set up wireless mode
CountryRegion—Sets the channels for your particular country / region
Using iwpriv eth1 set_Region REGION
REGION Explanation
1 (USA) (default) Use 802.11g channels 1 to 11
2 (Taiwan/Europe) Use 802.11g channels 1 to 13
3 (France) Use 802.11g channels 10 to 13
4 (Japan) Use 802.11g channels 1 to 14
5 (Israel) Use 802.11g channels 3 to 9
6 (Mexico) Use 802.11g channels 10 , 11
WirelessMode—Sets the wireless mode
Using iwpriv eth1 set_mac_mode Setting
Note: infrastruct just support mixed/a mode; Ad-hoc support b/g/a mode
Setting Explanation
1 (default) 11a/mixed(b. g)
2 11g only
3 11b only
4 11a only
SSID—Sets the softAP SSID
Using iwconfig eth1 essid Setting
iface eth1 inet dhcp
Setting
Any 32-byte string
NetworkType—Sets the wireless operation mode
Using iwconfig eth1 mode Setting
Setting Explanation
managed Infrastructure mode (uses access points to transmit data)
ad-hoc Adhoc mode (transmits data from host to host)
2-8
ThinkCore W311/321/341 Linux User’s Manual Getting Started
Channel—Sets the channel
Using iwconfig eth1 channel Setting
Note: Infrastruct couldn’t set channel
Freq—Sets the channel frequence
Using iwconfig eth1 freq Setting(G,M,K)
AuthMode—Sets the authentication mode
Using iwpriv eth1 set_auth Setting
Setting Explanation
0 OPEN
1 SHARED
2 AUTO(default)
KeyStr—Sets Key Support string key and hex key
EncrypType—Just Support NONE , WEP64 and WEP128 depend on your key length
Using iwpriv eth1 key s:KEYVALUE (open) Î support string key
Using iwpriv eth1 key KEYVALUE (open) Î support hex key
RTSThreshold—Sets the RTS threshold
Using iwpriv eth1 rts Setting
Setting
1 to 2347
FragThreshold—Sets the fragment threshold
Using iwpriv eth1 frag Setting
Setting
256 to 2346
Moxa Repeat—Sets the Repeat function through adhoc method
Using iwpriv eth1 set_moxa_repeat
2-10
ThinkCore W311/321/341 Linux User’s Manual Getting Started
Using WPA_SUPPLICANT to Support WPA and WPA2
This embedded computer supports the WPA and WPA2 functions using the /bin/wpa_supplicant
program. We wrote a shell script to help you use this function:
ssid and psk variables in the file etc/wpa_supplicant.conf.
Step 2:
/etc/init.d/wpa.sh eth1 start to enable this function. To stop the function, type
Type
/etc/init.d/wpa.sh eth1 stop
SD Slot and USB for Storage Expansion
The W341 and W321 provide an SD slot for storage expa nsion. MOXA provides an SD flash disk
for plug & play expansion that allows users to plug in a Secure Digital (SD) memory card
compliant with the SD standard V1.0 for up to 1 GB of additional memory space. The following
steps show you how to install SD card into the W341 and W321.
W321
The SD slot is located on the right side of the W321 enclosure. To install an SD card, you must
first remove the SD slot’s protective cover to access the slot, and then plug the SD card directly
into the slot.
The SD card will be mounted at /mnt/sd. Detailed installation instructions are shown below:
Step 1: Use a screwdriver to remove the screws holding the SD slot’s outer cover.
Step 2: After removing the cover, insert the SD memory card as shown.
2-11
ThinkCore W311/321/341 Linux User’s Manual Getting Started
W341
The SD slot is located on the front panel of the W341. To install an SD card, you must first
re
move the SD slot’s protective cover to access the slot, and then plug the SD card directly into the
slot.
The
SD card will be mounted at
p 1: Use a screwdriver to remove the screws holding the SD slot’s outer cover, and then
Ste
re
move the cover.
/mnt/sd. Detailed installation instructions are shown below:
Step 2: Insert the SD memory card as shown.
NOTE: To remove the SD card from the slot, press the SD card in slightly with your finger, and
then
remove your finger to cause the card to spring out partially. You may now grasp the top of the
with two fingers and pull it out.
card
ore removing the SD card, remember to type
Bef
/sync to ensure that your data has been written.
In addition to the SD socket, two USB 2.0 ports are located on the W341’s upper panel. The USB
host is also designed for storage expansion. To use a USB flash disk to expand the storage space,
plug the USB flash disk into the USB port. The flash disk will be detected automatically, and its
file
partition will be mounted into the OS. The USB storage will be mounted in one of four
directories: /mnt/usbstorage1, /mnt/usbstorage2, /mnt/usbstorage3, or /mnt/usbstorage4.
2-12
ThinkCore W311/321/341 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 W311/321/341. In general, program development involves the following seven
steps.
Step 1:
Connect the W311/321/341 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.
Step 5:
Download the program to the W311/321/341 using FTP
or NFS.
Step 6:
Debug the program
Æ If bugs are found, return to Step 4.
Æ If no bugs are found, continue with Step 7.
Step 7:
Back up the user directory (distribute the program to
additional W311/321/341 units if needed).
x86
Cross
Compiler
Installing the Tool Chain (Linux)
The Linux Operating System must be pre-installed in the PC before installing the W311/321/341
GNU Tool Chain. Fedora core or compatible versions are recommended. The Tool Chain requires
approximately 100 MB of hard disk space on your PC. The W311/321/341 Tool Chain software is
located on the W311/321/341 CD. To install the Tool Chain, insert the CD into your PC and then
issue the following commands:
The Tool Chain will be installed automatically on your Linux PC within a few minutes. Before
compiling the program, be sure to set the following path first, since the Tool Chain files, including
the compiler, link, library, and include files are located in this directory.
PATH=/usr/local/arm-linux/bin:$PATH
Setting the path allows you to run the compiler from any directory.
NOTE Refer to Appendix B for an introduction to the Windows Tool Chain. In this chapter, we use the
Linux tool chain to illustrate the cross compiling process.
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
2-13
ThinkCore W311/321/341 Linux User’s Manual Getting Started
If there isn’t enough “Available” space for your application, you will need to delete some existing
files. To do this, connect your PC to the W311/321/341 with the console cable, and then use the
console utility to delete the files from the W311/321/341’s flash memory. To check the amount of
free space available, look at the directories in the read/write directory /dev/mtdblock3. Note that
the directories /home and /etc are both mounted on the directory /dev/mtdblock3.
NOTE If the flash memory is full, you will need to free up some memory space before saving files to
the Flash ROM.
Compiling Hello.c
The package CD contains several example programs. Here we use Hello.c as an example to show
you how to compile and run your applications. Type the following commands from your PC to
copy the files used for this example from the CD to your computer’s hard drive:
# cd /tmp/
# mkdir example
# cp –r /mnt/cdrom/example/* /tmp/example
To compile the program, go to the Hello subdirectory and issue the following commands:
Next, execute make to generate hello-release and hello-debug, which are described below:
hello-release—an ARM platform execution file (created specifically to run on the W311/321/341)
hello-debug—an ARM platform GDB debug server execution file (see Chapter 5 for details about
the GDB debug tool).
2-14
NOTESince 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).
Refer to Chapter 5 to see a Makefile example.
Uploading and Running the “Hello” Program
Use the following commands to upload hello-release to the W311/321/341 by FTP.
1.From the PC, type:
#ftp 192.168.3.127
2.Use the bin command to set the transfer mode to Binary mode, and then use the put command
to initiate the file transfer:
We use the tcps2 example to illustrate how to build an application. The procedure outlined in the
following subsections will show you how to build a TCP server program plus serial port
communication that runs on the W311/321/341.
2-15
ThinkCore W311/321/341 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 W311/321/341’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 W311/321/341 through an RS-232 connection. At the remote site, data can b e transferred
between the W311/321/341’s Ethernet port and PC 2 over an Ethernet connection.
PC 2PC 1
RS-232LAN
tcps2.c
Read serial data
Write data to PC1
Serial Rx
Buffer
LAN Rx
Buffer
Send data to PC2
Receive LAN data
2-16
ThinkCore W311/321/341 Linux User’s Manual Getting Started
Compiling tcps2.c
The source code for the tcps2 example is located on the CD-ROM at
CD-ROM://example/TCPServer2/tcps2.c. Use the following commands to copy the file to a
specific directory on your PC. We use the direrctory /home/w341/1st_application/. Note that you
need to copy 3 files—Makefile, tcps2.c, tcpsp.c—from the CD-ROM to the target directory.
Two executable files, tcps2-release and tcps2-debug, are created.
tcps2-release—an ARM platform execution file (created specifically to run on the
W311/321/341).
tcps2-debug—an ARM platform GDB debug server execution file (see Chapter 5 for details about
the GDB debug tool).
NOTE If you get an error message at this point, it could be because you neglected to put tcps2.c and
tcpsp.c in the same directory. The example Makefile we provide is set up to compile both tcps2
and tcpsp into the same project Makefile. Alternatively, you could modify the Makefile to suit
your particular requirements.
2-17
Uploading and Running the “tcps2-release” Program
Use the following commands to upload tcps2-release to the W311/321/341 through an FTP
connection.
1. From the PC, type:
#ftp 192.168.3.127
2. Next, use the bin command to set the transfer mode to Binary, and the put command to
initiate the file transfer:
ftp> bin
ftp> cd /home
ftp> put tcps2-release
root@server11:/home/w341/1st_application
[root@server11 1st_application]# ftp 192.168.3.127
Connected to 192.168.3.127
220 Moxa FTP server (Version wu-2.6.1(2) Mon Nov 24 12:17:04 CST 2003) ready.
530 Please login with USER and PASS.
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.
226 Transfer complete
4996 bytes sent in 0.00013 seconds (3.9e+04 Kbytes/s)
ftp> ls
227 Entering Passive Mode (192.168.3.127.106.196)
150 Opening ASCII mode data connection for /bin/ls.
-rw------- 1 root root 899 Jun 10 08:11 bash_history
-rw-r--r-- 1 root root 4996 Jun 12 02:15 tcps2-release
226 Transfer complete
ftp>
604 root SW [mtdblockd]
609 root SW [pccardd]
611 root SW [pccardd]
625 root SWN [jffs2_gcd_mtd3]
673 root 500 S /bin/inetd
679 root 3004 S /usr/bin/httpd -k start -d /etc/apache
682 bin 380 S /bin/portmap
685 root 1176 S /bin/sh --login
690 root 464 S /bin/snmpd
694 nobody 3012 S /usr/bin/httpd -k start -d /etc/apache
695 nobody 3012 S /usr/bin/httpd -k start -d /etc/apache
696 nobody 3012 S /usr/bin/httpd -k start -d /etc/apache
697 nobody 3012 S /usr/bin/httpd -k start -d /etc/apache
698 nobody 3012 S /usr/bin/httpd -k start -d /etc/apache
701 root 352 S /bin/reportip
714 root 1176 S -bash
726 root 436 S /bin/telnetd
727 root 1164 S -bash
#kill %1
command to check if
2-19
ThinkCore W311/321/341 Linux User’s Manual Getting Started
NOTE Use the
kill -9
command for PID 728 to terminate this program:
Testing Procedure Summary
1. Compile tcps2.c
2. Upload and run tcps2-release in the background
3. Check that the process is running
4. Use a serial cable to connect PC1 to the W311/321/341’s serial port 1.
5. Use an Ethernet cable to connect PC2 to the W311/321/341.
6. On PC1: If running Windows, use HyperTerminal (38400, n, 8, 1) to open COMn.
7. On PC2: Type
8. On PC1: Type some text on the keyboard and then press Enter.
9. On PC2: The text you typed on PC1 will appear on PC2’s screen.
The testing environment is illustrated in the following figure. However, note that there are
limitations to the example program tcps2.c.
(#make
).
#telnet 192.168.3.127 4001
RS-232LAN
(#./tcps2-release &)
(#jobs or #ps -ef)
.
#kill -9 %728
.
.
PC 2PC 1
tcps2.c
Read serial data
Serial Rx
Send data to PC2
Buffer
LAN Rx
Write data to PC1
NOTE The tcps2.c application is a simple example designed to give users a basic understanding of the
concepts involved in combining Ethernet communication and serial port communication.
However, the example program has some limitations that make it unsuitable for real-life
applications.
1. The serial port is in canonical mode and block mode, making it impossible to send data from
the Ethernet side to the serial side (i.e., from PC 2 to PC 1 in the above example).
2. The Ethernet side will not accept multiple connections.
Buffer
Receive LAN data
2-20
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 W311/321/341 units.
The following topics are covered in this chapter:
System Version Information
System Image Backup
¾ Upgrading the Firmware
¾ Loading Factory Defaults
¾ Backing Up the User Directory
¾ Deploying the User Directory to Additional W311/321/341 Units
Enabling and Disabling Daemons
Setting the Run-Level
Adjusting the System Time
¾ Setting the Time Manually
¾ NTP Client
¾ Updating the Time Automatically
Cron—daemon to Execute Scheduled Commands
3
Loading...
+ 74 hidden pages
You need points to download manuals.
1 point = 1 manual.
You can buy points or you can get point for every manual you upload.