Combining high-level design with speed and flexibility is the key to machine-to-machine development. Fabien Fleutot reports.
Potential applications for wireless machine-to-machine (M2M) technology include automotive telematics, alarms, asset tracking, utility metering and many more. Web-based tools provide an ideal vehicle for vendors and end users to interact with these devices, enabling functions such as remote monitoring and reporting as well as aiding application prototyping, development and maintenance.
Developers of web-based applications for desktop environments favour interpreted programming languages such as PHP, Perl, Python or Ruby. Particularly attractive are convenience features and high-level programming constructs that reduce development time. Of course, interpreted languages have also provided the critical enabling technology for dynamic content on the web.
However, a dynamic language that offers value to M2M developers must also be embeddable, and the CPU and memory resource demands of most available languages are too high. M2M developers also frequently need a language able to ensure the real-time responsiveness.
Some M2M platform vendors have ported an interpreted language such as Python to support rapid design of web-based applications and to accelerate programming. However, to achieve a result that is suitable for embedding, developers have had to dramatically reduce the libraries supporting Python, as well as removing support for specific instructions. These adjustments compromise the power of the language, creating an embedded application solution that is able only to perform simple operations such as modem control but with limited value for powerful application-level functions.
As a compromise between C and a real dynamic language, Java has been successfully ported to a large number of consumer cellular platforms. Again, however, the difference between the original release and subsequent embeddable variants introduces certain limitations. In the case of Java, its portability to adapt to different hardware platforms quickly and easily is not available in J2ME, the embeddable version of Java.
The speed challenges associated with using a virtual machine to run the semi-compiled Java bytecode have also restricted developers working with Java in embedded designs. Although dynamic compilation has successfully extracted higher performance, Java is not a powerful choice for developers seeking real-time performance.
To satisfy demands for real-time performance in M2M applications, one solution could be to use a combination of an embeddable interpreted language for high-level functions with a more suitable language such as C/C++ for the low-level and real-time tasks.
Lua is an interpreted language whose API is conceived to allow strong integration with code written in lower level languages, especially C/C++, enabling developers to switch between C/C++ and Lua at will - ideal for M2M applications that require both real-time performance and high-level productivity and convenience. Writing high-level functions in Lua affords the benefits of compact code and high productivity, while strategic use of C/C++ code enables real-time performance and efficient implementation of hardware-related functions.
For M2M applications, Lua's networking capabilities and ability to support TCP/IP-based functions such as a Telnet or web server come with the advantages of low memory footprint and resource overhead. Lua allows easy implementation of programs from small web applications up to complete multithreaded servers such as FTP, HTTP or others, using relatively few lines of code, with each thread typically imposing an overhead of only around 1Kbyte.
Sierra Wireless (formerly Wavecom) has ported Lua to its Open AT RTOS software platform for its range of Wireless CPU devices, ARM9 based processors with embedded cellular modems. Complete bindings to AT (host based commands), Open AT ADL (Application Development Layer - embedded APIs) and TCP/IP features enable M2M developers to enhance connectivity over any bearer. Other powerful features of the porting include multithreading, as well as advanced string processing and data structures handling.
The close binding between Lua and C/C++ user code is of particular benefit to developers using Sierra Wireless' Lua plug-in for the Open AT platform. This is attributable to the carefully designed pseudo-stack API through which both languages communicate. From C/C++, it is easy to push or pop values from the stack using a single command. From Lua, any C/C++ function communicating through this pseudo-stack can be used; other functions can very easily be made accessible through wrapper functions, either written manually or generated with automated tools.
Further powerful attributes for M2M developers include improved remote-device management, such as inspecting and updating Lua functions on the fly without rebooting. Modifications can be tested safely in RAM before committing to Flash with a simple call to save ():. Other functions that are prohibitive in C/C++, such as adjustment of configuration settings using tables, are also easy and economical in terms of resources.
This environment delivers the benefits of a fast, easily embedded language engine with a small footprint, which supports rapid, web-based debugging. M2M developers can build and tune applications live in front of customers. Persuasive demonstrations of cost-effective M2M solutions that deliver real-time performance in complex, distributed applications are possible.
Enter XX at www.engineerlive.com/eee
Fabien Fleutot is senior developer, Sierra Wireless (formerly Wavecom), Issy-les-Moulineaux, France. www.wavecom.com