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

Go Back   MobileRead Forums > E-Book Readers > Amazon Kindle > Kindle Developer's Corner

Notices

Reply
 
Thread Tools Search this Thread
Old 05-19-2012, 04:52 PM   #1
silver18
THE NOOB
silver18 ought to be getting tired of karma fortunes by now.silver18 ought to be getting tired of karma fortunes by now.silver18 ought to be getting tired of karma fortunes by now.silver18 ought to be getting tired of karma fortunes by now.silver18 ought to be getting tired of karma fortunes by now.silver18 ought to be getting tired of karma fortunes by now.silver18 ought to be getting tired of karma fortunes by now.silver18 ought to be getting tired of karma fortunes by now.silver18 ought to be getting tired of karma fortunes by now.silver18 ought to be getting tired of karma fortunes by now.silver18 ought to be getting tired of karma fortunes by now.
 
silver18's Avatar
 
Posts: 701
Karma: 1545649
Join Date: Jan 2012
Location: Italy
Device: Kindle Touch 5.3.2
LIPC: how to set a custom event?

Good evening to all!!

I'm diving into the events send/receive system of our Kindle.
Is it possible to set a new event (let's call it "test"), bind to this event an action (run a custom script) and then send this event?

I know lipc-send-event works when sending an existing event, but how to set a new event?

Thanks to all!!
silver18 is offline   Reply With Quote
Old 05-19-2012, 05:23 PM   #2
eureka
but forgot what it's like
eureka ought to be getting tired of karma fortunes by now.eureka ought to be getting tired of karma fortunes by now.eureka ought to be getting tired of karma fortunes by now.eureka ought to be getting tired of karma fortunes by now.eureka ought to be getting tired of karma fortunes by now.eureka ought to be getting tired of karma fortunes by now.eureka ought to be getting tired of karma fortunes by now.eureka ought to be getting tired of karma fortunes by now.eureka ought to be getting tired of karma fortunes by now.eureka ought to be getting tired of karma fortunes by now.eureka ought to be getting tired of karma fortunes by now.
 
Posts: 741
Karma: 2345678
Join Date: Dec 2011
Location: north (by northwest)
Device: Kindle Touch
You should name the publisher subsystem (plain binary compiled program or Lua script or Java program or WAF application or something else) on top of which you want to set a new event handler. Or rather rephrase your question: "how to set a new publisher with custom event receiver with handling of custom event?".

If you'll build a new compiled program linked with liblipc.so and will use functions exported by this library, everything will be possible (with regard to implemented abilities of LIPC).

Last edited by eureka; 05-19-2012 at 06:07 PM. Reason: correcting false definitions
eureka is offline   Reply With Quote
Advert
Old 05-20-2012, 08:58 AM   #3
knc1
Going Viral
knc1 ought to be getting tired of karma fortunes by now.knc1 ought to be getting tired of karma fortunes by now.knc1 ought to be getting tired of karma fortunes by now.knc1 ought to be getting tired of karma fortunes by now.knc1 ought to be getting tired of karma fortunes by now.knc1 ought to be getting tired of karma fortunes by now.knc1 ought to be getting tired of karma fortunes by now.knc1 ought to be getting tired of karma fortunes by now.knc1 ought to be getting tired of karma fortunes by now.knc1 ought to be getting tired of karma fortunes by now.knc1 ought to be getting tired of karma fortunes by now.
 
knc1's Avatar
 
Posts: 17,212
Karma: 18210809
Join Date: Feb 2012
Location: Central Texas
Device: No K1, PW2, KV, KOA
Quote:
Originally Posted by eureka View Post
If you'll build a new compiled program linked with liblipc.so and will use functions exported by this library, everything will be possible (with regard to implemented abilities of LIPC).
That might not work, since lipc may be keeping its information in its process address space.
Your additions would have to be made within the lipc process address space.

But since this is a dynamically loaded library, that is possible.
-----
A few command examples to get you started.
Here, using a copy of my K3-3.2.1 system image mounted at /mnt/k321 but the principles remain the same.
Remember, "man(ual)" is your friend for details of these commands.

Locate the dynamic library(ies):
Code:
core2quad k321 $ find . -name 'liblipc*'
./usr/lib/liblipc.so
./usr/lib/liblipc.so.0
./usr/lib/liblipc.so.0.1
Find which are the links and which is the binary:
Code:
core2quad k321 $ cd ./usr/lib
core2quad lib $ ls -l liblipc.so*
lrwxrwxrwx 1 root root    14 2011-04-06 19:15 liblipc.so -> liblipc.so.0.1
lrwxrwxrwx 1 root root    14 2011-04-06 19:15 liblipc.so.0 -> liblipc.so.0.1
-rwxr-xr-x 1 root root 73326 2011-04-06 19:15 liblipc.so.0.1
When you want to link code against that library, the *.so is presumed and the "-l" in the compiler's link options is shorthand for "lib" so to specify this library: "-llipc".

Use one of the symbol listing tools to list the external entry points.
For detailed information, including disassembly, objdump is probably the tool of choice.

For a quick listing of the symbol names use nm without any options.
Get a list of the defined (external) symbols:
Code:
core2quad lib $ nm -g --defined-only liblipc.so.0.1
- - - -
00005ce8 T LipcRegisterHasharrayProperties
00005e88 T LipcRegisterHasharrayProperty
0000620c T LipcRegisterIntProperties
0000639c T LipcRegisterIntProperty
00005f80 T LipcRegisterStringProperties
00006110 T LipcRegisterStringProperty
- - - -
0000839c T LipcSetEventCallback
- - - -
00008420 T LipcSubscribe
- - - -
There are 93 of them in this copy of the library, the above ones may be of interest to this question.
Any or all of them might be of general interest, but this may be a starting point.

Next you will need the symbol's parameter list and return values.
Since this is a compiler generated object file, the entry and exit to the functions match known patterns, making this step much easier than it might be otherwise.
You could even get by using just objdump, although there are fancier tools for the purpose.

Note: In the USA, determining the user interface to a closed source binary is legal, your country might have different rules/laws.

Next question: "I know the symbol's entry and exit interface, how do I make use of that?"

Let us imagine that the user of this dynamic library is an executable named "lipc".
We can't (legally) disassemble, modify, re-assemble and distrbute a closed source executable.

This is a dynamically loaded library, so we don't have to.
You can write a "wedge" library layer that provides your changed entry points and use the LD_PRELOAD dynamic loader variable on executions of "lipc".
Instead of:
lipc <parms>
The execution would be:
LD_PRELOAD=my_wedge.so lipc <parms>
Which can be implemented by a simple (shell) wrapper around the original lipc.

Where my_wedge.so would provide the new and/or modified features and it would dlopen liblipc.so to provide all the other, existing, features.
The "lipc" executable would never know the difference.

For a complete worked example of how this is all done, study the "fakeroot" utility.
http://anonscm.debian.org/gitweb/?p=...oot.git;a=tree
http://alioth.debian.org/projects/fakeroot/

Note: There is also a way to do this using the PTRACE facility, see: fakeroot-ng

Last edited by knc1; 05-20-2012 at 10:08 AM.
knc1 is offline   Reply With Quote
Old 05-20-2012, 11:14 AM   #4
knc1
Going Viral
knc1 ought to be getting tired of karma fortunes by now.knc1 ought to be getting tired of karma fortunes by now.knc1 ought to be getting tired of karma fortunes by now.knc1 ought to be getting tired of karma fortunes by now.knc1 ought to be getting tired of karma fortunes by now.knc1 ought to be getting tired of karma fortunes by now.knc1 ought to be getting tired of karma fortunes by now.knc1 ought to be getting tired of karma fortunes by now.knc1 ought to be getting tired of karma fortunes by now.knc1 ought to be getting tired of karma fortunes by now.knc1 ought to be getting tired of karma fortunes by now.
 
knc1's Avatar
 
Posts: 17,212
Karma: 18210809
Join Date: Feb 2012
Location: Central Texas
Device: No K1, PW2, KV, KOA
Quote:
Originally Posted by silver18 View Post
Good evening to all!!

I'm diving into the events send/receive system of our Kindle.
Is it possible to set a new event (let's call it "test"), bind to this event an action (run a custom script) and then send this event?

I know lipc-send-event works when sending an existing event, but how to set a new event?

Thanks to all!!
On the k3-v3.2.1 firmware, see: /etc/lipc-daemon-events.conf

Code:
## This file defines what evetns are handled by lipc-daemon
## The format of the file is 
##<event name>   <event publisher>   <command to execute when event is received>
##
## NOTE: By default the event name and any parameters are passed to the script as arguments.  If you want to ignore the arguments,
## you must add a semi-colon (;) to the end of the script command.
##
usbConfigured     com.lab126.hal        echo "lock">/dev/null; echo "lock">/dev/null; echo "lock">/proc/accelerometer;
usbUnconfigured   com.lab126.hal        echo "unlock">/dev/null; echo "unlock">/dev/null; echo "unlock">/proc/accelerometer;
FrameworkStarted  com.lab126.framework  rm -f /var/local/system/.framework_retries /var/local/system/.framework_reboots
tzRequested       com.lab126.framework  settz
interfaceChange   com.lab126.cmd        /usr/sbin/updatetime & true
triggerTimeChange com.lab126.cmd        /usr/sbin/updatetime & true

## Uncomment the following line if you want to see when lipc-daemon received
## outOfScreenSaver event.  Useful for debugging out of suspend performance
#outOfScreenSaver    com.lab126.powerd  . /etc/rc.d/functions; msg "lipc-daemon got outOfScreenSaver at `date +%s`s" I; true;
And the file etc/lipc-daemon-props.conf
Code:
# This file defines what properties are exposed by lipc-daemon.
orientation r   cat /proc/accelerometer | xargs echo -n
usid r   cat /proc/usid | xargs echo -n
boardid r   cat /proc/boardid | xargs echo -n
version r   cat /etc/version.txt | xargs echo -n
waveformversion r cat /proc/eink_fb/waveform_version | xargs echo -n
date w   /usr/sbin/setdate
sendEvent w lipc-send-event com.lab126.system.event
Plus the supplied utilities:
Code:
/usr/bin/lipc-daemon
/usr/bin/lipc-get-prop
/usr/bin/lipc-hash-prop
/usr/bin/lipc-probe
/usr/bin/lipc-send-event
/usr/bin/lipc-set-prop
/usr/bin/lipc-wait-event
Which have usage screens.
knc1 is offline   Reply With Quote
Old 05-28-2012, 03:51 PM   #5
silver18
THE NOOB
silver18 ought to be getting tired of karma fortunes by now.silver18 ought to be getting tired of karma fortunes by now.silver18 ought to be getting tired of karma fortunes by now.silver18 ought to be getting tired of karma fortunes by now.silver18 ought to be getting tired of karma fortunes by now.silver18 ought to be getting tired of karma fortunes by now.silver18 ought to be getting tired of karma fortunes by now.silver18 ought to be getting tired of karma fortunes by now.silver18 ought to be getting tired of karma fortunes by now.silver18 ought to be getting tired of karma fortunes by now.silver18 ought to be getting tired of karma fortunes by now.
 
silver18's Avatar
 
Posts: 701
Karma: 1545649
Join Date: Jan 2012
Location: Italy
Device: Kindle Touch 5.3.2
Ok, I missed the reply! Sorry, I didn't mean to be not grateful!

Thanks a lot knc1!!! It seems I need to study really hard!

BTW, I'm having a problem related to lipc...
If I send this command:

Code:
/$ lipc-set-prop -- com.lab126.system takeScreenShot 1
to take a screenshot, I get this error:

Code:
com.lab126.system failed to set value for property takeScreenShot (0x3 lipcErrNoSuchSource)
And com.lab126.system is not listed in lipc-probe -l results (as it was before)....

Any clue?
silver18 is offline   Reply With Quote
Advert
Old 05-28-2012, 04:02 PM   #6
knc1
Going Viral
knc1 ought to be getting tired of karma fortunes by now.knc1 ought to be getting tired of karma fortunes by now.knc1 ought to be getting tired of karma fortunes by now.knc1 ought to be getting tired of karma fortunes by now.knc1 ought to be getting tired of karma fortunes by now.knc1 ought to be getting tired of karma fortunes by now.knc1 ought to be getting tired of karma fortunes by now.knc1 ought to be getting tired of karma fortunes by now.knc1 ought to be getting tired of karma fortunes by now.knc1 ought to be getting tired of karma fortunes by now.knc1 ought to be getting tired of karma fortunes by now.
 
knc1's Avatar
 
Posts: 17,212
Karma: 18210809
Join Date: Feb 2012
Location: Central Texas
Device: No K1, PW2, KV, KOA
Quote:
Originally Posted by silver18 View Post
Code:
/$
Any clue?
If a person can believe what they read...
Translation: If the $PS1 prompt is set according to customary *nix practice...

Then the '$' indicates you are running the command as an un-privledged user.
Try running the same command as 'root' ($PS1 will be set to '#').
It is reasonable to assume that you would have to be 'root' to change the system event message database.
knc1 is offline   Reply With Quote
Old 05-28-2012, 04:12 PM   #7
silver18
THE NOOB
silver18 ought to be getting tired of karma fortunes by now.silver18 ought to be getting tired of karma fortunes by now.silver18 ought to be getting tired of karma fortunes by now.silver18 ought to be getting tired of karma fortunes by now.silver18 ought to be getting tired of karma fortunes by now.silver18 ought to be getting tired of karma fortunes by now.silver18 ought to be getting tired of karma fortunes by now.silver18 ought to be getting tired of karma fortunes by now.silver18 ought to be getting tired of karma fortunes by now.silver18 ought to be getting tired of karma fortunes by now.silver18 ought to be getting tired of karma fortunes by now.
 
silver18's Avatar
 
Posts: 701
Karma: 1545649
Join Date: Jan 2012
Location: Italy
Device: Kindle Touch 5.3.2
Quote:
Originally Posted by knc1 View Post
If a person can believe what they read...
Translation: If the $PS1 prompt is set according to customary *nix practice...

Then the '$' indicates you are running the command as an un-privledged user.
Try running the same command as 'root' ($PS1 will be set to '#').
It is reasonable to assume that you would have to be 'root' to change the system event message database.
Well, that was the output of WinSCP...using Putty I get the #:

Code:
[root@kindle root]# lipc-set-prop -- com.lab126.system takeScreenShot 1
com.lab126.system failed to set value for property takeScreenShot (0x3 lipcErrNoSuchSource)
but I get also the error!

The point is, I didn't changed anything!
Moreover, I can't understand why com.lab126.system isn't listed in lipc-probe -l!
silver18 is offline   Reply With Quote
Old 05-28-2012, 04:52 PM   #8
eureka
but forgot what it's like
eureka ought to be getting tired of karma fortunes by now.eureka ought to be getting tired of karma fortunes by now.eureka ought to be getting tired of karma fortunes by now.eureka ought to be getting tired of karma fortunes by now.eureka ought to be getting tired of karma fortunes by now.eureka ought to be getting tired of karma fortunes by now.eureka ought to be getting tired of karma fortunes by now.eureka ought to be getting tired of karma fortunes by now.eureka ought to be getting tired of karma fortunes by now.eureka ought to be getting tired of karma fortunes by now.eureka ought to be getting tired of karma fortunes by now.
 
Posts: 741
Karma: 2345678
Join Date: Dec 2011
Location: north (by northwest)
Device: Kindle Touch
Quote:
Originally Posted by silver18 View Post
BTW, I'm having a problem related to lipc...
If I send this command:

Code:
/$ lipc-set-prop -- com.lab126.system takeScreenShot 1
to take a screenshot, I get this error:

Code:
com.lab126.system failed to set value for property takeScreenShot (0x3 lipcErrNoSuchSource)
And com.lab126.system is not listed in lipc-probe -l results (as it was before)....

Any clue?
lipc-daemon must be started.

If it isn't running, then output of status lipcd will be lipcd stop/waiting. If it's running, then output of status lipcd will be lipcd start/running, process NNN. To start it, execute: start lipcd
eureka is offline   Reply With Quote
Old 05-28-2012, 04:59 PM   #9
silver18
THE NOOB
silver18 ought to be getting tired of karma fortunes by now.silver18 ought to be getting tired of karma fortunes by now.silver18 ought to be getting tired of karma fortunes by now.silver18 ought to be getting tired of karma fortunes by now.silver18 ought to be getting tired of karma fortunes by now.silver18 ought to be getting tired of karma fortunes by now.silver18 ought to be getting tired of karma fortunes by now.silver18 ought to be getting tired of karma fortunes by now.silver18 ought to be getting tired of karma fortunes by now.silver18 ought to be getting tired of karma fortunes by now.silver18 ought to be getting tired of karma fortunes by now.
 
silver18's Avatar
 
Posts: 701
Karma: 1545649
Join Date: Jan 2012
Location: Italy
Device: Kindle Touch 5.3.2
To be true, it's the first time I see those commands (lipcd start/stop). I always ran the command to take a screenshot without any problem...
Anyway, first time I run lipcd status, I get lipcd stop/waiting.
Then I run start lipcd and I get lipcd start/running, process NNN (9020 or other...)
But

Code:
lipc-set-prop -- com.lab126.system takeScreenShot 1
still ends in an error....and com.lab126.system don't show up...

Last edited by silver18; 05-28-2012 at 05:03 PM.
silver18 is offline   Reply With Quote
Old 05-28-2012, 05:07 PM   #10
eureka
but forgot what it's like
eureka ought to be getting tired of karma fortunes by now.eureka ought to be getting tired of karma fortunes by now.eureka ought to be getting tired of karma fortunes by now.eureka ought to be getting tired of karma fortunes by now.eureka ought to be getting tired of karma fortunes by now.eureka ought to be getting tired of karma fortunes by now.eureka ought to be getting tired of karma fortunes by now.eureka ought to be getting tired of karma fortunes by now.eureka ought to be getting tired of karma fortunes by now.eureka ought to be getting tired of karma fortunes by now.eureka ought to be getting tired of karma fortunes by now.
 
Posts: 741
Karma: 2345678
Join Date: Dec 2011
Location: north (by northwest)
Device: Kindle Touch
Well, I can't say for sure, but I think it's not really running (or is stopped in a moment after starting).

Your command is working fine for me when lipc-daemon is running and shows the same error when lipc-daemon is stopped (not running).
eureka is offline   Reply With Quote
Old 05-28-2012, 05:10 PM   #11
silver18
THE NOOB
silver18 ought to be getting tired of karma fortunes by now.silver18 ought to be getting tired of karma fortunes by now.silver18 ought to be getting tired of karma fortunes by now.silver18 ought to be getting tired of karma fortunes by now.silver18 ought to be getting tired of karma fortunes by now.silver18 ought to be getting tired of karma fortunes by now.silver18 ought to be getting tired of karma fortunes by now.silver18 ought to be getting tired of karma fortunes by now.silver18 ought to be getting tired of karma fortunes by now.silver18 ought to be getting tired of karma fortunes by now.silver18 ought to be getting tired of karma fortunes by now.
 
silver18's Avatar
 
Posts: 701
Karma: 1545649
Join Date: Jan 2012
Location: Italy
Device: Kindle Touch 5.3.2
If the problem was lipc-daemon, I shouldn't be able to send any other command. Am I right?
Instead, I can send other commands, not related to com.lab126.system, like:

Code:
lipc-set-prop com.lab126.winmgr orientationLock L
silver18 is offline   Reply With Quote
Old 05-28-2012, 05:56 PM   #12
eureka
but forgot what it's like
eureka ought to be getting tired of karma fortunes by now.eureka ought to be getting tired of karma fortunes by now.eureka ought to be getting tired of karma fortunes by now.eureka ought to be getting tired of karma fortunes by now.eureka ought to be getting tired of karma fortunes by now.eureka ought to be getting tired of karma fortunes by now.eureka ought to be getting tired of karma fortunes by now.eureka ought to be getting tired of karma fortunes by now.eureka ought to be getting tired of karma fortunes by now.eureka ought to be getting tired of karma fortunes by now.eureka ought to be getting tired of karma fortunes by now.
 
Posts: 741
Karma: 2345678
Join Date: Dec 2011
Location: north (by northwest)
Device: Kindle Touch
lipc-daemon isn't the daemon that serves all LIPC communication. It's a wrong assumption. LIPC is a thin abstraction on top of D-Bus. And lipc-daemon uses this abstraction and only exposes properties as com.lab126.system publisher. So it's OK that other publishers are still accessible when lipc-daemon is stopped.
eureka is offline   Reply With Quote
Old 05-28-2012, 06:01 PM   #13
silver18
THE NOOB
silver18 ought to be getting tired of karma fortunes by now.silver18 ought to be getting tired of karma fortunes by now.silver18 ought to be getting tired of karma fortunes by now.silver18 ought to be getting tired of karma fortunes by now.silver18 ought to be getting tired of karma fortunes by now.silver18 ought to be getting tired of karma fortunes by now.silver18 ought to be getting tired of karma fortunes by now.silver18 ought to be getting tired of karma fortunes by now.silver18 ought to be getting tired of karma fortunes by now.silver18 ought to be getting tired of karma fortunes by now.silver18 ought to be getting tired of karma fortunes by now.
 
silver18's Avatar
 
Posts: 701
Karma: 1545649
Join Date: Jan 2012
Location: Italy
Device: Kindle Touch 5.3.2
I didn't know this!!
So, the point is now to bring up lipc-daemon...
silver18 is offline   Reply With Quote
Old 05-28-2012, 06:07 PM   #14
eureka
but forgot what it's like
eureka ought to be getting tired of karma fortunes by now.eureka ought to be getting tired of karma fortunes by now.eureka ought to be getting tired of karma fortunes by now.eureka ought to be getting tired of karma fortunes by now.eureka ought to be getting tired of karma fortunes by now.eureka ought to be getting tired of karma fortunes by now.eureka ought to be getting tired of karma fortunes by now.eureka ought to be getting tired of karma fortunes by now.eureka ought to be getting tired of karma fortunes by now.eureka ought to be getting tired of karma fortunes by now.eureka ought to be getting tired of karma fortunes by now.
 
Posts: 741
Karma: 2345678
Join Date: Dec 2011
Location: north (by northwest)
Device: Kindle Touch
For taking screenshot, just issue screenshot command. Result will be the same as setting the property of com.lab126.system.
eureka is offline   Reply With Quote
Old 05-28-2012, 06:09 PM   #15
silver18
THE NOOB
silver18 ought to be getting tired of karma fortunes by now.silver18 ought to be getting tired of karma fortunes by now.silver18 ought to be getting tired of karma fortunes by now.silver18 ought to be getting tired of karma fortunes by now.silver18 ought to be getting tired of karma fortunes by now.silver18 ought to be getting tired of karma fortunes by now.silver18 ought to be getting tired of karma fortunes by now.silver18 ought to be getting tired of karma fortunes by now.silver18 ought to be getting tired of karma fortunes by now.silver18 ought to be getting tired of karma fortunes by now.silver18 ought to be getting tired of karma fortunes by now.
 
silver18's Avatar
 
Posts: 701
Karma: 1545649
Join Date: Jan 2012
Location: Italy
Device: Kindle Touch 5.3.2
I know this, but I need this for two reason:
- my waf app uses that command
- I don't see why it mustn't work
silver18 is offline   Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Automatically set custom column when fetching news bork Library Management 1 04-14-2012 03:20 AM
Custom TextToSpeech "engine" as a way to create custom real audiobooks with texts noisy Kindle Developer's Corner 2 03-31-2012 08:42 AM
Using OnDevice to set the value of a custom column WendyR14 Library Management 3 10-23-2011 08:03 PM
Can custom book data be displayed in a custom column? kiwidude Development 9 03-02-2011 05:35 AM


All times are GMT -4. The time now is 12:40 AM.


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