Saturday, April 14, 2012

Counter Point (Bluegiga BLE112: A Game Changer?)

After writing the last blog entry, a thought kept re-occurring: "Mission Accomplished."  You may have immediately caught on to the reference: President Bush's 2003 Mission Accomplished speech.

I certainly don't want to trivialize the aftermath of that speech (are we really done yet?), but  it does remind me of the faith we (the software community) place in abstractions and generalizations.

A scripting language onboard the BLE112 and so it will only take a few lines of code to do my sensors?  Sounds great.  But, there are no reports from the ground yet.  Is the scripting language stable? Are there bugs hidden in the implementation?  Are there subtle things that it does automatically that will bite me in the ass?

The same questions can be asked about Embedded Erlang. It sounds fantastic, and of course the first major Erlang deployment was indeed embedded (the AXD301 switch). But a lot has been added to Erlang and OTP since then. Is all of it good? Is all of it stable and proven?

This is not a criticism of BLE112 scripting or Erlang, but a reminder of why I went "low level" 6 years ago in the first place: The abstractions and libraries were killing me.

A thought: My Roku locks up every couple of months.  I have to hard reboot it.  I am guessing that it isn't a hardware problem nor a problem with the OS (linux?). Somewhere an app is failing.  My home sensor system can't do this. It must work 24/7 for as long as it is powered.

While Erlang has a great approach to fault tolerance, it is not the complete answer. You must intelligently use it's recovery features and you must avoid software faults to begin with.

"Not invented here" is preached against, but if you can't trust the provided tools, what do you do?

I'll have to see if Bluegiga's scripting is solid. But, what do I do if the sensors start silently failing weeks (or months) after deployment. How do I debug it?

In order to get my Erlang base station up and running I will need my Erlang code to interface with a serial port. There is no support in Erlang to do this.  I was going to write one (or use "netcat") to create a TCP bridge for the serial port and let Erlang talk to it. Will this eventually introduce subtle problems? How do I manage the bridge?  The Erlang approach says to expect that the bridge will fail and simply restart it (and resync the rest of the processes with it).  This is a smart approach, but with the "bridge" I have left the Erlang eco-system.

All of these issues nag me, and they should.  On the one hand, I think that the embedded world (mostly hardware types writing assembly, C and maybe C++)  is way behind the "high level programming" world in providing flexibility.  But with that flexibility, software folks have brought with them all of the little devils that come with high level programming.

Food for thought.


3 comments:

Ulf Wiger said...

You are absolutely right in that the low-level robustness requires careful thought. Even with the best of tools, there is no free lunch. :)

Yes, a lot has been added to Erlang, but all this time, Erlang has been running in commercial non-stop embedded systems, so the parts critical to robustness are managed with great care.

There is an embryo to a nice serial port library from us at Feuerlabs at http://github.com/tonyrog/uart - it is lacking documentation, but works pretty well on unix derivatives. The ambition is that it should also work well on Windows, but overlapped IO on Windows takes a little longer to get right.

You can check out the test module at https://github.com/tonyrog/uart/blob/master/src/uart_test.erl for some ideas on how to use the serial driver.

We will be posting reports of our progress at http://feuerlabs.com, and we hope to be able to address most of your concerns over time.

Todd Coram said...

Excellent. Tony's uart code is just what I am looking for.

Feuerlabs looks interesting. I'll be keeping an eye on the blog.

Thanks

Anonymous said...

Doing serious application development using BGScript. Issues and bugs hinder completion, and surprise 2k code limit limits usefulness considerably. Bluegiga offers platitudes and apologies........ but no quick resolution!