Thread: iLiad Battery status
View Single Post
Old 10-06-2009, 04:59 AM   #3
Iņigo
Guru
Iņigo did not drink the Kool Aid.Iņigo did not drink the Kool Aid.Iņigo did not drink the Kool Aid.Iņigo did not drink the Kool Aid.Iņigo did not drink the Kool Aid.Iņigo did not drink the Kool Aid.Iņigo did not drink the Kool Aid.Iņigo did not drink the Kool Aid.Iņigo did not drink the Kool Aid.Iņigo did not drink the Kool Aid.Iņigo did not drink the Kool Aid.
 
Posts: 730
Karma: 72743
Join Date: Feb 2008
Location: Here or there
Device: iRex iLiad, iRex DR800S. K4NT. Kobo Aura, Aura One, Libra 2.
Quote:
Originally Posted by hansel View Post
Ioctl() is no simple to handle in a generic way: the parameters are often pointers to structs. But Perl, Python, and Python do it, so.....

It's not difficult to write functions in C, and to make a Lua module with it. I did that with liberdm once, to play with the screen refresh functions. We could make a Lua module with handy Iliad functions. After that you could use them in a Lua script. Of course this is not very handy for experimenting. Directly scripting in Lua would be much cooler.

Edit: There is a Lua module to pack / unpack C-structs exists: http://www.inf.puc-rio.br/~roberto/struct/
Edit: I asked on the Lua list... Alien (http://alien.luaforge.net/) might be a way to implement things like ioctl(). It requires libffi (which is not present on the Iliad, but is a cool thing to have). I'll have a look at this when I have some more spare time...
I've read your message to lua mailing list this morning. I also searched but didn't find anything useful either.

I'm for the module for useful functions. We don't need a fully operational ioctl, only those handy functions exported to lua world. F.e. pm_getBatteryStatus, hw_detectMMC, and so on.
This extension module should be included with iliad-lua package, so any lua developer could use it.

In fact my bat.py code was to drive us to this discussion

So, which other functions are interesting to be wrapped?

Iņigo

PS: if I underestand correctly, lua alien/FFI module is like ctypes in python, a way to call functions present in any dynamic library of the OS. Ok, it could be quite useful.
Iņigo is offline   Reply With Quote