embedded-web

Document Sample
embedded-web Powered By Docstoc
					Data Acquisition Module
with Internet Technology
       Senior Project




        David Harty
       Angelo Lauria
        CDA 4914
         12/14/00




                        Advisors:
                                Dr. Bassem Al-Halabi
                                Dr. Maria Petrie
1      Introduction ................................................................................................................. 3
2      Purpose ........................................................................................................................ 3
3      Components................................................................................................................. 4
    3.1      Core Module........................................................................................................ 4
    3.2      The Data Acquisition Module ............................................................................. 5
    3.3      The Ethernet Module........................................................................................... 6
4      Design Concept & Implementation............................................................................. 7
    4.1      NT installation:.................................................................................................... 9
    4.2      Diamond Universal Driver Installation Procedures .......................................... 10
    4.3      Preparing Visual C++ for Driver Development ................................................ 10
    4.4      Preparing the Java Environment ....................................................................... 11
    4.5      Developing the Java Native Interfaces.............................................................. 12
    4.6      The Jakarta-Tomcat3.2 Server .......................................................................... 13
       4.6.1      Setting up Tomcat on your Winnt system :............................................... 13
       4.6.2      Configuing TomCat to run as an NT service ............................................ 14
       4.6.3      Advance TomCat Setup Features.............................................................. 15
    4.7      Developing Java Server Pages .......................................................................... 15
    4.8      Launching the DAMIT...................................................................................... 16
5      Conclusion................................................................................................................. 17
6      References and Resources......................................................................................... 18
    6.1      Ampro Computers www.ampro.com ................................................................ 18
    6.2      Diamond Systems www.diamondsys.com ........................................................ 18
    6.3      Sun Microsystems www.sun.com ..................................................................... 18
       6.3.1      “The source for Java Technology” java.sun.com/..................................... 18
       6.3.2      Java Server Pages java.sun.com/products/jsp/ .......................................... 18
       6.3.3      JSP Specfications java.sun.com/products/jsp/download.html .................. 18
    6.4      Borland www.borland.com ............................................................................... 18
    6.5      TextPad www.textpad.com ............................................................................... 18
    6.6      JSP Resource Index www.jspin.com................................................................. 18
    6.7      Web Development with JSP www.burridge.net/jsp.......................................... 18
    6.8      Jakarta-Tomcart http://jakarta.apache.org/tomcat/............................................ 18
    6.9     Core Java2 Volume II-Advanced Features ....................................................... 18
    6.10 Red Had Linux 6.0 Unleashed .......................................................................... 18
7      Appendices ................................................................................................................ 19
    7.1      index.jsp ............................................................................................................ 20
    7.2      dam1Bean.java .................................................................................................. 22
    7.3      DamNative.java................................................................................................. 24
    7.4      DamNative.h ..................................................................................................... 25
    7.5      DamNative.c...................................................................................................... 26
        Data Acquisition Module with Internet Technology
        Students    David Harty & Angelo Lauria        Florida Atlantic University
            Class   CDA4915                            College of Engineering
     Main Advisor   Dr. Bassem Alhalabi                Computer Science & Engineering Dept
   Second Advisor   Dr. Maria Petrie                   December 13, 2000



Objectives
The Data Acquisition Module is a web
server with wireless capabilities that
allows a user to remotely monitor and
control data acquisition units via the
Internet or other TCP/IP based network.
The idea was to build a system that
could remotely monitor a series of
sensors while at the same time
providing control capabilities.    For
instance, a pit crew could monitor a
racecar in real time and make
performance adjustments to the system
based on the acquired data.

General Description
The system utilizes the PC104
subsystem, an Ethernet Module, and a              Java capabilities to a Client logged in over a
data acquisition module. As seen here             network. The Client side can be controlled
in the picture, the modules are small,            through Java Server Pages or Applets.
about 4” x 4”. This allows our system
flexibility in design and implementation,         Conclusion
without losing operational capabilities of
                                                  The Data Acquisition module is
a PC. For our purposes, this flexibility
                                                  implemented as a real time embedded
was a key feature of the PC104.
                                                  system for the purposes of remote data
                                                  acquisition and control. The design is
Theory of Operation                               unique from the standpoint that we have
The system runs on the Windows NT                 embedded an Internet based software
platform and utilizes Java Native                 solution to fit the characteristics of the
Interfaces to control the Data                    PC104. The use of this type of system
Acquisition board. The Jakarta-Tomcat             will be beneficial to anyone interested in
Server is used to provide Server-Side             data      acquisition      or      internet
                                                  technologies.
1 Introduction
The Data Acquisition Module with Internet Technology (DAMIT) utilizes the PC104
platform. PC/104 offers full hardware and software compatibility with the standard
desktop PC (and PC/AT) architecture, but in an ultra-compact (3.6” x 3.8”), self-stacking,
modular format. PC/104 standardizes a way to repackage desktop PC functions in order
to satisfy the ruggedness, reliability, and size constraints of embedded systems.
Consequently, PC/104 provides an attractive PC-compatible alternative to traditional
embedded micro controllers. The DAMIT uses an Ampro computer CM2-4Dxi core
module, an Ampro computer Ethernet module with a SMC controller, and a Diamond
Systems Garnet MM data acquisition card.


2 Purpose
The purpose of the DAMIT is to allow a user to remotely monitor and control a wide
variety of applications. Efforts were made to maintain the expandability of the DAMIT.
The DAMIT was originally implemented in an application specific setting to promote and
highlight its main features

The object-oriented approach followed to allow the DAS and NCS subsystems to operate
independently of one another, while maintaining unit cohesiveness.

The DAS sensors were utilized to determine sensor inputs and transmitted over the web
server. This data is analyzed and stored by the CSS. The NCS will allow an authorized
user of the DAMIT, to communicate with the CSS using the TCP/IP protocol. Through
the NCS, the user will be able to view the current status of the entire system, including
but not limited to, the current state of individual sensors and recent system activity. The
NCS will also allow the user to call the functions of the DAS, thereby preemptively
engaging the window or top systems.

                              Figure 1: Modular Construction
3      Components
The major components of the DAMIT, as mentioned earlier are the Core Module, the
Ethernet module, and the Data acquisition module. All of these subsystems are based on
the PC104 form factor.


3.1 Core Module

The CoreModule/4DXe CPU is a 486DX-based PC/AT compatible system in the PC/104
form factor. This single-board system contains all the component subsystems of a PC/AT
motherboard plus the equivalent of several PC/AT expansion boards.

Key functions included on the CoreModule/4DXi module are CPU, RAM, embedded-PC
BIOS, keyboard and speaker interfaces, two RS-232C serial ports (one configurable as
RS-485), a bi-directional parallel port, floppy drive controller and IDE hard disk
controller. In addition, the CoreModule/4DXe CPU includes system extensions and
enhancements that are specifically designed for embedded systems. It is designed to meet
the size, power consumption, temperature range, quality, and reliability demands of
embedded applications.

Note: The Core Module CM2-4Dxi is no is no longer supported by Ampro computers.
Ampro recommends upgrading to the CM2-4Dxe.

                       Figure 2, the PC/104 Embedded Platform
The Core Module is a PC104 compliant CPU:

       CPU                    • AMD "5x86" (486DX5) CPU, 133 MHz internal clock rate; jumper selectable to
       100 MHz

       M E M O RY             • 4 Mbytes directly surface mounted, expandable to 64 Mbytes

       SYSTEM CONTROLLERS     • 7 DMA channels (8237 equivalent)
                              • 14 interrupt channels (8259 equivalent)
                              • 3 programmable counter/timers (8254 equivalent)

       REAL TIME CLOCK        • Real time clock with CMOS RAM (MC146818 equivalent);

       BIOS                   • Award ROM-BIOS with Ampro embedded-PC enhancements




3.2 The Data Acquisition Module

The Data acquisition module consists of a Garnet-MM. Garnet-MM is a PC/104-format
digital I/O board with 48 lines of I/O. It contains two 82C55 ICs, each having 3 8-bit I/O
ports. Each 82C55 has its own 50-pin I/O header for external connections. Direction on
all ports is selected by programming control registers built in to the 82C55 chips. The I/O
lines are controlled using the Native C interfaces embedded within Java code. This
Module is the crux of the data acquisition and control processes of the DAMIT.


                    Figure 3. The Garnet-MM Data Acquisition Module
3.3 The Ethernet Module

The Ethernet module is designed to take advantage of the object-oriented nature of the
project and allow for multiple network configurations. The initial prototype uses an
Ampro Ethernet-II network interface module. This module implements the IEE802.3
(ANSI 8802-3) Ethernet standard and operates at a data rate of 10 megabits per second.
The Ethernet-II also provides a socket for a standard “remote boot” and support for
TCP/IP. These allow the DAMIT to be activated remotely, while enabling Internet
communication. The design allows for facilitation and the expansion to other types of
communication interfaces and protocols. The coming wireless cellular standards, that
will enable “always on,” high bandwidth connections, would be a logical extension.

                       Figure 4: The Ampro Ethernet Controller
4 Design Concept & Implementation
The original design was to use the components mentioned above along with a modem
card to be used for wireless networking capabilities. We had also planned to use the
Linux operating systems for a number of reasons:

       Low Cost
       Open Source
       Size Constraints of Embedded System
       Stable Platform
       Rebuildable Kernel
       Extensive Configurability
       Availability of reliable Apache Web Server

As we embarked upon the installation of Red Hat Linux 6.2 we encountered a number of
obstacles. Many attempts were made to install onto the Ampro Core Module. During
initialization of the boot install disk, the system would freeze after performing a ram disk
operation. Discussions with Ampro Technical support provided us with an updated Bios,
which did not fix the problem. Red Had support offered multiple alternatives, which also
were unsuccessful. We located the problem after cannibalizing several old computers to
build a basic “open air” Pentium 100 system with 32 Megs of ram. Our initial install
attempt on this system went smoothly, and we had a Linux system running an Apache
Web Server up within the day.

We then removed the hard drive from this computer and installed it into the PC104. We
were not wholly surprised when the system booted. However, later attempts to install the
PC104 specific hardware were met with the same ram disk enabled crash.

After experimenting with the ramdisk function of dos, and were able to reduplicate the
crash by creating an 8 meg ram disk, and then running a ram disk check on it. We
contacted Red Hat to see if an install could be done using a smaller ramdisk or bypassing
the ramdisk all together. According to Red Hat this can be done, but the procedure
requires a solid knowledge of the Linux operating system and kernel development. We
decided to leave this up to an enterprising student with kernel development experience,
and instead opted for the most efficient route in order to accomplish our stated objectives.
We requisitioned a 32 meg memory expansion unit from Ampro.

While waiting for the memory module to be delivered, we continued development on the
P100 system. It was during this time that we first began to experiment with the Apache
server, and more specifically server side Java. We found several freely available Java
Servers including Borland Inprise Application Server and Sun Microsystems’ Java Web
Server, which can both be downloaded for a 30-day trial. We decided to go with the
Jakarta-Tomcat server because although it is not as user friendly, it is not limited to a
limited time trial, which would be important if other students wanted to follow up on our
work. I have recently learned that a non-expiring version of Sun’s Java web server is
available for educators at http://freeware.thesphere.com/ . It was during this time that we
were able to run our first Server Side Java program. It was simple, but it pointed to
bigger things to come.

When the Memory for the PC104 arrived, we promptly installed it and retried the Linux
installation. As we expected, we were able to boot the installation disk. After doing a
custom install to install only the packages we needed, (Apache, C development etc.) we
were confronted by a new problem. Upon rebooting the system after the install, the
Linux LILO Boot loader crashed while trying to initialize itself. Eventually we tracked
this problem to the to the fact that the PC104 does not support Large Block Addressing
which the LILO boat loader needs in order to recognize larger drives. The Drive we used
was slightly over 1 gig, which was to large. To work around this problem, we created a
boot disk to load from. While impractical, it was a convenient workaround, as time was
getting short.

When we got the Linux system running, we attempted to reduplicate our successes with
the Apache server and Linux-Config on the P100 system. We were able to configure and
start the server, but were met with a permission denied page when we tried to log onto the
system. It was at this time that the bombshell hit. A concern of ours since the beginning
of the project was the limited support for the Linux on the PC104. We had however been
informed by Diamond that they were developing a Linux version of their Universal
Driver which as the name implies can be used for all of the Diamond PC104 products.
We contacted them at this time to see if they were available yet. We were informed that
their Linux expert was no longer with the company.

It was at this time that we tried to try Windows NT or 2000 to see if we had any luck.
We had hoped to avoid Windows because of the enormous resources required, and the
fact that once running, the DAMIT would have no need for a server side graphical user
interface. Several installation attempts and “fdisk”ings were required just to remove the
remnants of the inoperable LILO boot loader. Finally, the NT installation worked, but
several attempts at installing 2000 in order to use the included Internet Information
Service failed. The platform independence of Java really made itself felt during the
ensuing porting procedures. We were able to use the same Tomcat server that we had
used on Linux on NT. The only major difficulty remaining, laid in the configuration and
development of the Java native interface drivers to control the DAMIT. The following
section will detail the entire installation and configuration procedure required to build the
existing web/driver development platform on the PC104 system using Windows NT.
4.1 NT installation:

     Setup will prompt you whether you want a new installation or repair an old
     installation.
     Choose a new installation
     Next setup will automatically detect floppy controllers, hard disks and CD-ROMs
     without user intervention, or you can skip the automatic detection, and add the
     CD manually.
     We had to manually add the CD from the list given because when setup did it
     automatically, the system would crash. We chose IDE CD-ROM (ATAPI 1.2)
     from the list provided.
     After setup recognizes the mass storage devices in your system choose enter to
     continue.
     Next, agree to the license agreement, then double check that the system has the
     correct hardware selections. Choose enter to continue.
     Then, create the partition you want to install NT on, and choose enter to continue.
          o We chose the NTFS.
     Next, choose the directory to install NT.
          o We chose the default (\WINNT) provided by setup.
          o At this time, it might be a good idea to let NT perform an exhaustive test
             of the disk drives.
     When the test is completed, NT will copy the necessary files to the hard drive for
     installation. Choose enter to continue.
     Make sure that all the required hardware components are installed on you system
     before NT reboots, to avoid having to add them later.
     Once completed, NT will then walk you through the NT installation setup. We
     choose a custom install, so we would only install the minimum amount of
     Windows Accessories needed for development of our system.
     After choosing the items you want installed, NT will install and then reboot.
     When the system reboots, you will be prompted if you want to install Microsoft
     Networking. Select Yes.
     The System will attempt to locate the Ethernet card, but will be unable to do so.
     You will be prompted to select from a list of components or load them from a
     driver disk.
     Click “Have Disk.” You will need to supply drivers for the Ethernet II mini
     module        that    can     be    found     at    The     Ampro       Web      site
     http://www.ampro.com/support/utilities/mm-enet-ii.htm.          Download          the
     SW30245A.zip file and extract it to a floppy. The driver you need is in NDIS3
     directory.
     It is important at this step to document the default base address that is assigned to
     the Ethernet card. Ours was assigned to 0x300. This is also the default base
     address of the Garnett MM card. We will rectify this conflict later.
     Next Configure windows networking with the following components TCP/IP
     networking. Get an appropriate IP address and computer name from your
     network administrator if necessary.
       The computer will then prompt you to restart.
       After the restart you will be ready to prepare the system for driver development.


4.2 Diamond Universal Driver Installation Procedures
       All of the files used below come with the Diamond Universal Driver zip
       “dscud40.zip” available at       www.diamondsys.com/techlit.htm
       Unzip “dscud40.zip” to a directory on your hard drive.
       Copy WINDRVR.SYS and dscudkp.sys files to
       C:\WINNT\SYSTEM32\DRIVERS
       Run the following commands from the command line to install drivers and add
       registry entries:
               a) "WDREG.EXE install"
               b)      "WDREG.EXE –name “DiamondUni” –file dscudkp install"
                       -startup automatic
       To uninstall driver, use the following commands.
               a) "WDREG.EXE remove"
               b) "WDREG.EXE -file dscudkp remove"
       When compiling your C or Java files make sure to link the compiler to the
       "dscud.lib" Library. (We will detail the compilation procedures later)
       Make sure "dscud.dll" is located on your path.
           o Change the system environment to add the path to "dscud.dll"
           o Or, copy "dscud.dll" to a location on your existing path
           o A good location would be “Winnt\system32”

4.3 Preparing Visual C++ for Driver Development
You can use either Visual C++ or the free Borland C++ compiler for driver development
and compilation. We installed Visual C++ and utilized its command line compiler for
compilation. In order to compile the driver on visual studio a number of steps were taken
to make certain that all the files are in the correct location. The driver uses header files
and dynamic link libraries that have to put in the right folders in Visual C. Follow these
steps:

       Add the file “dscud.h” to the “include” folder of VC98. Ex. “VC98\include”
       Add the file “dscud.lib” to the “lib” of VC98. Ex. “VC98\lib”
       Add the file named dscud.dll to the “Winnt\system32” folder. (Note: you may
       have already been done this in the previous section.

If you use Borland C++, available for free at

       www.borland.com/bcppbuilder/freecompiler.

There are detailed instructions on how to configure it to work with the diamond driver in
the “dscudman.doc” file included with the Diamond Universal Driver zip. This
Document also details the commands available in the dcsud.dll file.
We used Visual C++ to create programs in C to test the functionality of the Garnet Board.
A helpful resource was the GMM demo files (gmm.zip) also located at:

       www.diamondsys.com/techlit.htm.


4.4 Preparing the Java Environment
Next, we installed the JavaTM 2 platform, Standard Edition (J2SETM) in order to create a
Java class that could call the native methods of the Diamond Driver file. The Java
Software Development Kit is available at no charge for Windows, Linux or Solaris at:

       www.java.sun.com/j2se/1.3

We referenced Core Java Volume II-Advanced Features by Cay S. Horstmann and Gary
Cornell on how to develop the Java Native interfaces file. Information about this series is
available at:

       www.phptr.com/corejava

As an aide to utilizing the command line compilation programs, we downloaded and
installed a program called TextPad 4.0. TextPad is a shareware utility that we found
indispensable during the development of the project. It is a simple text editor that enables
syntax highlighting of text for programming and markup languages. In addition, you can
configure it to run command line programs like the Java compiler. TextPad is available
for evaluation at:

       www.textpad.com.

We configured it to compile and run Java files, create the Java header files needed for
Native Interfaces, and run our batch file to call the VC command line compiler. Under
Configure->preferences->tools you can add the following commands and run time
parameters

   1. javac.exe                    // compiles Java
             -classpath $FileDir $File
             $FileDir
             capture/sound

   2. java.exe                     // runs the Java program
             -classpath $FileDir $BaseName
             $FileDir

   3. javah.exe                    // created the JNI header file
             -classpath $FileDir $BaseName
             $FileDir
             capture/sound
4.5 Developing the Java Native Interfaces
In order to utilize Java Native Interfaces, Several steps must be taken to ensure
compliance with the JNI specifications. The following are VERY simplified steps for
utilizing Java Native Interfaces
        Write a Java class that contains a name for the function you want to call. Ex:
           class DamNative
           {
               public native static void setByte(byte port, byte value); // send a port a value
           }

       Compile the class using javac.eve to make sure it doesn’t contain any errors.
       Call the javah.exe function to generate the header file, in this case
       “DamNative.h”.
       Open the generated header file and you will look like this:
           /* DO NOT EDIT THIS FILE - it is machine generated */
           #include <jni.h>
           /* Header for class DamNative */

           #ifndef _Included_DamNative
           #define _Included_DamNative
           #ifdef __cplusplus
           extern "C" {
           #endif
           /*
            * Class: DamNative
            * Method: setByte
            * Signature: (BB)V
            */
           JNIEXPORT void JNICALL Java_DamNative_setByte
             (JNIEnv *, jclass, jbyte, jbyte);

           Notice the JNIEXPORT declaration. You will need to use this declaration
           EXACTLY as it appears here in a C file that will call the desired C function.
           Note: you will want to create a java function for each C function you want to
           call, and then copy the resulting declaration from the header file to your C file.
           Create your C file (Note: make sure you add parameter names corresponding
           with the header file type ex: (JNIEnv *env, jclass cl, jbyte port, jbyte data)
           Add the C function you want to call to the declaration you just copied for the
           header file. Our setByte function looks like this in our DamNative.c file:

               JNIEXPORT void JNICALL Java_DamNative_setByte
                 (JNIEnv *env, jclass cl, jbyte port, jbyte value)
               {
                       UD(dscDIOOutputByte(board,port,value)); // sets output to board
               }

           Finally compile the C file linking to the JNI compiler AND the dscud library.
           We wrote a batch file “JNI.bat” to aid in this last step, but this was our
           command line: (yours may change if you used different directory names
           during installation):

              cl -I c:\!temp\sandbox -I c:\dev\jdk1.3\include -I c:\dev\jdk1.3\include\win32 -LD
                    DamNative.c -FeDamNative.dll -link dscud.lib

                  c:\!temp\sandbox is the location of our current header file
                  c:\dev\jdk1.3\ is the path of the JDK.
                  DamNative.c is the name of the file we want to compile.
                  DamNative.dll is the name we want it compiled to.
                  dscud.lib is the Diamond Driver Library. This last bit is very
                  important.

           Don’t forget to call the run “VCVARS32.bat” in the VC98 directory in order
           to set the environment for running the command line. We copied the contents
           out of this file into the beginning of the JNI.bat file in order to set the
           environments before running the above command line
           Now you have a DamNative.dll file that will be called anytime a java class
           calls the setByte function of the DamNative java class.
           Finally you will need to add a load library function to your Java class in order
           to load the library you just created. Ours looked like this:
              static
              {
                       System.loadLibrary("DamNative");
              }
   NOTE: We had trouble with the use of Packages, JNI and the Web Server. We
     solved this by writing our java classes without packages.

4.6 The Jakarta-Tomcat3.2 Server
Tomcat is the Reference Implementation for the Java Servlet 2.2 and JavaServer Pages
1.1 Technologies. Tomcat is the official reference implementation for these
complementary technologies and is developed under the Apache license in an open and
participatory environment. You can download the latest release quality distribution from:

       http://jakarta.apache.org/tomcat/

A bonus to this distribution is the same copy download will run on Linux Solaris or
Windows systems.

4.6.1 Setting up Tomcat on your Winnt system :
       (from the Tomcat Users Manual)

   •   Download the zip file from http://jakarta.apache.org/downloads/binindex.html.
   •   Unzip the file into some directory (say foo). This should create a new
       subdirectory named "tomcat".
   •   Change to the "tomcat" directory and set a new environment variable
       (TOMCAT_HOME) to point to the root directory of your Tomcat hierarchy.
          1. On Win32 you should type: "set TOMCAT_HOME=foo\tomcat"

           2. To enable this every time windows starts go to “System Environment”
           under My Computer/Properties and add TOMCAT_HOME=foo\tomcat to the
           system variables

   •   Set the environment variable JAVA_HOME to point to the root directory of your
       JDK hierarchy, then add the Java interpreter to your PATH environment variable.

That's it! You can now execute Tomcat and it will run as a stand-alone (type 1) servlet
container.

4.6.2 Configuing TomCat to run as an NT service

   1. Get a hold on the NT executable (jk_nt_service.exe)
          o Download the executable from the win32/i386 directory found where you
               downloaded the Tomcat binary distribution. For those using Netscape as
               your browser, try downloading a zip version of the file, if available. There
               can be problems using Netscape to download DLL files.
   2. Customize a properties file that provides the service with Tomcat information
      (wrapper.properties).
          o Locate the wrapper.properties template file in your Tomcat conf directory.
          o Update the wrapper.tomcat_home property to point at your tomcat home.
          o Update the wrapper.java_home property to point at your Java home.
   3. Install jk_nt_service by running it with the -i flag.
          o Execute jk_nt_service -I <name of service> <path to updated wrapper
               properties>
          o <name of service> should be a single word (without and spaces) such as
               Jakarta
          o <path to updated wrapper properties> should point to your
               wrapper.properties file (and the service will check it's existence.)
          o For example, a valid command line can be jk_nt_service -I Jakarta
               wrapper.properties
   4. Start tomcat as a service.
          o From the command line, execute net start <name of service> (e.g. net start
               Jakarta)
          o From the NT services applet, highlight your service and press start.
          o You may also want to set this service to “automatic” so that it starts
               automatically when the system is booted.

       Note: If the log file location in your wrapper.properties file points to the logs
       directory, and the logs directory doesn't yet exist, manually create it before
       starting the service.
   5. Stop Tomcat as a service.
         o From the command line, execute net stop <name of service> (e.g. net stop
             Jakarta)
         o From the NT services applet, highlight your service and press stop.

Special note: The Tomcat service is using AJPV to perform clean shutdown and you
should make sure that an AJPV connector is defined in your server.xml. In the absence of
a configured AJPV port the Tomcat service will kill Tomcat abruptly (that is murder it)
without giving it a chance to clean up.

To remove the installed service, execute jk_nt_service -R <name of service>

4.6.3 Advance TomCat Setup Features

   1. Modify the Tomcat NT service properties. By default the service will run in
      manual mode and under the local system user account. To modify this, open the
      NT services applet, highlight your service and press startup. A popup window is
      opened and you will be able to customize the service to your satisfaction.
   2. Modify the classpath. The classpath is determined by the wrapper.class_path
      properties, to modify it just add/remove/modify wrapper.class_path lines. The
      complete classpath is calculated by concatenating all the wrapper.class_path lines
      and putting ";" between them.
   3. Execute several Tomcat instances. Say that you want one Tomcat to run for
      "production" and one for development, you can do that. All you will need to do is
      to install the Tomcat service twice and under two different names (and with
      different wrapper.properties file and server.xml files).
           o Make sure that the AJPV12 and HTTP connectors are modified in each
              server.xml file to prevent a clash.
           o Make sure to update the wrapper.shutdown_port property in
              wrapper.properties to point to the correct AJPV12 shutdown ports (default
              is 8007).
   4. Modify the command line used to start Tomcat. The Tomcat service is taking all
      it's command line configuration from wrapper.properties! To customize the
      command line, edit the property wrapper.cmd_line and make sure that it makes a
      legal Java command line.



4.7 Developing Java Server Pages
We used JavaServer Pages to interact with the TomCat server. JavaServer Pages
technology allowed us to utilize a scripting language to communicate with the server side
JavaBean to control and receive memory from the DAMIT.

JavaServer Pages technology uses XML-like tags and scriptlets written in Java to
encapsulate the logic that generates the content for the page. Additionally, the application
logic can reside in server-based resources (JavaBeans; http://java.sun.com/beans) that the
page accesses with these tags and scriptlets.

This development of JSPs is really a two step process. First, we created a Java Class in
JavaBean format that calls the functions of the JNI class we had already created in
section 4.5.

Read the Java Server Pages Specifications at http://java.sun.com/products/jsp/ for
specific details on how to create a JSP enabled Java Bean.

We then created a Java Server Page that uses the JSP scripting commands to call the
Server Side JavaBean.

To aid in our development of the Java Server Pages and Beans we used Borland’s
JBuilder 4.0. A foundations version is available at no charge from
www.borland.com/jbuilder. It contained a simple tutorial that enabled us to begin
development of the JSP now in use on the DAMIT.

When we were done devlopment of the JSP we copied the .jsp file to the
“<tomcat>\webapps\ROOT\” directory, and copied the Java class files, along with the
compiled JNI dll and the Diamond dscud.dll into the “<tomcat>webapps\ROOT\WEB-
INF\classes” directory. A very important step to remember when creating JavaBeans that
call native methods is NOT to include them in packages. If you write a JNI enabled bean
as part of a package, you will receive an “UnsatisfiedLinkError” when you try to load the
JSP.

If you rename you JSP “index.jsp”, it will automatically be loaded whenever someone
logs into your webserver.


4.8 Launching the DAMIT
If you’ve successfully created the previous steps, you should have a working Data
Acquisition Module with Internet Technology. You should now be able to go to anyother
computer on the network and log in to the DAMIT. For example is the IP address of the
DAMIT is 192.162.10.1, you should be able to type in “http:// 192.162.10.1” into a
browser and log into the DAMIT. (Note: Some older browsers like Internet Explorer 3.0
don’t support JSP). You could likewise type “http://nameofDAMITcomputer” and also
have access to the unit. For example, the IP address we used on the Senior Project Lab
network is 131.91.81.107, and the Computers name under Network Identification is
“BELO.” Typing “http://belo” into a browser on any computer in the lab will log you
onto the DAMIT.

Ideally you could place this unit anywhere there is a network connection, or configure it
to use a modem connection, and then log into it to monitor and control a local
environment from anywhere else in the world with an internet connection.
                       Figure 5: The DAMIT System (overview)




This concept will allow for expansion of the DAMIT to numerous applications. In
addition, the hierarchical design will allow for the development of numerous control sub-
systems, which will be able to communicate in a peer-to-peer network.




5 Conclusion
Using PC architecture as the hardware and software basis for mobile and portable
embedded systems provides many advantages. The compact, modular PC-compatible
PC/104 standard was developed specifically to provide PC architecture compatibility in
space-constrained embedded applications. In addition, the modular design allows us to
utilize the Object-Oriented Paradigm while designing the DAMIT. This flexibility will
carry over into the reusability of the Data Acquisition Module with Internet Technology.
The PC104 is a very powerful tool in the design of embedded systems and in the realm of
designing future products for manufacturing.
6 References and Resources

6.1 Ampro Computers www.ampro.com

6.2 Diamond Systems www.diamondsys.com

6.3 Sun Microsystems www.sun.com
6.3.1 “The source for Java Technology” java.sun.com/

6.3.2 Java Server Pages java.sun.com/products/jsp/

6.3.3 JSP Specfications java.sun.com/products/jsp/download.html

6.4 Borland www.borland.com

6.5 TextPad www.textpad.com

6.6 JSP Resource Index www.jspin.com

6.7 Web Development with JSP www.burridge.net/jsp
6.8 Jakarta-Tomcart http://jakarta.apache.org/tomcat/
6.9 Core Java2 Volume II-Advanced Features
    Horstmann and Cornell, Sun Microsystems Publishing; 2000

6.10 Red Had Linux 6.0 Unleashed
    Pitts and Ball, Sams publishing; August 1999.
7 Appendices
7.1 index.jsp
This file is the file that is loaded automatically when someone logs onto the DAMIT. It
is the user interface that allows for monitoring and control of the DAMIT.

<HTML>
<HEAD>
<jsp:useBean id="damBeanID" scope="session" class="dam1Bean" />
<jsp:setProperty name="damBeanID" property="*" />
         <TITLE> damITIndex </TITLE>
 </HEAD>
 <BODY>
         <H1> Data Aqusition Module with Internet Technology</H1>
         <TABLE WIDTH="100%" BGCOLOR="#FFFFFF" BORDER="1">

                <TR VALIGN="BOTTOM">
                 <TD VALIGN="BOTTOM" ALIGN="CENTER" COLSPAN="3">
                         <H3>Output Values</H3></TD>
                </TR>
                <TR VALIGN="MIDDLE">
                 <TD VALIGN="MIDDLE" ALIGN="CENTER">
                         <FORM METHOD="post">
                              <P>Enter Output value (-128 to +127):<BR> <INPUT
NAME="portA1" ><BR>
                               <INPUT TYPE="SUBMIT" NAME="Port A" VALUE="Port
A"><BR>
                               Value of A1 is : <jsp:getProperty name="damBeanID"
property="portA1" /></P>
                </FORM>
           </TD>

                 <TD VALIGN="MIDDLE" ALIGN="CENTER">
                         <FORM METHOD="post">
                              <P>Enter Output value (-128 to +127)<BR> <INPUT
NAME="portB1"><BR>
                               <INPUT TYPE="SUBMIT" NAME="Port B" VALUE="Port B">
<BR>
                               Value of B1 is : <jsp:getProperty name="damBeanID"
property="portB1" /></P>
                        </FORM>
                 </TD>

                 <TD VALIGN="MIDDLE" ALIGN="CENTER">
                        <FORM METHOD="post">
                              <P>Enter Output value (-128 to +127)<BR> <INPUT
NAME="portC1"><BR><INPUT
                               TYPE="SUBMIT" NAME="Port C" VALUE="Port C"> <BR>
                               Value of C1 is : <jsp:getProperty name="damBeanID"
property="portC1" /></P>
                       </FORM>
                 </TD>
               </TR>
               <TR VALIGN="BOTTOM">
                 <TD VALIGN="BOTTOM" ALIGN="CENTER" COLSPAN="3">
                        <H3>Input Values</H3></TD>
              </TR>
              <TR VALIGN="MIDDLE">
               <TD VALIGN="MIDDLE" ALIGN="CENTER">
                      <FORM METHOD="post">
                            <P><BR> <INPUT TYPE="SUBMIT" NAME="Port A2"
VALUE="Port A2">
                             <BR>Value of Port A2 is : <%= damBeanID.getportA2()%></P>
</FORM></TD>
               <TD VALIGN="MIDDLE" ALIGN="CENTER">
                      <FORM METHOD="post">
                            <P><BR> <INPUT TYPE="SUBMIT" NAME="Port B2"
VALUE="Port B2">
                             <BR>Value of Port B2 is : <%=
damBeanID.getportB2()%></P></FORM></TD>
               <TD VALIGN="MIDDLE" ALIGN="CENTER">
                      <FORM METHOD="post">
                            <P><BR> <INPUT TYPE="SUBMIT" NAME="Port C2"
VALUE="Port C2">
                             <BR>Value of Port C2 is : <%=
damBeanID.getportC2()%></P> </FORM></TD>
              </TR>

       </TABLE> </BODY>
</HTML>
7.2 dam1Bean.java

/**
 * Title:    Data Aquistion Module with Internet Technology
 * Description:
 * Copyright: Copyright (c) 2000
 * Company:     Senior Project
 * @author David Harty and Angelo Lauria
 * @version 1.0
 */
import java.lang.Object;

public class dam1Bean
{
  private String sample = "Start value";
  private boolean started = false;
  byte portA1 = 0, portB1=0, portC1=0; // output ports
  private byte portA2, portB2, portC2; // input ports

  byte PORTA1 = (byte) 0;
  byte PORTB1 = (byte) 1;
  byte PORTC1 = (byte) 2;
  byte PORTA2 = (byte) 3;
  byte PORTB2 = (byte) 4;
  byte PORTC2 = (byte) 5;

  public void setportA1(byte newValue)
  {
    if(initBoard())
    {
        DamNative.setByte(PORTA1, newValue);
        portA1 = newValue;
    }
  }

  public void setportB1(byte newValue)
  {
    if(initBoard())
    {
        DamNative.setByte(PORTB1, newValue);
        portB1 = newValue;
    }
  }

  public void setportC1(byte newValue)
  {
    if(initBoard())
    {
        DamNative.setByte(PORTC1, newValue);
        portC1 = newValue;
    }
  }
    public byte getportA2()
    {
      if(initBoard())
      {
          portA2 = DamNative.getByte(PORTA2);
      }
      return portA2;
    }

    public byte getportB2()
    {
      if(initBoard())
      {
          portB2 =DamNative.getByte(PORTB2);
      }
      return portB2;
    }

    public byte getportC2()
    {
      if(initBoard())
      {
          portC2 = DamNative.getByte(PORTC2);
      }
      return portC2;
    }


    public boolean initBoard()
    {
      if(!started)
      {
          if(DamNative.startBoard())
             started = true;
      }
      else
          started = false;

        return started;
    }

}
7.3 DamNative.java
class DamNative
{
        static
        {
               System.loadLibrary("DamNative");
        }

       public native static void setByte(byte port, byte value); // send it a port and a value

       public native static byte getByte(byte port); // send it a port

       public native static boolean startBoard();

       public native static boolean stopBoard();

}
7.4 DamNative.h


/* DO NOT EDIT THIS FILE - it is machine generated */
#include <jni.h>
/* Header for class DamNative */

#ifndef _Included_DamNative
#define _Included_DamNative
#ifdef __cplusplus
extern "C" {
#endif
/*
 * Class: DamNative
 * Method: setByte
 * Signature: (BB)V
 */
JNIEXPORT void JNICALL Java_DamNative_setByte
  (JNIEnv *, jclass, jbyte, jbyte);

/*
 * Class: DamNative
 * Method: getByte
 * Signature: (B)B
 */
JNIEXPORT jbyte JNICALL Java_DamNative_getByte
  (JNIEnv *, jclass, jbyte);

/*
 * Class: DamNative
 * Method: startBoard
 * Signature: ()Z
 */
JNIEXPORT jboolean JNICALL Java_DamNative_startBoard
  (JNIEnv *, jclass);

/*
 * Class: DamNative
 * Method: stopBoard
 * Signature: ()Z
 */
JNIEXPORT jboolean JNICALL Java_DamNative_stopBoard
  (JNIEnv *, jclass);

#ifdef __cplusplus
}
#endif
#endif
7.5 DamNative.c
#include "DamNative.h"
#include <stdio.h>
#include <windows.h>
#include "dscud.h"
#include <stdio.h>
#include <conio.h>
#include <malloc.h>
#include <memory.h>
#include <stdlib.h>
#include <string.h>
#include <dos.h>
#include <ctype.h>

static BYTE init_board();

// This is a preprocessor macro which we will use to capture error returns
// from DSCUD functions. It calls the specified function and prints out
// nice error strings if the call fails.
#define UD(x)                                           \
   {                                             \
     jbyte retval = x;                                \
     if (retval != DE_NONE)                               \
     {                                           \
     printf("DSCUD Error : %s\n", dscGetErrorString(retval));                    \
        return;                                    \
     }                                           \
   }

// global variables
DSCB board; // our board object returned by the driver
WORD FAR *sample_values; // buffer to store interrupt or dma generated word-sized data
BYTE FAR *transfer_values; // buffer to store interrupt or dma generated byte-sized data

//*/


/****************************
 * Class: DamNative
 * Method: setByte
 * Signature: ()V
 *************************/
JNIEXPORT void JNICALL Java_DamNative_setByte
  (JNIEnv *env, jclass cl, jbyte port, jbyte value)
{
                   //TESTing// UD(dscDIOOutputByte(board,0,243)); // sets output to board
             UD(dscDIOOutputByte(board,port,value)); // sets output to board
}


/******************************
 * Class: DamNative
 * Method: getByte
 * Signature: ()V
 ******************************/
JNIEXPORT jbyte JNICALL Java_DamNative_getByte // recieves input from port
(JNIEnv *env, jclass cl, jbyte port)
  {
                   jbyte value;
                   //              dscDIOInputByte(board, 3, &value);
                   //              printf("Input port: %02x\n",value);
                   dscDIOInputByte(board, port, &value);
           // UD(dscDIOInputByte(board, port, &value));
           return value;
  }


/******************************
          Class: DamNative
          Method: startBoard
          Signature: ()V
 *****************************/
JNIEXPORT jboolean JNICALL Java_DamNative_startBoard
  (JNIEnv * env, jclass cl)
  {
           BYTE retval;

        // we use halloc because it always returns a pointer
        // with the lowest possible offset for a given memory
        // address. This allows us to use potentially big
        // buffer sizes for the interrupt/dma functions without the
        // fear that the offset part of the pointer will overflow
    sample_values = (WORD FAR *)halloc((size_t)64000.0,1);

    _fmemset(sample_values,0,(size_t)64000.0);
    transfer_values = (BYTE FAR *)sample_values;

    dscInit(DSC_VERSION);

    retval = init_board();
    if (retval == DE_NONE)
       return 1;
    else
           return 0;
}



/*************************************
 * Class: DamNative
 * Method: stopBoard
 * Signature: ()Z
 ******************************/
JNIEXPORT jboolean JNICALL Java_DamNative_stopBoard
  (JNIEnv *env, jclass jc)
  {
           dscFree();
           return 1;
  }
/****************************************************************
 * init_board
 *
 * Initialize the GMM board. This sets up the driver with
 * data it needs and also resets the hardware.
 ****************************************************************/
static BYTE init_board()
  {
                    DSCCB dsccb;
               BYTE retval;
               BYTE config[2];

             dsccb.device_number = 0;       //original base addr was 0x300
             dsccb.boards.gmm.base_address = 0x330;//changed for networking reasons

             dsccb.boards.gmm.int_level1 = 5;                        // Jumper selected

             dsccb.boards.gmm.int_level2 = 7;                        // Jumber selected

             dsccb.boards.gmm.clock_freq = 4000000.0;

             retval = dscInitBoard(DSC_GMM,&dsccb,&board);

             config[0] = 0x80;                 // A1,B1,C1: output
             config[1] = 0x9b;                 // A2,B2,C2: input

             //UD(dscDIOSetConfig(board,config));
             dscDIOSetConfig(board,config);


            if (retval == DE_NONE)
               printf("Successfully initialized a Garnet-MM board.\n");
            else
               printf("Error initializing: %s\n",dscGetErrorString(retval));
  return retval;
  //*/
 }
7.6 JNI.bat
This file is called by TextPad to set the environment variables, and then run the visual
C++ command line compiler on the DamNative.C file

Rem this first large section sets the system environment variable
@echo off
rem
rem Root of Visual Developer Studio Common files.
set VSCommonDir=C:\PROGRA~1\MICROS~1\Common

rem
rem Root of Visual Developer Studio installed files.
rem
set MSDevDir=C:\PROGRA~1\MICROS~1\Common\msdev98

rem
rem Root of Visual C++ installed files.
rem
set MSVCDir=C:\PROGRA~1\MICROS~1\VC98

rem
rem VcOsDir is used to help create either a Windows 95 or Windows NT specific path.
rem
set VcOsDir=WIN95
if "%OS%" == "Windows_NT" set VcOsDir=WINNT

rem
echo Setting environment for using Microsoft Visual C++ tools.
rem

if "%OS%" == "Windows_NT" set
PATH=%MSDevDir%\BIN;%MSVCDir%\BIN;%VSCommonDir%\TOOLS\%VcOsDir%;%VSCom
monDir%\TOOLS;%PATH%
if "%OS%" == "" set
PATH="%MSDevDir%\BIN";"%MSVCDir%\BIN";"%VSCommonDir%\TOOLS\%VcOsDir%";"%VS
CommonDir%\TOOLS";"%windir%\SYSTEM";"%PATH%"
set
INCLUDE=%MSVCDir%\ATL\INCLUDE;%MSVCDir%\INCLUDE;%MSVCDir%\MFC\INCLUDE;%
INCLUDE%
set LIB=%MSVCDir%\LIB;%MSVCDir%\MFC\LIB;%LIB%

set VcOsDir=
set VSCommonDir=



rem The next line runs the compiler

cl -I c:\!temp\sandbox -I c:\dev\jdk1.3\include -I c:\dev\jdk1.3\include\win32 -LD DamNative.c -
FeDamNative.dll -link dscud.lib

				
DOCUMENT INFO
Shared By:
Categories:
Stats:
views:16
posted:3/11/2011
language:English
pages:30