View Full Version : Adding lua functions in plugins
curtiswren
February 24th, 2005, 07:02 PM
I'm trying to port the powerlinc usb plugin to Girder4. I used to add the lua functions in the gir_open function. When I try to do this now, the LuaState member is null. Is this not the correct place to do this anymore?
Ron
February 24th, 2005, 08:03 PM
Yeah, we changed the Lua loading order. Here is why:
Sometimes when you have a garbage collection routine assigned to your metadata Lua needs to shutdown before the plugin shutsdown. In Girder 3.3 this actually would crash Girder if you used Garbage collection. (The GC would be called after your plugin is unloaded.... havoc). So we changed the loading order.
You now have 2 new defines in the Girder header called:
GIRINFO_SCRIPT_AFTER_STARTED
GIRINFO_SCRIPT_BEFORE_STOPPED
These are passed to the gir_info function. When the first message comes simply register your functions. Usually you don't have to do anything before Lua is unloaded, but if you need to you can on the second message. The Lua state is passed in the lParam. You don't need to aquire the mutex during this process, Girder already holds it for the duration of the call to your plugin.
Ron
February 24th, 2005, 08:04 PM
int WINAPI gir_info(int message, int wparam, int lparam)
{
switch ( message )
{
case GIRINFO_SCRIPT_STATE_ASYM:
L = ( lua_State * ) lparam;
lua_iplibopen(L);
break;
case GIRINFO_BEFORE_SCRIPT_STATE_ASYM:
L = ( lua_State * ) lparam;
lua_iplibclose(L);
break;
}
return GIR_TRUE;
}
curtiswren
February 24th, 2005, 08:35 PM
Thanks, that works great. Another question. It looks like the plugin id that I used for 3.2 (153) is now being used for the Lua Windows Function Library. Do I need to get another id?
Thanks,
Curt
Ron
February 24th, 2005, 08:40 PM
Did we steal your ID? That is no good.
Ron
February 24th, 2005, 08:43 PM
No you keep your ID, we will recompile the Lua Windows Functions library.
quixote
February 28th, 2005, 08:09 AM
Curtis - on a slightly unrelated topic ( but still pertaining to LUA and plugins), Will you be recreating your XMLTV plugin for Girder 4? That would be super.
Also, I'd like to know a bit about the Powerlinc. I have a CM11a which is no longer supported for Girder 4 and I was wonder if the Powerlinc hears RF commands, if it works with all X10 components, and if it covers all house codes. Please PM me when you have a chance.
Thanks in advance.
curtiswren
February 28th, 2005, 04:28 PM
I will port the XMLTV plugin. It should be trivial. The powerlinc should be able to handle any X10 device that sends/receives signals over the power lines. Here's the web page http://www.smarthome.com/1132u.html. I don't think it handles RF commands though.
quixote
February 28th, 2005, 04:37 PM
The page you have requested has been moved or removed from our site. Please Click Here to return to the homepage if you are not automatically redirected. Thank you.
I'll search Smarthome. Is there a difference between powerlinc II and powerlinc USB?
I noticed that there is a powerlinc II sold with an RF attachment, but it is connected via serial cable. Is it compatible? Here is the page:
http://www.smarthome.com/4831K.HTML
curtiswren
February 28th, 2005, 05:08 PM
The serial powerlinc (I think powelince II is serial ) will not work with my plugin. There are 2 versions of the powerlinc USB, one standalone and one that requires a PC. Both work with the plugin.
Ron
February 28th, 2005, 05:09 PM
MarkF's serial plugin supports the powerlinc serial IIRC.
quixote
March 1st, 2005, 08:01 AM
Ok. Thanks for the info, guys. I'll consider throwing another couple hundred into my setup. If you wanted to have full X10 functionality, including RF commands and extended X10 commands such as the alarm system door magnet sensors, what would you go with?
I'm thinking that the most versatile way (but perhaps most complicated) would be to get a Powerlinc USB and a W800RF32A ( http://www.wgldesigns.com/w800.html ) and use them in conjunction. What do you think?
vBulletin® v3.7.4, Copyright ©2000-2009, Jelsoft Enterprises Ltd.