Download as pdf or txt
Download as pdf or txt
You are on page 1of 3

2011 International Conference on Intelligence Science and Information Engineering

Research of Embedded WebServer Based on


CAN-TCP/IP Gateway
Fei Xiao Zemin Zhu
College of Mathematics and Computer Science College of Mathematics and Computer Science
Huanggang Normal University Huanggang Normal University
Huanggang, Hubei Province, China Huanggang, Hubei Province, China
jsjxiaof@126.com zzm163com@163.com

Abstract - This article introduced the CAN, TCP/IP protocol Network Client, and operate embedded CAN-TCP/IP
and the embeded CAN-TCP/IP gateway based on them, Gateway through Internet browser directly at once. In the
researched and implemented embeded WebServer based on uClinux operating system, we can use general Web Server,
CAN-TCP/IP gateway. Embeded Web server of CAN bus has they are mainly httpd, thttpd and Boa. Httpd is a most
greatly enhanced usability and practicality of CAN-TCP/IP simple Web Server, whose function is the weakest, and it
gateway. doesn’t support authentication or CGI. However, thttpd and
Boa support both authentication and CGI and so on, its
Keywords-- uClinuxΙCAN-TCP/IPΙEmbeded WebServer function is quite complete.In order to implement Dynamic
Web Technology, we choose an Boa Web Server which
I. THE OVERVIEW OF CAN AND TCP/IP supports CGI and is quite fit for embedded WebServer. Boa
CAN Ε TCP/IP are two kinds of protocol which is is a single task http server, its Source Code is open and has
high performance. At present, the code in uClinux has
widely applied. TCP/IP is quite popular on the internet, it is
already included the boa source code. In a particular
communication protocol offering communication to the
uClinux system to achieving Boa, needs to do some
connected network computer. But its transmission and
configuration and modification to the Boa.
efficiency are difficult to meet the requirements of the
scene. CAN is a kind of excellent fieldbus, however, remote FLASH unit SDRAM unit LAN Cable
communication has a lot of deficiencies. With the
development of embeded products, especially the
appearance of Linux which has the feature by Source Code
of opening makes embedded system that connects the ARMS3C4510B
advantage technology of TCP/IP and CAN has high Ethernet
LAN Cable CPU unit
performance and practicality. Physical CAN Bus
layer Ethernet interface unit
Transceiver Controller
II. EMBEDDED CAN-TCP/IP GATEWAY
The embedded CAN-TCP/IP Gateway is developed by
Figure 1 Hardware structure of CAN bus embedded TCP / IP Gateway
uClinux system, it connects the advantages of both
technologies, that is, TCP/IP and CAN. IV. REALIZATION OF EMBEDDED
It implements the CAN bus and Ethernet TCP / IP WEBSERVER IN THE BOA WEB SERVER
protocol conversion through which the CAN Ethernet can
transmit and receive CAN, it requires a PC on the network A. Boa Server Configuration
can pass application software Operation Gateway, and
The Boa Server Configuration is achieved by modifying
implement the sending and receiving information of CAN.
boa.conf and mime.types files, the configuration needed to
In LAN, run Ethernet communication program which is
change are as followings:
based on Windows CAN-TCP/IP written on PC, link the
target board through Ethernet, comply the reception and 1) Making Directory Manually
display of network information, and send information to Because default root file system of uClinux is read-
CAN network. The hardware structure of CAN-TCP/IP only,we can’t use mkdir command, etc for the new
Gateway is shown in Figure 1. directory,Therefore, we need to build the directory to use
before compiling the kernel,which is achieved by modifying
III. EMBEDDED WEBSERVER the /uclinux-samsung/vendors/Samsung/4510b/makefile.
Add Home/webhome/web/cgi-bin to the back of
In the field of measurement and control, we often need ROMFS_DIRS =bin dev etc home lib mnt proc usr var, with
to remotely inquire the real-time status of Control Object, or modifying the kernel, romfs root file system which is
execute some kind of control operations. Embedded compiled includes these contents.
WebServer can achieve CAN bus Remote monitoring of
network device. In this way, Client needn’t install special

978-0-7695-4480-9/11 $26.00 © 2011 IEEE 279


DOI 10.1109/ISIE.2011.133

Authorized licensed use limited to: Corporacion Universitaria de la Costa. Downloaded on April 22,2021 at 18:13:18 UTC from IEEE Xplore. Restrictions apply.
2) Set Web SERVER_ROOT the outcome document of HTML form,send back
Enter the contents of /uclinux-samsung/user/boa/src/,set browser,and display it for the users by Web servers.
SERVER_ROOT by modifying the statement of #define
ERVER_ROOT“/home”in the define.h file.What’s more,we Browser on WEB Server
can set it by modifying the order,for example, boa-c the network
/home/&.Moreover,the SERVER_ROOT which is set by the
command line can cover the things that set in the define.h
file. ΞΞ CGI Program
3) Modify the boa.conf file
Modify the file in the ./uclinux- samsung/user/ boa/ src/
boa.conf: Browser on the
Change user obody network Documentation
Group ogroup Resources
To User 0
Group 0; CAN bus embedded Web
Change DocumentRoot/var/www to Document Root/ server
home/web,in this way, the SERVER_ROOT of web server's
Figure 2 CGI work flow chart
document is /home/web;
CGI program can use any program to design
Change mimeTypes /etc/mime.types to MimeTypes
language,for eaxample, shell scripting language Ε Perl Ε
/home/web/mime.types;
Define a default home page and CGI program FortranΕPascalΕC language and so on.However,uClinux
content,that is, don’t support PerlΕFortran language,etc,and C language
Directory Index index.htm performs well on the platform-independence,Therefore, we
Script Alias /cgi-bin/ /home/web/cgi-bin/ choose C language to write CGI programs.In addition,
After setting, index.htm is the home defaults that the uClinux does not support database,either, the data which
Remote View Clients see when they access needs to be saved can be only saved in the files,these files
WebServer.Then, edit CGI program written by C language are also the ones when CGI queries data,but they are not to
into a binary file,put in the contents of /cgi-bin/,CGI access the database.
program can be properly implemented. Devices in uClinux are also as files to access,so in the
Boa.conf file and mime.types file must put in the CGI program,we can aslo read and write the devices,such as
SERVER_ROOT of WebServer,so copy boa.conf file and sja1000 CAN,etc,that is, the operation of sending CAN and
mime.types file which are modified into the content receiving CAN.
of“./uclinux-samsung/romfs/home/”. Then,modify them in C. Edit Web pages
the /uclinux-samsung/Vendors/Samsung/4510b/inittab,add
the boa:unknown:/bin/boac/home in the back of Web pages is a HTML Web document,which requires
inet:unknown:/bin/inetd. embedded form.When compiling Web pages,the related
After configuration, recompile the kernel,select boa CGI program is designed by ACTION property,for example,
options when compiling.download the compiled kernel to ACTION=cgi-bin/CanServer; the method of submitting data
the development board, start uClinux,finish IP is specified by Mothod Properties,that is, METHOD =
configuration, start Boa Web Server,then you can access POSTΰGET is also OKα.Put the file in the /home/web
your website by IE. content.This Page appears for IP address which other
browsers access the device.
B. CGI Introduction
There are four kinds of technology offered to choose for D. Edit CGI program
achieving Dynamic Web pages; CGI(Common Gateway CGI program can be divided into the following parts:
Interface) Ε ASP (Active XServerPage) Ε PHP(Personal (1)accroding to POST method or GET method,receive data
Home Page)and JSP(Java Server Page).But ASPΕPHP and from the submitted form; (2)the decoding of URL encoding;
other dynamic page technology are not supported by (3)use printf () function to generate HTML source code,and
uClinux at present. If we want to implement dynamic web the data correctly return to the browser after decoding.Edit
pages, we can only adopt CGI mode. the written CGI program into binary file and put in the
The use of CGI (Common Gateway Interface) is to offer cgibin content,CGI program can be correctly executed.
Web Servers a channel that executes external program, this Here introducing the CGI program core of CanTcp.c that
server technology makes it Interactive between the browser we edit,which completes CAN information receiving and
and server. CGI program belongs to an external program, displays to the browser.It mainly includes two parts:read
which needs to be edited into an executable file in order to CAN receiving information and output HTML data stream.
run the server, its application structure is shown in Figure 2. sjadev = open("/dev/sja1000",O_RDWR);
User input data is sent to the Web server by browser, the // open sja1000 device
Web server sends data to CGI program by stdin, probably if ( sjadev == -1 )
access some files of stored data,finally,using stdout outputs {

280

Authorized licensed use limited to: Corporacion Universitaria de la Costa. Downloaded on April 22,2021 at 18:13:18 UTC from IEEE Xplore. Restrictions apply.
printf("Cann't open file "); [2] Xiao Fei,Zhu Zemin,Yin Yedan. Driver Design of CAN Bus Device
exit(0); Based on Embeded uClinux[J]. Microcomputer Information,2008,pp.
84-85.
}
[3] Ma Xintao,Li Hongping. Research and Realization of Embeded
read(sjadev,buf,13); // read sja1000 device,put the CAN Gateway Based on ARM and Linux[J]. Information
information into buf Technology.2010,pp.49-50.
for (i = 0; i < 13;i++) [4] Wu Jian,Zhang Jiaqi,Jiang Pin. Implementation of WebServer and
itos(buf[i],strbuf+i); CGI On uClinux[J].Control Technology.2007, pp. 68-69.
// convert CAN Integer into a string
close(sja1000); // close CAN device
printf("Content-type:text/html\n\n");
printf("<HTML>\n");
// the sign of starting the HTML File
printf("<HEAD>\n");
// the header information of HTML file
printf("<TITLE>HTML & CGI Script Demo
Result</TITLE>\n");
// title Information
printf("</HEAD>\n");
printf("<BODY>\n");
printf("<H1>sja1000 CAN device receives information
and displays </H1>\n");
printf("CAN_ID0Κ %s\n", strbuf[0]);
// display CAN_ID0
printf("CAN_ID1Κ %s\n", strbuf[1]);
// display CAN_ID0
………………
printf("CAN_DATA7Κ %s\n", strbuf[12]);
// display CAN_DATA7
printf("</BODY>\n");printf("</HTML>\n");
fflush(stdout);
// take HTML information above as data stream
to send out
exit(0);
// end of program
V. Conclusion
WebServer in the embedded uClinux improves CAN-
TCP/IP Gateway's usability. The Boa WebServer server
which this article studies and uses is a small Web server,it
handles a limited number of client connections at the same
time.We can research thhttpd or other WebServer and
transplant it to the uClinux system, so that we can achieve
its producibility better.
Acknowledgment
I thank reviewers for constructive reviews and
suggestions that improved the quality of this manuscript.
This essay is the fruit of our several months’ consisting
work. This work was funded by the Fund of Huanggang
Normal University (NO: 07CA085) and Hubei Provincial
Department of Education funded projects
(NO: B20082701).

REFERENCES
[1] Lin Shibing, Yuan Yan, Yang Yupu. TCP / IP network and the CAN
Network Gateway Design and Implementation[J]. Computer
Engineering, 2007,pp. 249-250,264.

281

Authorized licensed use limited to: Corporacion Universitaria de la Costa. Downloaded on April 22,2021 at 18:13:18 UTC from IEEE Xplore. Restrictions apply.

You might also like