Global Sources
EE Times-India
Stay in touch with EE Times India
EE Times-India > Embedded

Designing an embedded Web app server (Part 1)

Posted: 09 Jan 2014     Print Version  Bookmark and Share

Keywords:Web application  LAN  TCP/IP  Embedded systems  ruggedized PC 

To figure that out, let's look at what needs to be done. Development work can be broken down into the following categories:
 • Managing data
 • Parsing requests
 • Assembling responses

All of this needs string manipulation. String manipulation in C isn't rocket science, but it's tedious and extremely easy to get wrong. Everything must be strictly typed, and memory must be explicitly reserved and released as needed, requiring scrupulous attention to every detail and making maintenance difficult. Assembling a C server page requires string concatenation on a grand scale.

On the other hand, with Web scripting environments such as Lua, much of this work has already been done. The application server abstracts the web server details, giving access to request and response objects and their associated APIs. This means that the application specific code has to deal only with high-level behaviour and data.

A single line of script can implement the entire string concatenation. The lower-level machinations are automatically handled. Scripts also access and manipulate data without the need to worry about data organisation or type definition.

Another important distinction is that scripting languages use just-in-time compilation while the system is operating. Whenever the user navigates or refreshes the browser, the virtual machine compiles any changed script before it sends the requested page to the browser, thereby automating the host of compilation, linking, and other developer overheads associated with an equivalent C-based application. Figure 5 illustrates the development process.

Figure 5: Scripting languages ensure that the scripts are compiled just-in-time when requested by the browser. The diagram relates to the Lua language (Lua Server Page).

So the bottom line becomes clear. Web applications can be developed in as little as 1/30th of the time if, instead of using custom written C, scripts and pre-built infrastructure are used wherever possible.

Scripts don't totally eliminate C from the equation. C is retained for what it does best (figure 6). Scripting environments intentionally restrict scripts from getting down to the hardware level, so C routines (similar to drivers) connect the hardware to the web application.

Figure 6: Lua to C/C++ access is called a Lua binding and can be created manually or by using an automatic Lua Binding Generator.

Maintaining sharp user response
It would be easy to suppose that the overhead of compilation 'on the fly' would impact the user experience, but that is far from the case. In fact, the impact on response time is negligible compared with the overhead of the network connection. Lua web applications typically respond with lightning speed, even when run in small, web-based embedded devices.

That experience can be further enhanced by writing user interface applications that can send data to, and retrieve data from, a server asynchronously, in the background, without interfering with the display and behaviour of the existing page.

Embedded is not the same
The difference in the embedded environment and the restraints it imposes make a massive difference to the optimal deployment of HTTP communication technology.

In the end, what really matters is that end users experience the system in a way that matches what they expect. By using web or application servers designed to work on small embedded systems along with an appropriate scripting language, you can focus on your key application development, giving your users the interface they want while letting you dedicate most of your energy to doing the things that you do best.

In Part 2 we will describe how to use the Lua Web scripting language to integrate Internet Protocol connectivity into your C-language application code.

About the author
Wilfred Nilsen, Founder & CTO of Real Time Logic, has 25 years' experience in designing embedded software. Powered by a vision of a connected embedded systems, he designed the Barracuda Application Server, tailoring it for the small footprint, real-time needs of embedded microcontrollers and microprocessors.

To download the PDF version of this article, click here.

 First Page Previous Page 1 • 2 • 3

Comment on "Designing an embedded Web app server..."
*  You can enter [0] more charecters.
*Verify code:


Visit Asia Webinars to learn about the latest in technology and get practical design tips.


Go to top             Connect on Facebook      Follow us on Twitter      Follow us on Orkut

Back to Top