| WRAP Access Server: User's and Developer's Guide | ||
|---|---|---|
| <<< Previous | Next >>> | |
This manual describes how to create and use applications using the WRAP Access Server Software Development Environment. The relationships between the applications in the WRAP Access Server Software Platform are shown in Figure 5-1.
Note: The Software Development Environment can be installed only on a PC running the Linux operating system!
The following hardware and software is required to run the WRAP Access Server Development Environment:
PC with
CD-ROM drive
Linux (tested with RedHat Enterprise Linux 3 and above, Fedora Core 2 and above)
Devel libraries (especially zlib-devel and ncurses-devel) must be installed
modutils-2.4.26 or newer must be installed
300MB of available hard disk space
An Ethernet connection to a Local Area Network (also connected to the Access Server board) is highly recommended.
Mount the WRAP Access Server SDK CD-ROM or ISO image, change the current working directory to where it is mounted, and run the install script. If the user running install does not have privileges to create the directory for the toolchain, normally /usr/local/arm, the install scripts prompts for root password.
Example (things you need to type are printed like this):
$ mount /dev/cdrom /mnt/cdrom
$ (or mount -o loop /path/to/sdk2.iso /mnt/cdrom)
$ cd /mnt/cdrom
$ sh install
|
Install will ask you some questions (described below) regarding which components to install and the paths to install them to. If you are not very familiar with Linux, just press enter to these questions (the default values are suitable for most users and systems).
Access Server toolchain directory � (default: /usr/local/arm)
This is the path where you want the WRAP Access Server Software Development tools (arm-linux-gcc, etc.) to be installed.
Note: If you change this value, the WRAP Access Server tools and libc must be recompiled. The recompilation process is very complicated and lengthy, and it may fail, depending on your system. Recompilation is done automatically by the install script, if necessary.
Development directory � (default: [home_of_current_user]/asdk)
This is the path where you want the WRAP Access Server Software Development Environment to be installed.
Development directory owner � (default: [current_user])
(Asked only if run as root) This is the username of the owner of the development directory.
Note: If this is not the username of the developer for whom the Software Development Environment is being installed, the user will not have rights to use the development files and therefore can not develop any WRAP Access Server software.
Install toolchain sources � (default: no - unless the tools directory was changed)
Whether or not the toolchain sources will be installed. These are required only if the WRAP Access Server tools directory was changed from the default target location in step 1.
Install linux headers (default: no - unless libc sources are selected)
Whether or not the Linux header files will be installed. These are required only if the libc sources are being installed (chosen in step 5).
Install example applications � (default: yes)
Whether or not the WRAP Access Server example applications and their sources will be installed.
Compile image after installation � (default: yes)
If set to yes, install will compile the WRAP Access Server filesystem image to test that the installation was successful and that the Development Environment is working correctly.
The fastest way to start developing Access Server applications is to study, change, and recompile the example files in the asdk/examples directory.
To demonstrate the software development features of the Access Server, the WRAP Access Server Software Development Environment comes with several example applications.
The compiled example files are located in WPK packets on the WRAP Access Server SDK tree in the directory asdk/bin/.
The examples can be manually uploaded and installed on the Access Server board by sending them to to the /tmp/obex directory. The wpkgd server automatically installs them. Uploading can be done with Bluetooth, SCP, SFTP or X/Y/Zmodem.
The examples, with their usage and purpose, are described in Table 5-1.
Table 5-1. Examples, Their Usage and Purpose
| Example | Usage | Purpose |
|---|---|---|
| helloworld | /usr/bin/helloworld | The "Hello, world!" application. |
| serial | /usr/bin/serial /dev/ttyAT1 | "Hello, world!" to the serial port. Note: "/dev/ttyAT1" must be free (no WRAP SMS Gatewary or WRAP Bluetooth Serial Port Profile using it). |
| forkserver | SET BLUETOOTH LISTEN 11 /usr/bin/forkserver | Simplest Bluetooth RFCOMM server example, use for example btserver as a client. |
| btserver | /usr/bin/btserver - for server mode (if no forkserver running), /usr/bin/btserver <bdaddr of btserver in server mode or forkserver> 11 for client mode | Advanced iWRAP client example (can run both as RFCOMM server or client). |
| io/ioled | /usr/bin/ioled | I/O: LED/Buzzer example. |
| ledtest | /usr/bin/ledtest | I/O: Another LED example. |
| m2n | echo testmessage | /usr/bin/m2n | Machine 2 Network example. System Logger configuration needed for actual remote connection. Without it, simulates it locally. |
| man2m | /usr/bin/ledserver and browse with Java-enabled browser to http://wrap-ip-adress/man2m/ | Man 2 Machine example. Also demonstrates Java applets. |
| www | Browse to http://wrap-ip-address/example.html | Demonstration of the web server capabilities. |
| makesms | Browse to http://wrap-ip-address/send.html. Note: Assumes WRAP SMS Gateway is up and running (see Section 3.5.3). | Demonstrates WRAP SMS Gateway by sending SMS messages with WRAP SMS Gateway. |
| obexbrowser | Documented in Section 6.10.3. | Demonstrates the usage of the WRAP OBEX libraries implementing Object Push Profile and File Transfer Profile clients. |
To start a new project, you need to create a new subdirectory in your Development Environment's directory (asdk/) and add your application source files and Makefile to that directory.
A project skeleton can be done automatically using WRAP Access Server Project AppWizard. Just give the command make appwiz APP=dir/to/newapp in the Development Environments top level directory (asdk/). A "hello world" example ANSI C project is then created.
To create C++ project, give the command make appwiz APP=dir/to/newcppapp CPP=y.
You can add your directory to the compile queue by inserting it in the file asdk/DIRECTORIES if you want to compile the whole source tree at once from the top level asdk-directory.
You may need to modify the variables in the Makefile for your project. You can see the defaults and their description in the default Makefile created by the AppWizard (asdk/dir/to/newapp/Makefile in our example above).
Makefile variables are:
TOPLEVEL
This should point to the Development Environment source directory, i.e. asdk/.
APPNAME
This is the name of the executable file of the application. In our example, this line should be APPNAME = testapp
APP_DIR
This is the location of the application executable, when installed with the .wpk packet. By default, this is /usr/local/bin
SRC
This variable defines the files to be compiled and linked into APPNAME. In our example, this line could be SRC = testapp.c. Several files are separated with space, like SRC = testapp.c extraobj.c
APP_STRIP
Optional variable. The application symbols are removed by default to reduce application size. For debugging, these are needed, which can be done by APP_STRIP = false.
CFLAGS
Optional extra flags for C compiler. Set CFLAGS = -ggdb if you want to debug application.
CXXFLAGS
Optional extra flags for C++ compiler. Set CXXFLAGS = -ggdb if you want to debug application.
LIBS
Optional additional libraries needed by application. Multihreaded application needs libpthread with LIBS = pthread.
Now you have a new project just waiting for coding. To compile the project, you simply need to run make in the testapp directory.
The build system also creates the installation packet (testapp-timestamp.wpk), which can be transferred to /tmp/obex directory of the Access Server from where it is installed automatically.
The WRAP Access Server Development Environment uses the ARM port of the GNU bintools and compilers to build applications. If you are not very familiar with Linux development, you should use the method explained in the previous section instead of writing your own makefiles.
If you still want to use your very own development environment, there are two minor issues to remember:
Tools are prefixed with arm-linux-, so for calling gcc C-compiler you need to call arm-linux-gcc, etc.
Tools are located in /usr/local/arm/2.95.3/bin/ directory, which is not in PATH by default.
To run an application on the Access Server, it must first be transferred into it. There are several ways of doing this (see Section 2.3.3). The most usable ways while doing software development are discussed in the following subsections.
An SCP transfer is done with a single command. In the following example myapp is transferred to the directory /tmp in the Access Server:
$ scp myapp root@<wrap-ip-address>:/tmp
root@<wrap-ip-address>'s password: buffy (not echoed back)
/path/to/myapp/myapp 100% 20KB 20.0KB/s 00:00
$
|
An SFTP transfer is almost similar, but the command procedure is a bit closer to an FTP session (FTP can also be used if the FTP server is enabled):
$ sftp root@<wrap-ip-address>
Connecting to <wrap-ip-address>...
root@<wrap-ip-address>'s password: buffy (not echoed back)
sftp> cd /tmp
sftp> put myapp
Uploading myapp to /dev/shm/tmp/myapp
/path/to/myapp/myapp 100% 20KB 20.0KB/s 00:00
sftp> quit
$
|
With SSHFS, the filesystem of the WRAP Access Server can be securely mounted to be a part of the development host's filesystem.
To download and install SSHFS, visit http://fuse.sourceforge.net/sshfs.html. After that you can mount the whole filesystem and copy the myapp application to /tmp directory in the Access Server with the following commands:
$ mkdir mnt
$ sshfs root@<wrap-ip-address>: mnt
root@<wrap-ip-address>'s password: buffy (not echoed back)
$ cp myapp mnt/tmp
$ fusermount -u mnt
$
|
If your Access Server is not connected to a LAN, you may use terminal software of your own choice to transfer data to the Access Server.
The Access Server contains an X/Y/Zmodem protocol application, which allows you to transfer data over the console using almost any terminal software available:
Connect your computer to the Access Server management UART using a cross-over serial cable, and start your terminal software (115 200bps, 8 data bits, no parity, 1 stop bit).
Change your working directory to where you want to upload your application, and run the xmodem application with your application name as parameter.
Start Xmodem send from your terminal software.
Example 5-1. Transfering Files with Xmodem
[root@wrap /] cd /tmp
[root@wrap /tmp] rx testapp
rx: ready to receive testapp.
now start xmodem (checksum, not CRC) send from your terminal
[root@wrap /tmp]
|
If you want to save the application to /usr/local/bin (on the flash file system), you will have to replace cd /tmp with cd /usr/local/bin. To examine the directory structure of the Access Server, please see Appendix A.
To run the application you just transferred to the Access Server, you need access to the Access Server console, either using terminal software connected to the Access Server management UART or using the SSH connection (log in as user root and remember the password, which is buffy by default).
After establishing a connection to the Access Server, change the directory to where your application is located and change file permissions so that it can be executed, then run it.
It is possible to use GNU debugger GDB and a graphical user interface, like DDD, for debugging applications in the WRAP Access Server.
You have to compile with debug options and without symbol stripping to make debugging work. As mentioned above, this can be done by adding lines "APP_STRIP=false" and "CFLAGS=-ggdb" to the Makefile below SRC line.
After you have compiled your application with these options and transferred your application to Access Server, you can start debugging the application as follows:
Start gdbserver on the WRAP Access Server
Usage: gdbserver :<port> <your application>
Example: gdbserver :6789 ./hello
Start debugger on the host PC. (example is for DDD)
Example: ddd --debugger /usr/local/arm/2.95.3/bin/arm-linux-gdb hello
Create connection to the WRAP Access Server.
Usage: target remote <node IP>:<port>
Example: target remote 192.168.42.3:6789
Run the program with command continue.
| <<< Previous | Home | Next >>> |
| Bluetooth Technology Overview | iWRAP - Bluetooth Interface |