4

Does anyone have some cool ideas for a use of a scripting language on an embedded system? I'm thinking about the eLua project specifically.

Basically, you need a micro with at least 64k of RAM, 256k of Flash, the Newlib C library, and a gcc compiler, (AVR32, ARM7, Cortex-M3 are all supported right now among others), and you can send it (or program it to load) scripts. It doesn't need an OS, but it lets you use your micro (which is far too small for embedded Linux) much more like a general purpose computing device, by allowing programs not flashed into the program memory to be run.

The current project has a number of example applications, but none of them seem to do anything that you can't do with a program burned into Flash. The big difference that I can see is that you can send each program separately, and run different programs without resetting. In addition, you can use it interactively (Change your program flow with your decisions at the keyboard, rather than having to code everything.

How would you use such a device? Would you give it a keyboard and character LCD, and write your own scripts while it sat on your desk? Would you simply use the scripting language to simplify programming of more complex applications? (Like the games currently available on the project site?) Or would you do something completely different? I'm getting started with it and looking for project ideas.

Edit: You can send it programs over whatever protocol you want to use (UART, SPI/I2C etc., USB, Ethernet), load them from an SD card, whatever your chip supports. Just wanted to clarify that it didn't have to be in a reprogramming-friendly environment.

Edit2: Most of my projects are for my personal use, or for sharing with like-minded friends, not often for sale to the general public. I expect users of my projects to be interested in and familiar with embedded systems, and able to pick up the rudimentary use of a scripting language without too much trouble. I might use them around the house or in the car, or more likely in the shop as an aide to designing and debugging more new projects. I also might propose it to my boss at work, where we manufacture and design embedded systems. Or, I might use it on an engineering project for school.

flag
I would be interested if someone pointed out a scripting language for 8-bit and 16-bit chips like the megaAVR or PICs. – Rick_2047 Jun 19 at 8:19

2 Answers

4

I'm planning on embedding a scripting language in my little mom-find-me device (finally progressing again, hope to have a working prototype by the Detroit Maker Faire next month).

It's a little platform with GPS, compass, SD card, and zigbee that is meant to help my keep track of my younger kids at large parks, and to give them a way to easily find me when they need me.

The embedded scripting language will provide a protected sandbox where simple applications, such as games, maps, geocaching programs, or multiplayer games (several kids, each with a unit can play enhanced versions of capture the flag, hide and seek, tag, etc) without affecting the base function of being able to track my kids. These would go on the SD card as text files so they can easily be edited and updated with no special hardware or software.

There are lots of other ways and reasons to use a scripting language in embedded systems, but in order to see how or why it might fit into your needs we'd have to understand more about your particular system.

link|flag
That makes sense; Lua has sandboxing capabilities as well. However, what do you do if they enter "while true do --[[nothing]]-- end"? – reemrevnivek Jun 19 at 1:31
What language are you using? I'm not aware of many alternatives to eLua. – reemrevnivek Jun 19 at 1:31
1 
BTW, this is the kind of answer I'm looking for-I'm just going to wait a while longer for some more answers to filter in. – reemrevnivek Jun 19 at 1:48
@reemrevnivek - 1) I will be running them in an interrupt-able manner. I haven't decided whether that means I'll be running a full pre-emptive multitasking OS, or simply running all my "important" code on interrupt timers (the latter is relatively easy anyway), or some other solution. 2) Many scripting languages are embeddable. I asked this same question on SO a 18 months ago, and got lots of good answers: stackoverflow.com/questions/191222/… – Adam Davis Jun 19 at 13:41
6

I've looked into eLua and also an embedded python interpreter for some projects I'm working on in my day job. We're developing a base control system, but these systems go out and are customized extensively in the field. Rather than require the end use to add extra processing modules, we allow them to configure our system, and in some cases, write their own features. Since it is prohibitive to have end users reflash in the field (they could easily brick things), we provide a scripting interface.

Currently, we have a proprietary language that is compiled into bytecode and churned through in order by the kernel, but we are trying to make things more standards compliant and easier to maintain.

Here's a comparison of different interpreted languages that can run on 'bare metal': http://stackoverflow.com/questions/1082751/what-are-the-available-interactive-languages-that-run-in-tiny-memory

Generally, once the device has been flashed once in the factory, we don't want to have to reflash. It is slow, prone to errors, and difficult for end users. In order to extend functionality after production, some sort of scripting extension is a good solution.

link|flag

Your Answer

Not the answer you're looking for? Browse other questions tagged or ask your own question.