Reply
Thread Tools
rm_you's Avatar
Posts: 98 | Thanked: 189 times | Joined on Jul 2007 @ San Antonio, TX
#41
Yes, I am currently assuming 0 as sw level, just to set the current...

Thanks for explaining what the kernel is doing! The values I was seeing make a bit more sense now. I thought I was going insane, writing one value to the file and seeing another! >_>

I will look into reverse-engineering that, as it would be much better if the applet worked without the special kernel...

Oh, new version: http://cs.trinity.edu/~acm/debs/adva...ght-0.3.tar.gz
And source: http://cs.trinity.edu/~acm/debs/adva...0.3-src.tar.gz

The only real changes are a bit of code cleanup (doubt it has a performance impact) and it now checks to see which device it is on, to prevent blanking the screen on an n800 (since it lacks a transflective screen) and confusing the user.

Edit: an strace is here: http://pastebin.ca/850430
I'm not sure how to interpret that... I have done some strace interpretation for an Operating Systems class once, but nothing this complex.

Last edited by rm_you; 2008-01-11 at 05:37.
 

The Following User Says Thank You to rm_you For This Useful Post:
Posts: 2,152 | Thanked: 1,490 times | Joined on Jan 2006 @ Czech Republic
#42
Originally Posted by rm_you View Post
an strace is here: http://pastebin.ca/850430
I'm not sure how to interpret that... I have done some strace interpretation for an Operating Systems class once, but nothing this complex.
Here is my try from 770, your strace build seems to not to resolve syscalls etc which makes it a bit more hard
Code:
Nokia-770-36:/# strace /usr/sbin/dsmetest -l 1
execve("/usr/sbin/dsmetest", ["/usr/sbin/dsmetest", "-l", "1"], [/* 47 vars */]) = 0
..
..
..
brk(0)                                  = 0x12000
brk(0x13000)                            = 0x13000
socket(PF_FILE, SOCK_STREAM, 0)         = 3
connect(3, {sa_family=AF_FILE, path="/tmp/dsmesock"}, 112) = 0
fcntl(3, F_SETFL, O_RDONLY|O_NONBLOCK)  = 0
write(3, "\f\0\0\0\206\2\0\0\1\0\0\0", 12) = 12
write(1, "brightness reqyest sent!\n", 25brightness reqyest sent!
) = 25
close(3)                                = 0
_exit(0)                                = ?
So basically it is the
Code:
write(3, "\f\0\0\0\206\2\0\0\1\0\0\0", 12) = 12
line. When starting with -l 2 it becomes
Code:
write(3, "\f\0\0\0\206\2\0\0\2\0\0\0", 12) = 12
or when using strace -x (print in hex) it becomes
Code:
write(3, "\x0c\x00\x00\x00\x86\x02\x00\x00\x02\x00\x00\x00", 12) = 12
In your output the line is
write(3, "\f\0\0\0\211\2\0\0d\0\0\0", 12) = 12
ASCII code for 'd' is 100 so it makes some sense. The beginning is perhaps some version handshake or structure size or something.
__________________
Newbies click here before posting. Thanks.

If you really need to PM me with troubleshooting question please consider posting it to the forum instead. It is OK to PM me a link to such post then. Thank you.

Last edited by fanoush; 2008-01-11 at 09:07.
 

The Following User Says Thank You to fanoush For This Useful Post:
rm_you's Avatar
Posts: 98 | Thanked: 189 times | Joined on Jul 2007 @ San Antonio, TX
#43
Ok, so all I have to do is write out to "/tmp/dsmesock" something like this?
Code:
\x0c\x00\x00\x00\x86\x02\x00\x00\x[hexvalue]\x00\x00\x00
Possibly? >_> I will do some testing.

By the way, what did your strace command line look like? On my n800 it is complicated a little bit because strace doesn't exist in the chroot with dsmetest, so I had to do
Code:
strace -f chroot /mnt/initfs/ dsmetest -l 100

Last edited by rm_you; 2008-01-11 at 10:06.
 
Posts: 2,152 | Thanked: 1,490 times | Joined on Jan 2006 @ Czech Republic
#44
Originally Posted by rm_you View Post
Ok, so all I have to do is write out to "/tmp/dsmesock" something like this?
Code:
\x0c\x00\x00\x00\x86\x02\x00\x00\x[hexvalue]\x00\x00\x00
Possibly?
Yes, not sure about the \x86 since you have different value there.

Originally Posted by rm_you View Post
By the way, what did your strace command line look like?
The line is above, I have compiled static version of strace and copied it to initfs so I could run it inside chroot :-) Maybe there is easier solution but this worked too and I needed it quite a few times inside initfs (like when debugging why dropbear does not start early in usb network recovery mode :-).
__________________
Newbies click here before posting. Thanks.

If you really need to PM me with troubleshooting question please consider posting it to the forum instead. It is OK to PM me a link to such post then. Thank you.
 
rm_you's Avatar
Posts: 98 | Thanked: 189 times | Joined on Jul 2007 @ San Antonio, TX
#45
Err, yes... I guess I saw that and it didn't register. I guess I will have to compile something similar to get info...

Edit: Ok, so here is the code I am trying to use...
Code:
#include <stddef.h>
#include <stdio.h>
#include <stdlib.h>
#include <sys/socket.h>
#include <sys/un.h>

void main()
{
        int mysock = socket(PF_FILE, SOCK_STREAM, 0);
        struct sockaddr_un name;
        size_t size;
        int nbytes;

        name.sun_family = AF_FILE;
        strcpy (name.sun_path, "/mnt/initfs/tmp/dsmesock");
        size = (offsetof (struct sockaddr_un, sun_path) + strlen (name.sun_path) + 1);

        if (connect (mysock, (struct sockaddr *) &name, size) < 0) {
                printf("Error opening socket.\n");
        }
        else {
                nbytes = write (mysock, "\f\0\0\0\211\2\0\0d\0\0\0", 12);
                if (nbytes < 0)
                {
                        printf("Write error.\n");
                        exit(1);
                }
                shutdown(mysock,2);
        }
}
It seems to go? but it doesn't do anything.

strace:
Code:
Nezumi:~# strace -f ./testdsme
execve("./testdsme", ["./testdsme"], [/* 59 vars */]) = 0
brk(0)                                  = 0x11000
uname({sys="Linux", node="Nezumi", ...}) = 0
mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x40000000
access("/etc/ld.so.preload", R_OK)      = -1 ENOENT (No such file or directory)
open("/etc/ld.so.cache", O_RDONLY)      = 3
fstat64(3, {st_mode=S_IFREG|0644, st_size=31704, ...}) = 0
mmap2(NULL, 31704, PROT_READ, MAP_PRIVATE, 3, 0) = 0x40004000
close(3)                                = 0
open("/lib/libc.so.6", O_RDONLY)        = 3
read(3, "\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\3\0(\0\1\0\0\0\324\302"..., 512) = 512
fstat64(3, {st_mode=S_IFREG|0755, st_size=1086428, ...}) = 0
mmap2(0x41028000, 1118708, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x41028000
mprotect(0x4112c000, 32768, PROT_NONE)  = 0
mmap2(0x41134000, 12288, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x104) = 0x41134000
mmap2(0x41137000, 8692, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x41137000
close(3)                                = 0
mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x4000c000
syscall_983045(0x4000c4a0, 0x4000c4a0, 0x41023048, 0x4000cb78, 0x40, 0, 0x48, 0xf0005, 0, 0, 0x41023000, 0xbee853d4, 0, 0xbee85050, 0xfffffff8, 0x41000ad0, 0x20000010, 0x4000c4a0, 0xd02c, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0) = 0
mprotect(0x41134000, 4096, PROT_READ)   = 0
munmap(0x40004000, 31704)               = 0
mq_notify(1, ptrace: umoven: Input/output error
{...})                     = 3
SYS_283(0x3, 0xbee854d8, 0x1b, 0xbee854d8, 0x41022db8) = 0
write(3, "\f\0\0\0\211\2\0\2\0\0\0\0", 12) = 12
SYS_293(0x3, 0x2, 0xc, 0xc, 0x41022db8) = 0
io_submit(0, 0, 0 <unfinished ... exit status 0>
Process 3339 detached

Last edited by rm_you; 2008-01-11 at 11:19.
 
Posts: 2,152 | Thanked: 1,490 times | Joined on Jan 2006 @ Czech Republic
#46
Maybe using hex values could confuse you or compiler less (i.e. maybe the output on screen look same but binary data in string is in fact different)?

Also if it still doesn't work you could steal the code from https://garage.maemo.org/plugins/scm...ot=powerlaunch
see dsme.c and .h, void dsme_connect(Powered *server) has slightly different socket setup.

EDIT:
also you may try to drop unneeded /mnt/initfs/ from path to dsme socket but that perhaps won't fix anything
__________________
Newbies click here before posting. Thanks.

If you really need to PM me with troubleshooting question please consider posting it to the forum instead. It is OK to PM me a link to such post then. Thank you.

Last edited by fanoush; 2008-01-11 at 14:03.
 

The Following User Says Thank You to fanoush For This Useful Post:
rm_you's Avatar
Posts: 98 | Thanked: 189 times | Joined on Jul 2007 @ San Antonio, TX
#47
Wow, yeah... They've done ALL the work for this. They actually even have a display brightness function. >_>

I'm going to start ripping the code I need from their stuff and converting it to work correctly in my applet. I <3 GPL!
 
rm_you's Avatar
Posts: 98 | Thanked: 189 times | Joined on Jul 2007 @ San Antonio, TX
#48
Ok, well... I decided to just cheat and use system() to run chroot and dsmetest. It's a little laggier than it would probably be if I implimented it myself in C, but it *works* for now.

I will continue trying to get the socket connections and stuff to work in the next day or two. Meanwhile, the newest version of the applet does *not* require a modified kernel, and can be found here: http://cs.trinity.edu/~acm/debs/adva...ht-0.4b.tar.gz
And source: http://cs.trinity.edu/~acm/debs/adva....4b-src.tar.gz

To install, just untar, cd into the directory and run ./install.sh as root (though it should try to auto gainroot itself... thanks for the code for that, fanoush :P).

Note: I'm not sure why, but it seems that when you first add it and enable it, the UIdesktop crashes. Sometimes this happens the first two times you enable/disable it. I have not been able to determine WHY. If anyone has ideas, please share them.

Last edited by rm_you; 2008-01-13 at 07:09.
 

The Following 2 Users Say Thank You to rm_you For This Useful Post:
GeneralAntilles's Avatar
Posts: 5,478 | Thanked: 5,222 times | Joined on Jan 2006 @ St. Petersburg, FL
#49
Originally Posted by rm_you View Post
Note: I'm not sure why, but it seems that when you first add it and enable it, the UI desktop crashes. Sometimes this happens the first two times you enable/disable it. I have not been able to determine WHY. If anyone has ideas, please share them.
Just for accuracy's sake.
 
Posts: 6 | Thanked: 0 times | Joined on Nov 2007
#50
rm_you,

Huge, huge thanks for your work!
Just checked your page and found a v0.5 deb package for your applet. I installed it using the red pill mode, enabled it in the status bar... And here I go. Works like a charm.

No I can use my N800 as a real bedside alarm clock with the dim light at its very minimum. Awesome.

Thanks a lot!

Oh, next step: if it could somehow remind the settnigs wether the unit is plugged or not, that would be, well, just perfect...

Cheers!
 
Reply


 
Forum Jump


All times are GMT. The time now is 16:42.