OIP an Electrical Engineer's OSS Dream
A couple of weeks ago, we looked mostly at programs coded in Python and hosted in systems small enough to fit in gadgets like cellular handsets, networking appliances, and other such products. Several Tcl projects illustrate a different role for Linux, one of which marries a conventional personal computer with add-on special-purpose hardware.
Let's be clear about the different concepts and architectures involved here: our previous column focused on embedded Linux hosted on small but capable systems. It's entirely feasible now to run Linux on hardware that fits in a cellular handset or smaller, mounted on a board that costs $100, or possibly much less. Such a flavor of Linux can easily run Python, as the examples from earlier in the month showed, or any of the other high-level languages such as Lua, Tcl, or REBOL, that demand little memory: a megabyte or ten, rather than the twenty or hundred megabytes of a conventional Java installation, for instance.
Alternative Architectures
A more traditional way to wire Linux to the real world marries a conventional Linux host to a small dedicated processor running a special-purpose application. Commercial developer Syscomp Electronic Design Ltd. illustrates how impressive such teamwork can be. As its lead marketing slogan has it, "CircuitGear is an Electronics Lab in Your Pocket." In this case, CircuitGear is a small, special-purpose instrumentation module which implements an oscilloscope, function generators, and other tools, connected to USB ports communicating to a standard desktop or laptop computer.
Part of what makes Syscomp interesting is that the software it provides for CircuitGear and its other products makes up the Open Instrumentation Project. In plain and nearly-accurate language, Syscomp sells its clever hardware, and gives away its equally clever software. The hardware is generally typical of embedded projects: inexpensive dedicated eight-bit chipsets. To get the most of the hardware's capabilities, though, Syscomp has developed portable host-based programs which can run on Linux, among other operating systems. Although programmed in Tcl rather than C or assembler, these applications perform adequately even on 200-MHz Pentiums from a decade go.
This matches several of our own experiences: Tcl is plenty fast enough for even moderately demanding process-control or instrumentation applications. Naive benchmarks of Tcl and other high-level languages like Perl, Python, and so on can yield speeds that are only a tenth or a hundredth or even a those of comparable C or assembler fragments; Fractal is a concrete instance of such benchmarks. In practice, though, the useful programs our company Phaseit delivers are adequately fast even for soft real-time programming. I/O, report generation, and graphical rendering dominate processing time in many of our applications, and the optimized libraries of languages like Perl and Tcl compete quite nicely with "hand-coded" C in these instances. Tcl is "in production" in this architecture--a Tcl-coded control program hosted on a general-purpose operating system, connected to special-purpose hardware--on oil production platforms, in medical systems, in transportation systems, in factories, in telecomm installations, and many others, even beyond the bounds of Earth. It's a challenge to detail their engineering, because in a majority of the cases we know, the vendors involved don't disclose their choice of a high-level language to develop these mission-critical systems.
A few public models for this sort of programming exist, though. Usman Muzaffar recently wrote up his experience wiring RFID readers and a conveyor belt together with a little Tcl. Why Tcl? His answer: it's a language that is "available everywhere, great UI tool kit, [and with] easy event handling..." That last is crucial: a particular strength of Tcl is its event-based model for multiprocessing, an approach that simplifies development in many situations when compared to what use of threads entails.
The principals at iCanProgram Inc. hint at more of this power in their recently-released book Programming the SIMPL Way. SIMPL (Synchronous Interprocess Messaging Project for Linux) is a decade-old open-source project in Tcl and Python, which originated in real-time control projects. While the book concentrates almost exclusively on programming aspects, the library it presents has a record of success and refinement in data acquisition, point-of-sale automation, embedded security, and other "real world" applications.
Be careful, by the way, not to confuse this SIMPL with several others. While most of them are easy to distinguish (Simpl the rock band, for instance), one is a commercial Windows-oriented programming language for control systems.
More Linux and More High-Level than Vendors Know
One final caution if you work in this area: don't believe everything vendors say. Syscomp distinguishes itself not only for the attention-getting value its kits and products provide, but for its software sophistication. Syscomp manuals are clear and accurate even when describing software. Across the range of vendors who sell in this market, though, documentation generally lags far behind engineering: the best vendors for radio and robotics products, among others in our experience, have manual and specification sheets that are often simply wrong in their software aspects.
One characteristic error they make is not to understand the capabilities of Linux. We've repeatedly encountered cases where an interesting device worked with Linux although its vendor documents that it's only compatible with Windows, or does not work under Linux, although the vendor claims it does. Each time, as best we could tell, it's been an honest mistake, and not a willful attempt to deceive. These underscore, though, that work with products that connect outside computing systems demands alertness: you're likely to be "on your own" at least part of the way.
With these warnings in mind, though, Linux--and especially a high-level language like Tcl hosted on Linux--makes a great platform for development of systems that integrate hardware and software. Linux is reliable, flexible, and thrifty, and Tcl gives remarkable productivity with adequate performance, especially when focused on its original capabilities as a language for "gluing" together a broad span of components.
Kathryn and Cameron run their own consultancy, Phaseit, Inc., specializing in high-reliability and high-performance applications managed by high-level languages. They write about high-level languages and related topics in their "Regular Expressions" columns.

