User Interface Design using CGI Programming and Boa Web Server on M5249C3 Board



Similar documents
Local Interconnect Network (LIN) Physical Interface

Initializing the TSEC Controller

Improving Embedded Software Test Effectiveness in Automotive Applications

Point-of-Sale (POS) Users Guide Lech José Olmedo Guerrero Jaime Herrerro Gallardo RTAC Americas

Programming Audio Applications in the i.mx21 MC9328MX21

etpu Host Interface by:

Understanding LCD Memory and Bus Bandwidth Requirements ColdFire, LCD, and Crossbar Switch

How To Build A Project On An Eclipse Powerbook For Anarc (Powerbook) On An Ipa (Powerpoint) On A Microcontroller (Powerboard) On Microcontrollers (Powerstation) On Your Microcontroller 2 (Powerclock

Windows 7: Using USB TAP on a Classic CodeWarrior Installation (MGT V9.2 DSC V8.3)

Connecting Low-Cost External Electrodes to MED-EKG

Blood Pressure Monitor Using Flexis QE128 Gabriel Sanchez RTAC Americas

Handling Freescale Pressure Sensors

Installation of the MMA955xL CodeWarrior Service Pack Author: Fengyi Li Application Engineer

Performance Monitor on PowerQUICC II Pro Processors

Connecting to an SMTP Server Using the Freescale NanoSSL Client

Using WinUSB in a Visual Studio Project with Freescale USB device controller

IRTC Compensation and 1 Hz Clock Generation

Data Movement Between Big-Endian and Little-Endian Devices

Freescale Embedded GUI Converter Utility 2.0 Quick User Guide

Cyclic Redundant Checker Calculation on Power Architecture Technology and Comparison of Big-Endian Versus Little-Endian

PowerQUICC II Pro (MPC83xx) PCI Agent Initialization

Software Real Time Clock Implementation on MC9S08LG32

PQ-MDS-T1 Module. HW Getting Started Guide. Contents. About This Document. Required Reading. Definitions, Acronyms, and Abbreviations

How To Control A Motor Control On An Hvac Platform

Hardware Configurations for the i.mx Family USB Modules

Techniques and Tools for Software Analysis

Generate Makefiles from Command Line Support in Eclipse-Based CodeWarrior Software

3-Phase BLDC Motor Control with Hall Sensors Using 56800/E Digital Signal Controllers

MC13783 Buck and Boost Inductor Sizing

Flexible Active Shutter Control Interface using the MC1323x

MPC8245/MPC8241 Memory Clock Design Guidelines: Part 1

Freescale Semiconductor. Integrated Silicon Pressure Sensor. On-Chip Signal Conditioned, Temperature Compensated and Calibrated MPX4080D.

Real Time Development of MC Applications using the PC Master Software Visualization Tool. 1. Introduction. 2. Development of Motor Control.

How to Convert 3-Axis Directions and Swap X-Y Axis of Accelerometer Data within Android Driver by: Gang Chen Field Applications Engineer

Using the Performance Monitor Unit on the e200z760n3 Power Architecture Core

Detecting a CPM Overload on the PowerQUICC II

Using Program Memory As Data Memory. 1. Introduction Program Memory and Data. Contents. Memory. Freescale Semiconductor Application Note

Freescale Semiconductor. Integrated Silicon Pressure Sensor. On-Chip Signal Conditioned, Temperature Compensated and Calibrated MPX5500.

Understanding Pressure and Pressure Measurement

VGA Output using TV-Out Extension Solution i.mx21

Enhanced Serial Interface Mapping

USB HID bootloader for the MC9S08JM60

MCF54418 NAND Flash Controller

How To Fit A 2Mm Exposed Pad To A Dfn Package

Using the High Input Voltage Charger for Single Cell Li-Ion Batteries (KIT34671EPEVBE)

Genesi Pegasos II Setup

Implementing Positioning Algorithms Using Accelerometers

White Paper. Freescale s Embedded Hypervisor for QorIQ P4 Series Communications Platform

3-Phase BLDC Motor Control with Hall Sensors Using the MC56F8013

Using XGATE to Implement LIN Communication on HCS12X Daniel Malik 8/16-Bit Products Division East Kilbride, Scotland

Developing an Application for the i.mx Devices on the Linux Platform

ITU-T V.42bis Data Dictionary Search on the StarCore SC140/SC1400 Cores

MLPPP in the Evolving Radio Access Network

CodeWarrior Development Studio Floating Licensing Quick Start

How To Measure Power Of A Permanent Magnet Synchronous Motor

Processor Expert Software Microcontrollers Driver Suite Getting Started Guide

User Guide. Introduction. HCS12PLLCALUG/D Rev. 0, 12/2002. HCS12 PLL Component Calculator

ColdFire Security SEC and Hardware Encryption Acceleration Overview

Using eflexpwm Module for ADC Synchronization in MC56F82xx and MC56F84xx Family of Digital Signal Controllers

Using the HC08 SCI Module

How To Improve Performance On A P4080 Processor

NOT RECOMMENDED FOR NEW DESIGN

Installing Service Pack Updater Archive for CodeWarrior Tools (Windows and Linux) Quick Start

i.mx28 Ethernet Performance on Linux

Using the Kinetis Security and Flash Protection Features

Efficient Low-Level Software Development for the i.mx Platform

SEMICONDUCTOR TECHNICAL DATA

NOT RECOMMENDED FOR NEW DESIGN

MPXAZ6115A MPXHZ6115A SERIES. Freescale Semiconductor Technical Data. MPXAZ6115A Rev 4, 01/2007

Configuring the FlexTimer for Position and Speed Measurement with an Encoder

LOW POWER NARROWBAND FM IF

MSC8156 and MSC8157 PCI Express Performance

A Utility for Programming Single FLASH Array HCS12 MCUs, with Minimum RAM Overhead

Emulated EEPROM Implementation in Dual Flash Architecture on MC9S08LG32 With Demo Description

i.mx Applications Processors with Hantro's Multimedia Framework

P D Operating Junction Temperature T J 200 C Storage Temperature Range T stg 65 to +150 C

Getting Started with the Student Learning Kit Featuring the Freescale HCS12 Microcontroller Application Module

Ref Parameters Symbol Conditions Min Typ Max Units. Standby μa. 3 Range kpa. 4 Resolution 0.15 kpa. 5 Accuracy -20ºC to 85ºC ±1 kpa

CodeWarrior Development Studio for Freescale S12(X) Microcontrollers Quick Start

ULN2803A ULN2804A OCTAL PERIPHERAL DRIVER ARRAYS

Freescale Semiconductor, I

Installing Service Pack Updater Archive for CodeWarrior Tools (Windows and Linux) Quick Start

AND8365/D. 125 kbps with AMIS-4168x APPLICATION NOTE

LOW POWER SCHOTTKY. GUARANTEED OPERATING RANGES ORDERING INFORMATION

VLE 16-bit and 32-bit Instruction Length Decode Algorithm

AND8336. Design Examples of On Board Dual Supply Voltage Logic Translators. Prepared by: Jim Lepkowski ON Semiconductor.

MC33064DM 5 UNDERVOLTAGE SENSING CIRCUIT

Freescale Variable Key Security Protocol Transmitter User s Guide by: Ioseph Martínez and Christian Michel Applications Engineering - RTAC Americas

Comparison of MC9S08QE128 and MCF51QE128 Microcontrollers Scott Pape and Eduardo Montanez Systems Engineering, Freescale Microcontroller Division

AND9190/D. Vertical Timing Optimization for Interline CCD Image Sensors APPLICATION NOTE

Robust Over-the-Air Firmware Updates Using Program Flash Memory Swap on Kinetis Microcontrollers

How to Do EEPROM Emulation Using Double Flash Array on MC9S08LC60 Ronald Gonzalez and Tatiana Orofino RTAC Americas

Solder Joint Temperature and Package Peak Temperature Determining Thermal Limits during Soldering

Multicore Processing: Virtualization and Data Center

RF Power Field Effect Transistors N- Channel Enhancement- Mode Lateral MOSFETs

Adding SDIO Wi-Fi Solution to i.mx Windows CE 5.0/Windows CE 6.0

NOT RECOMMENDED FOR NEW DESIGN

Transcription:

Freescale Semiconductor Application Note AN3238 Rev. 0, 02/2006 User Interface Design using CGI Programming and Boa Web Server on M5249C3 Board by: H.K. Au MCD Applications 1 Introduction This application note describes the implementation of a user interface on the M5249C3 board. The user interface is developed using CGI programming with Boa server running on uclinux at M5249C3 board side as shown below: User Web browser Boa web server Web page / CGI program PC running Linux or Windows Ethernet M5249C3 / uclinux Figure 1. System Setup The user can get the web page or invoke an executable program stored at the M5249C3 board side through the web browser and the Boa web server. A simple example is used in this document to illustrate how to implement this kind of user interface. This example allows the user to input three parameters at the parameter setting web page, and then display them at the result display page. This application note assumes a familiarity of running uclinux on the ColdFire EVB. Therefore, the procedure of compiling uclinux and download the uclinux image to the Freescale Semiconductor, Inc., 2006. All rights reserved.

Boa Setup EVB are not included. The EVB used in this application note is the M5249C3. However, the procedure described in this application note can be applied to other ColdFire EVBs without a big difference. 2 Boa Setup Boa web server can be setup in uclinux by enabling the boa in make xconfig ( uclinux Application Configuration => Network Application ). The default setting of Boa is: The directory index file is index.html in /home/httpd/ The CGI binary files are in /home/httpd/cgi-bin/ These settings can be changed by modifying the file home//httpd/boa.conf. No need to modify boa.conf if the default setting is used. The example in the document used the default setting. In uclinux source code, the index.html file is located in vendor/generic/httpd. After compilation, the index.html will be copied to home/httpd in romfs. So, the first step is to create the index.html file as shown at Appendix A and then copy the index.html to vendor/generic/httpd and replace the original index.html from the uclinux distribution. When the user accesses the Boa web server using http:// <IP address of the M5249C3 board>, the index.html will be shown at the user s web browser as below: Figure 2. Home Page 2 Freescale Semiconductor

3 CGI Programming Example CGI Programming Example The common gateway interface (CGI) is a protocol that transmits data between the user web browser and the web server. In the example used in this document, the data are the parameters that user input to the M5249C3 board running uclinux. The CGI programs used in the example are all written in C language. There are two CGI programs used in this example and they are modified from the demo programs in the uclinux distribution. The first is the cgi_demo in /user/cgi_generic/. This program was modified to get the parameters from the user. Figure 3. Parameter Setting Page When the Enter button is clicked, all three parameters shown will be shown at the resulting web page. When the Reset button is clicked, the parameters will be reset to null and any modification done on the browser will be lost. For each input parameter in the example, the maximum length is 16 characters and no space character is allowed. The second CGI program is the query-results file in /user/cgihtml/examples/. This program was modified to get the parameters input by user then display the parameters on the web browser as shown: Freescale Semiconductor 3

Design of the CGI Program Figure 4. Parameter Display Page 4 Design of the CGI Program The design of the example shown in previous section will be described in this section. 4.1 Home Page The home page is the index.html file in directory home/httpd/index.html. In the example, there is a link to parameter setting page in the home page. This is done by the following line of code in index.html: <A HREF=/cgi-bin/cgi_demo>Parameter Setting</A> When the Parameter Setting icon is clicked on the home page, it will execute the cgi_demo file in /cgi-bin/. 4.2 Parameter Setting Page The Parameter Setting Page is created by the cgi_demo file which is a CGI program in C language. This C program is modified from the demo program in uclinux (/user/cgi_generic/). If this demo program is not used in real software development, a new application under uclinux can be created. The subroutine template_page() is responsible for displaying the parameter setting page. The source code is in template.c. The template_page() subroutine uses the HTML form attribute to display the user input parameters and allow the parameter modification. In the form action attribute, it specifies the URL of /cgi-bin/query-results. 4 Freescale Semiconductor

Summary of Procedure of Preparing the CGI Example Source Code and Testing The template_page() subroutine is invoked by main() in /user/cgi_generic/cgi.c as shown in Appendix A. 4.3 Parameter Display Page The query-results file is a CGI program which displays the parameter input at Parameter Display Page. The query-results is modified from the example of cgihtml library. cgihtml is a collection of CGI parsing and HTML output functions written in C. These routines simplify the task of writing CGI programs in C. The source code of query-results is in /user/cgihtml/examples/query-results.c. query-results uses the subroutines read_cgi_input() and print_entries() in cgihtml library for getting and display parameter respectively. There are a lot of functions in the cgihtml library for writing a CGI program in C. Please refer to the documents in /user/cgihtml/docs/ for more information. After displaying the input parameters, the program terminates for this example. However, if further processing on the input parameter is required, the inputs are available to the C program for processing. For example, use the function cgi_val() as shown in the query-result.c source code in Appendix D. In summary, the design of the CGI program example in this documents looks like this: cgi-bin/cgi_demo form action cgi-bin/query-results read_cgi_input(); print_entries(); Getting parameters from user Further processing on input home/httpd/index.html home/httpd/cgi-bin/cgi_demo home/httpd/cgi-bin/query-results Figure 5. CGI Program Flow 5 Summary of Procedure of Preparing the CGI Example Source Code and Testing Procedure: 1. Prepare index.html as shown in Appendix A. Copy to uclinux source code vendor/generic/httpd/ and replace the original index.html. 2. Prepare cgi.c as shown in Appendix B. Copy to uclinux source code /user/cgi_generic/ 3. Prepare template.c file as shown in Appendix C. Copy to uclinux source code /user/cgi_generic/ Freescale Semiconductor 5

Conclusion 4. Prepare query-results.c file as shown in Appendix D. Copy to uclinux source code user/cgihtml/examples/ 5. Enable boa in make xconfig (in Network Application) 6. Enable cgi generic and cgihtml in make xconfig (in uclinux Application Configuration =>Miscellaneous Configuration). 7. Execute make dep and make to generate the uclinux image.bin 8. Download the image.bin file to the M5249C3 board and run uclinux (g 20000) 9. Configure the IP address of uclinux and the host computer of the web browser on the same IP address domain. Test the CGI demo as described in Section 2, Boa Setup, and Section 3, CGI Programming Example. 6 Conclusion An example of how to design a user interface for a M5249C3 board/uclinux embedded system using CGI/Boa is shown in this application note. Through good web page design using HTML, it is possible to develop a simple, user-friendly, and interactive method of getting input from the user. Software development effort can also be reduced if the existing CGI library in the uclinux distribution is used, as shown in this application note. 6 Freescale Semiconductor

Appendix A index.html Conclusion <HTML> <HEAD> <TITLE>A test web page</title> </HEAD> <BODY> <H1>Home Page</H1> <P> Please select function: <P> <A HREF=/cgi-bin/cgi_demo>Parameter Setting</A> </BODY> </HTML> Freescale Semiconductor 7

Conclusion Appendix B cgi.c /* cgi.c */ #include <stdio.h> #include <string.h> #include "cgivars.h" #include "htmllib.h" #include "template.h" int main() { } char **postvars = NULL; /* POST request data repository */ char **getvars = NULL; /* GET request data repository */ int form_method; /* POST = 1, GET = 0 */ form_method = GET; htmlheader("demo Web Page"); htmlbody(); template_page(postvars, form_method); htmlfooter(); cleanup(form_method, getvars, postvars); exit(0); fflush(stdout); 8 Freescale Semiconductor

Appendix C template.c Conclusion /* template.c */ #include <stdio.h> #include "cgivars.h" #include "htmllib.h" int template_page(char **postvars, int form_method) { int i; char *a=null; addtitleelement("parameter Setting"); /* GET */ printf("<form ACTION=\"%s\" METHOD=POST>", "/cgi-bin/query-results"); printf("<p>parameter 1 "); printf("<input NAME=\"Parameter_1\" VALUE=%s SIZE=\"16\" MAXLENGTH=\"16\">(Max. 16 char. No space) </BR>",a); printf("<p>parameter 2 "); printf("<input NAME=\"Parameter_2\" VALUE=%s SIZE=\"16\" MAXLENGTH=\"16\"></BR>", a); printf("<p>parameter 3 "); printf("<input NAME=\"Parameter_3\" VALUE=%s SIZE=\"16\" MAXLENGTH=\"16\"></BR>", a); printf("<br><input TYPE=submit VALUE=\"Enter\">"); printf("<input TYPE=reset VALUE=\"Reset\">"); printf("</form>"); return 0; } Freescale Semiconductor 9

Conclusion Appendix D query-results.c /* query-results.c */ #include <stdio.h> #include "cgi-lib.h" #include "html-lib.h" int main() { llist entries; int status; char *p1="parameter_1"; char *p2="parameter_2"; char *p3="parameter_3"; char *first_input; char *second_input; char *third_input; html_header(); html_begin("query Results"); status = read_cgi_input(&entries); h1("<small><font color=red>parameter Input from User:</small><font color=blue>"); } print_entries(entries); html_end(); /*************************************************************** Futher processing on the input parameters can be done here. ***************************************************************/ first_input = cgi_val(entries, p1); // Example of getting the input to second_input = cgi_val(entries, p2); // the C program for processing third_input = cgi_val(entries, p3); // using function cgi_val() list_clear(&entries); return 0; 10 Freescale Semiconductor

This page intentionally left blank. Freescale Semiconductor 11

How to Reach Us: Home Page: www.freescale.com E-mail: support@freescale.com USA/Europe or Locations Not Listed: Freescale Semiconductor Technical Information Center, CH370 1300 N. Alma School Road Chandler, Arizona 85224 +1-800-521-6274 or +1-480-768-2130 support@freescale.com Europe, Middle East, and Africa: Freescale Halbleiter Deutschland GmbH Technical Information Center Schatzbogen 7 81829 Muenchen, Germany +44 1296 380 456 (English) +46 8 52200080 (English) +49 89 92103 559 (German) +33 1 69 35 48 48 (French) support@freescale.com Japan: Freescale Semiconductor Japan Ltd. Headquarters ARCO Tower 15F 1-8-1, Shimo-Meguro, Meguro-ku, Tokyo 153-0064 Japan 0120 191014 or +81 3 5437 9125 support.japan@freescale.com Asia/Pacific: Freescale Semiconductor Hong Kong Ltd. Technical Information Center 2 Dai King Street Tai Po Industrial Estate Tai Po, N.T., Hong Kong +800 2666 8080 support.asia@freescale.com Information in this document is provided solely to enable system and software implementers to use Freescale Semiconductor products. There are no express or implied copyright licenses granted hereunder to design or fabricate any integrated circuits or integrated circuits based on the information in this document. Freescale Semiconductor reserves the right to make changes without further notice to any products herein. Freescale Semiconductor makes no warranty, representation or guarantee regarding the suitability of its products for any particular purpose, nor does Freescale Semiconductor assume any liability arising out of the application or use of any product or circuit, and specifically disclaims any and all liability, including without limitation consequential or incidental damages. Typical parameters that may be provided in Freescale Semiconductor data sheets and/or specifications can and do vary in different applications and actual performance may vary over time. All operating parameters, including Typicals, must be validated for each customer application by customer s technical experts. Freescale Semiconductor does not convey any license under its patent rights nor the rights of others. Freescale Semiconductor products are not designed, intended, or authorized for use as components in systems intended for surgical implant into the body, or other applications intended to support or sustain life, or for any other application in which the failure of the Freescale Semiconductor product could create a situation where personal injury or death may occur. Should Buyer purchase or use Freescale Semiconductor products for any such unintended or unauthorized application, Buyer shall indemnify and hold Freescale Semiconductor and its officers, employees, subsidiaries, affiliates, and distributors harmless against all claims, costs, damages, and expenses, and reasonable attorney fees arising out of, directly or indirectly, any claim of personal injury or death associated with such unintended or unauthorized use, even if such claim alleges that Freescale Semiconductor was negligent regarding the design or manufacture of the part. Freescale and the Freescale logo are trademarks of Freescale Semiconductor, Inc. All other product or service names are the property of their respective owners. Freescale Semiconductor, Inc. 2006. All rights reserved. For Literature Requests Only: Freescale Semiconductor Literature Distribution Center P.O. Box 5405 Denver, Colorado 80217 1-800-441-2447 or 303-675-2140 Fax: 303-675-2150 LDCForFreescaleSemiconductor@hibbertgroup.com AN3238 Rev. 0, 02/2006