Author Topic: Lua-based alternative to Ruby and Generic Serial Device  (Read 15239 times)

aaron.b

  • Regular Poster
  • **
  • Posts: 35
    • View Profile
Lua-based alternative to Ruby and Generic Serial Device
« on: May 28, 2008, 01:48:58 am »
Control of basic serial devices, like tv's and receiver's with rs232 ports, is done with generic serial device, which uses embedded ruby.

We're working now on a port of LinuxMCE that will provide basic home automation control and a/v control on a very cheap platform (think $50 access point with 4mb ram).  We're running into a problem with GSD, though.  Ruby is just too big and heavy.  99% of the gsd devices don't need the power that Ruby offers.  All they do is string parsing and formatting.  For example, the 'set volume' command takes an int from 0-100, but a Yamaha receiver wants the volume as a hex value from 0x00-0xff.  So, for the yamaha receiver, all we use Ruby for is basic math (i*2.55) and formating (decimal to hex), and calculating a checksum, which is the string sent to the receiver.  All the serial port control is done in the C-code of GSD; the Ruby engine is just used as a built in script engine for basic string manipulation.

There are some really sophisticated GSD based devices that use a lot of Ruby; like the EIB.  But, for the really basic control of simple serial devices, I'm thinking it would be nice to allow use of a lighter weight scripting language to do the string parsing.  That way, those devices could run on very lightweight platforms.

Does anybody have any comments on this?  Anybody with experience with Lua, or perhaps who could propose alternative languages that might do what we want?  I thought about embedding PERL, but it seems to be heavy, like Ruby.  We could just do basic bash calls, however, bash doesn't really have a C-language interface afaik that would allow the C-language DCE device to easily call functions in bash and get return values.

Comments?

rnmixon

  • Regular Poster
  • **
  • Posts: 35
    • View Profile
Re: Lua-based alternative to Ruby and Generic Serial Device
« Reply #1 on: May 28, 2008, 09:47:53 am »
I've just started using LUA for Netstreams DigiLinX RS232 drivers - integrating various home automation components. Its not too bad and seems to perform well on very modest hardware.

I groaned at first, because it was new and not as familiar as Ruby or C - but its pretty easy to learn. I don't think I would want to write really large systems in it, but for this type of work it should do fine.
Core/hybrid: Antec Fusion case, Asus M2NPV-VM motherboard, AMD 64 x2 4400,  1GB RAM, Global Cache GC100, Streamzap remote, ZCU000 ZWave, Hauppage PVR-500 to cable box, HDHomeRun to two HD antenna's in Scottsdale, AZ; Akai PT50DL14 50" DLP, Global Cache

ddamron

  • Alumni
  • wants to work for LinuxMCE
  • *
  • Posts: 962
    • View Profile
    • My LinuxMCE User Page
Re: Lua-based alternative to Ruby and Generic Serial Device
« Reply #2 on: May 28, 2008, 12:45:25 pm »
Aaron,

I really like the power of the Ruby in the current system... however, I do recognise your predicament.

My drivers are all in Ruby, so I'd have to rewrite them in LUA... and learn LUA...

I may end up learning C++ first though :)

In the End, as long as there is a good scripting language, I don't really care what it is... The only benefit of ERb is that there's a lot of support already written for it.

HTH,

Dan Damron
The only intuitive interface is the nipple.  After that it's all learned.
My other computer is your windows box.
I'm out of my mind.  Back in 5 minutes.
Q:  What's Red and smells like blue paint?

A:  Red Paint.

aaron.b

  • Regular Poster
  • **
  • Posts: 35
    • View Profile
Re: Lua-based alternative to Ruby and Generic Serial Device
« Reply #3 on: May 28, 2008, 08:07:12 pm »
>> I'd have to rewrite them in LUA... and learn LUA...

For right now we're not really looking to run your 'powerful' gsd devices on a low-power box like that.  It's really just for the basic control of TV's and Receivers.  These are all really simple things that take only about 1 hour to do in GSD anyway, and normally the GSD code is nothing more than: <$"POWER_ON"$> type of stuff.

abooreal

  • Newbie
  • *
  • Posts: 9
    • View Profile
Re: Lua-based alternative to Ruby and Generic Serial Device
« Reply #4 on: May 29, 2008, 05:25:36 am »
Lua is a very good idea!!! 1 vote from me.
I played around with it in my WOW (World Of Warcraft) days and I really enjoyed it.

The WOW GUI is done in LUA. Blizzard used a XML file to layout the GUI components, then LUA to implement the functions.

This would be a very nice feature to have on linuxMCE, the LUA Orbiter layout tool~~  ;)

I am no expert of lua, and I don't really know Ruby, so I guess I will list the features of LUA I know and someone can further comment on that...
  • The LUA engine is very light
  • Very smooth gateway with C/C++
  • Easy to learn
  • somewhat mature with lots of libs.

These are just my opinions based on my experience with lua, please feel free to correct me.

Here is a link of the world of warcraft GUI tutorial... (basically lua + xml) If anyone's interested.
http://fara.webeddie.com/frames/

Zaerc

  • Alumni
  • LinuxMCE God
  • *
  • Posts: 2256
  • Department of Redundancy Department.
    • View Profile
Re: Lua-based alternative to Ruby and Generic Serial Device
« Reply #5 on: May 29, 2008, 11:39:05 am »
So why not just use a "real" language like java?  It should be available on most embedded platforms already anyway.
"Change is inevitable. Progress is optional."
-- Anonymous


rnmixon

  • Regular Poster
  • **
  • Posts: 35
    • View Profile
Re: Lua-based alternative to Ruby and Generic Serial Device
« Reply #6 on: May 29, 2008, 06:18:44 pm »
Yes, I would prefer Java too, and it is getting pretty widely available on some pretty small devices.

But my impression is that the LUA implementations are much lighter, and they are more easily available/ported.

Maybe Aaron can provide some more facts instead of my "impressions".
Core/hybrid: Antec Fusion case, Asus M2NPV-VM motherboard, AMD 64 x2 4400,  1GB RAM, Global Cache GC100, Streamzap remote, ZCU000 ZWave, Hauppage PVR-500 to cable box, HDHomeRun to two HD antenna's in Scottsdale, AZ; Akai PT50DL14 50" DLP, Global Cache

darrenmason

  • Addicted
  • *
  • Posts: 529
    • View Profile
Re: Lua-based alternative to Ruby and Generic Serial Device
« Reply #7 on: May 30, 2008, 04:30:43 am »
I had a look at Lua after reading this post and I think it seems very well suited for the task that you mentioned.
It is small and embeddable and can make use of existing libraries relatively easily (with many language bindings).

For something that is going to do minimal computational work then most developers will pick it up easily as long as there are a few examples that exist.

Aaron, if you are looking at a small embedded box will this also be able to display an orbiter? If so, have you managed to reduce the footprint for this? Or is it purely a control box?

eloy

  • Regular Poster
  • **
  • Posts: 19
    • View Profile
Re: Lua-based alternative to Ruby and Generic Serial Device
« Reply #8 on: May 30, 2008, 07:35:14 pm »
No mention of Lua is complete without a mention of Tcl ;-)

What are people's thoughts on Tcl? It's also highly embedable and light. I like Tcl but I am biased because I've written an application (www.netexpect.org) that embeds Tcl. It certainly has been around longer than Lua, although not sure that is any kind of good indication.

Blackhat

  • Regular Poster
  • **
  • Posts: 28
    • View Profile
Re: Lua-based alternative to Ruby and Generic Serial Device
« Reply #9 on: June 02, 2008, 07:11:56 pm »
I tend to lean towards Dan's opinion.  If speed is key then might as well switch over to a compiled language.  Personally, that would mean C++ for me, but to each their own.

rnmixon

  • Regular Poster
  • **
  • Posts: 35
    • View Profile
Re: Lua-based alternative to Ruby and Generic Serial Device
« Reply #10 on: June 02, 2008, 07:33:43 pm »
I hear you - a compiled language would definitely be faster and smaller. But C++ and similar are just beyond many of the folks that need to do the interfacing (if I'm reading Aaron's intent correctly). Think folks like home automation installers for Crestron, Netstreams, etc - which is probably Pluto's competition. They often have the odd piece of equipment - a pool controller, or whatever that needs to interface to the system. Most do not have enough background in software development and will find it hard to justify the time to learn - but they can learn to do simple LUA (or whatever) scripts.

LUA or a similar language is really just a "glue" language that you do your high-level control in, checking for button presses, string inputs on the serial port, etc. The underlying C routines do all of the intensive work. Sometimes the drivers only need to be a couple dozen lines long - sometimes they can get quite a bit longer.

No reason you cannot ultimately have both if the market (us :) demand is enough.
Core/hybrid: Antec Fusion case, Asus M2NPV-VM motherboard, AMD 64 x2 4400,  1GB RAM, Global Cache GC100, Streamzap remote, ZCU000 ZWave, Hauppage PVR-500 to cable box, HDHomeRun to two HD antenna's in Scottsdale, AZ; Akai PT50DL14 50" DLP, Global Cache

nite_man

  • NEEDS to work for LinuxMCE
  • ***
  • Posts: 1019
  • Want to work with LinuxMCE
    • View Profile
    • Smart Home Blog
Re: Lua-based alternative to Ruby and Generic Serial Device
« Reply #11 on: June 03, 2008, 09:15:23 am »
Agree with rnmixon. C++ is fast but how much time should spend somebody who doesn't know it? I never used Ruby when I started to develop an interface between Plutohome and custom controller. Draft version was ready after a few hours of work. You won't have similar result with C++. It should be two ways to implement a new device in LinuxMCE - one which works faster and another which can be done faster. If Lua will be chosen it'll ok. Just read its manual will be enough to start work with it.
Michael Stepanov,
My setup: http://wiki.linuxmce.org/index.php/User:Nite_man#New_setup
Russian LinuxMCE community: http://linuxmce.ru