Register Guidelines E-Books Search Today's Posts Mark Forums Read

Go Back   MobileRead Forums > E-Book Readers > More E-Book Readers > iRex > iRex Developer's Corner

Notices

Reply
 
Thread Tools Search this Thread
Old 11-17-2009, 01:23 AM   #121
ericshliao
Guru
ericshliao will become famous soon enoughericshliao will become famous soon enoughericshliao will become famous soon enoughericshliao will become famous soon enoughericshliao will become famous soon enoughericshliao will become famous soon enough
 
Posts: 973
Karma: 687
Join Date: Nov 2007
Device: Dell X51v; iLiad v2
I have one question: why the loading time of C apps (without modifying registry.xml) much longer than Lua?

I found one weird problem. My C apps, if not integrated into registry.xml, will take much long loading time (may over one minute), and LED will keep flashing if not manually stopped. Lua script, even without modifying registry.xml, it only takes about ten seconds to load, and LED won't flash. Why the difference? Any ideas?
ericshliao is offline   Reply With Quote
Old 11-17-2009, 02:58 AM   #122
hansel
JSR FFD2
hansel can extract oil from cheesehansel can extract oil from cheesehansel can extract oil from cheesehansel can extract oil from cheesehansel can extract oil from cheesehansel can extract oil from cheesehansel can extract oil from cheesehansel can extract oil from cheese
 
hansel's Avatar
 
Posts: 305
Karma: 1045
Join Date: Aug 2008
Location: Rotterdam, Netherlands, Europe, Sol 3
Device: iliad
Quote:
Originally Posted by ericshliao View Post
I have one question: why the loading time of C apps (without modifying registry.xml) much longer than Lua?
Lua is not only cool, it's also fast

Seriously, it must be something in the way your app is coded. I did a small C gtk app once, it started in 7-8 seconds.

Some ideas and guesses:
  • Do you use xx in both cases? xx turns the led off when started...
  • If your app has items with a cursor: disable cursor blinking! With xedpmgr or xx this causes many display updates (eats a lot of cpu ( and battery)). This is handled automatically in the lgob-iliad package for GtkEntry an GtkTextview. The code is:

    Code:
      // ptr is a pointer to a   GtkEntry an GtkTextview  
            GtkSettings* settings = gtk_widget_get_settings(ptr);
            g_object_set(settings, "gtk-cursor-blink", (int)FALSE, NULL);

PS: xx has an option to delay the display refreshing: when you do 'myapp | xx -p -s6 ' , the refreshings starts after 6 seconds, possibly avoiding some needless refreshes while myapp is starting...

Last edited by hansel; 11-17-2009 at 03:00 AM. Reason: typos
hansel is offline   Reply With Quote
 
Enthusiast
Old 11-17-2009, 03:32 AM   #123
ericshliao
Guru
ericshliao will become famous soon enoughericshliao will become famous soon enoughericshliao will become famous soon enoughericshliao will become famous soon enoughericshliao will become famous soon enoughericshliao will become famous soon enough
 
Posts: 973
Karma: 687
Join Date: Nov 2007
Device: Dell X51v; iLiad v2
Thanx for the detailed instructions.
1. As to the flashing LED, I can imagine that xx suppresses LED. I also remember that xepdmgr has the similiar code. Maybe my memory serves me wrong.
2. I will try to disable cursor blinking later. To make the problem more clear, I have an example. When I port FBReader to iLiad, if I modify registry.xml to integrate FBReader, FBReader can be launched in about 30 seconds. If registry.xml not modified, it takes about two minutes or longer for FBReader to launch.

Last edited by ericshliao; 11-17-2009 at 04:23 AM.
ericshliao is offline   Reply With Quote
Old 11-17-2009, 08:07 AM   #124
hansel
JSR FFD2
hansel can extract oil from cheesehansel can extract oil from cheesehansel can extract oil from cheesehansel can extract oil from cheesehansel can extract oil from cheesehansel can extract oil from cheesehansel can extract oil from cheesehansel can extract oil from cheese
 
hansel's Avatar
 
Posts: 305
Karma: 1045
Join Date: Aug 2008
Location: Rotterdam, Netherlands, Europe, Sol 3
Device: iliad
Some (educated ) guesses... During a 'normal start', contentlister starts a shell to run a script (run.sh), which starts your app. When using the registry, contentlister does a fork(), followed by an execvp() of your application (no shell involved). With execvp() lots of process resources (such as open files) are kept open. It could be (not sure about this) that shared libraries are still attached to the process causing the new excutable to load (= dynamic linking) faster.
EDIT 18 nov: this is probably not correct?

PS: This gives me a cool idea: if I add the Lua interpreter to contentlister (I've been planning this for a long time), and 'preload' lgob (including the gtk libs, which is already available in contenlister), then it should be possible to start Lua apps and tools very quickly...

A Lua enabled contentlister would also be much easier to modify / extend...

Last edited by hansel; 11-18-2009 at 04:23 AM.
hansel is offline   Reply With Quote
Old 11-17-2009, 02:26 PM   #125
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: 711
Karma: 72743
Join Date: Feb 2008
Location: Here or there
Device: iRex iLiad, in love with iRex DR800S. Also a K4NT. Now a Kobo Aura
Quote:
Originally Posted by hansel View Post
PS: This gives me a cool idea: if I add the Lua interpreter to contentlister (I've been planning this for a long time), and 'preload' lgob (including the gtk libs, which is already available in contenlister), then it should be possible to start Lua apps and tools very quickly...

A Lua enabled contentlister would also be much easier to modify / extend...
I'm designing / thinking on a new content lister from some time ago.
First I'm going to release a simple file manager (Fedora 12 has been announced today so it won't be as soon as I thought ).

I have lot of ideas but as I would use some of the features I'm testing in this file manager I prefer waiting for your comments.

Btw, a Lua question:
I have some options in the file "program.ini" (f.e. "OPTION1 = true\nOPTION2 = false ..."). Is there a simple way to read this file using "loadfile" or similar and get a table with those options without parsing the file line by line
=> opts = { OPTIONS1 = true, OPTIONS2 = false, ... }, opts been a table defined in _G from the calling code?

Iņigo
Iņigo is offline   Reply With Quote
Old 11-17-2009, 10:39 PM   #126
ericshliao
Guru
ericshliao will become famous soon enoughericshliao will become famous soon enoughericshliao will become famous soon enoughericshliao will become famous soon enoughericshliao will become famous soon enoughericshliao will become famous soon enough
 
Posts: 973
Karma: 687
Join Date: Nov 2007
Device: Dell X51v; iLiad v2
Quote:
Originally Posted by Iņigo View Post
Btw, a Lua question:
I have some options in the file "program.ini" (f.e. "OPTION1 = true\nOPTION2 = false ..."). Is there a simple way to read this file using "loadfile" or similar and get a table with those options without parsing the file line by line
=> opts = { OPTIONS1 = true, OPTIONS2 = false, ... }, opts been a table defined in _G from the calling code?

Iņigo
Glib privodes a "Key-value file parser". See here: http://library.gnome.org/devel/glib/...le-parser.html
ericshliao is offline   Reply With Quote
Old 11-18-2009, 04:41 AM   #127
hansel
JSR FFD2
hansel can extract oil from cheesehansel can extract oil from cheesehansel can extract oil from cheesehansel can extract oil from cheesehansel can extract oil from cheesehansel can extract oil from cheesehansel can extract oil from cheesehansel can extract oil from cheese
 
hansel's Avatar
 
Posts: 305
Karma: 1045
Join Date: Aug 2008
Location: Rotterdam, Netherlands, Europe, Sol 3
Device: iliad
Quote:
Originally Posted by ericshliao View Post
Glib privodes a "Key-value file parser". See here: http://library.gnome.org/devel/glib/...le-parser.html
Those are cool functions, but they are not in Lgob (yet)

Personally I prefer to store settings in xml file (that's what always do at work). If you choose to store values in attributs (not in tags) (like <Opts option1='true' option2='false'/>), then converting Lua (nested) hashes to and from xml is quite simple...

Last edited by hansel; 11-18-2009 at 04:47 AM.
hansel is offline   Reply With Quote
Old 11-20-2009, 11:21 AM   #128
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: 711
Karma: 72743
Join Date: Feb 2008
Location: Here or there
Device: iRex iLiad, in love with iRex DR800S. Also a K4NT. Now a Kobo Aura
Excuse me for the silence, too much work these days...

Quote:
Originally Posted by hansel View Post
Those are cool functions, but they are not in Lgob (yet)

Personally I prefer to store settings in xml file (that's what always do at work). If you choose to store values in attributs (not in tags) (like <Opts option1='true' option2='false'/>), then converting Lua (nested) hashes to and from xml is quite simple...
Well, I don't like XML so much, I usually prefer simpler solutions, like =pair values or JSON.

For the record, here you have the code I'm finally using:

Code:
local buf = "OPT1 = 1,OPT2 = 2"
local txt = "{\n"
for k, v in buf:gfind("([^%s]+)%s*=%s*([^\n]+)") do txt = txt .. k .. " = " .. v .. ",\n" end
txt = txt:sub(1, -3) .. "\n}"
print(txt)
print("***************************************************************************")
r = assert(loadstring("return " .. txt))
pr(r())
A simple loadstring should also work, but I prefer this implementation in order to catch malformed configuration file.
Iņigo is offline   Reply With Quote
Old 11-21-2009, 06:23 AM   #129
hansel
JSR FFD2
hansel can extract oil from cheesehansel can extract oil from cheesehansel can extract oil from cheesehansel can extract oil from cheesehansel can extract oil from cheesehansel can extract oil from cheesehansel can extract oil from cheesehansel can extract oil from cheese
 
hansel's Avatar
 
Posts: 305
Karma: 1045
Join Date: Aug 2008
Location: Rotterdam, Netherlands, Europe, Sol 3
Device: iliad
Quote:
Originally Posted by Iņigo View Post
Well, I don't like XML so much, I usually prefer simpler solutions, like =pair values or JSON.
I agree that JSON is 'nicer' than XML (easier to read and edit for humans). But apart from the syntax JSON and XML are almost the same thing (for configuration purpose). Both JSON and XML are much more powerful than plain ini files because the allow you to store structured data.

There are JSON implementations for Lua, like http://json.luaforge.net/ (I did not try it)
hansel is offline   Reply With Quote
Reply

Tags
gtk+, iliad, lgob, lua, networking, xml

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Pandigital announce the black Novel Nate the great News 0 08-18-2010 05:21 PM
iLiad China iLiad users can get developer package. ericshliao iRex Developer's Corner 35 03-20-2010 05:21 AM
iLiad Announce: Glade4Lua, develop graphical apps for the Iliad hansel iRex Developer's Corner 1 10-27-2009 05:00 PM
Sony to announce colour e-book ? markiehill News 11 08-22-2009 12:45 PM
Proud to announce our new moderator! Alexander Turcic Announcements 5 12-08-2003 11:18 PM


All times are GMT -4. The time now is 03:14 PM.


MobileRead.com is a privately owned, operated and funded community.