Accelerometer Access at kernel level - Hardware Hacking General

I would like to know how to access the accelerometer at the kernel level and read its values? For example how to identify if the user is standing still or moving(driving). Any tutorial, how to guide or some direction on this...

DKSL said:
I would like to know how to access the accelerometer at the kernel level and read its values? For example how to identify if the user is standing still or moving(driving). Any tutorial, how to guide or some direction on this...
Click to expand...
Click to collapse
This is a software question, not a hardware question - and the answer is different for every device. (Which is why getting an opensource sensor HAL on the I9100/I777 has been such a *****.)

Related

Find dll functions from rom dll

Not sure if I have worded this properly as I'm at the edge of my knowledge but I wish to call a function that I am assuming is in a DLL which is contained in ROM. I know the name of the DLL but how can I get a list of functions available from it when I cannot copy it onto my PC?
Many Thanks
Hi Tailor.
First, what function exactly are you looking for? There may be some documentation on it somewhere.
To browse a ROM dll you need to get a ROM dump. The simplest way for your purpose, provided you have a WM5 device is to search for TESTWM5.exe by mamiac on this forum. It will dump all files to your SD. They won't be workable for coding purposes, but still good enough to use dependency walker to get exported functions from DLLs.
Unfortunately that still won't tell you the parameters the function expects. only its name.
Hi Levenum and thanks for your reply.
Its a Sony Sat Nav Windows CE 4.2 device so unforunately theres not much chance of a ROM dump or documentation. Then unit is sold as a finished product and not intended for further developement.
I have installed TomTom instead of the poor app already installed and was trying to get access to the hardware buttons and Light sensor on the unit and then intended to use the TomTom SDK to recreate their functions.
The keys don't not trigger a key press event but their are DLL's called something like powerbutton.dll and navbutton.dll and so it's a fair guess that they could be used to trigger these events.
Obviously without knowing their exported functions I'm not going to get much further.
Any further thoughts ?
Many Thanks
How exactly are you trying to catch the key events?
For what you describe, you don't just need to know function names, you need to know with what parameters to call them so this is definitely not the way to go.
If you are coding with C++ search for info on SetWindowsHook. I am not sure of its implementation on CE, but this might be what you need.
I'm using VB.Net 2005
I'll have a look at SetWindowsHook, Thanks.
Any ideas for the light sensor, there's a test app that Sony have left on the device, it gives a reading from 0 to 100?
How are they likely to be reading this value?

Developing Auto-DisableRefresh-When-Dragging App [New Video Added]

I know some people have already discussed this in the noRefresh App thread.
But I got a new idea
I don't wanna create a module and embed that to applications
Instead, I created a new Input Device in the kernel
After that, I set the device ( dev/input/event3 ) permission to allow read / write for others.
Then, write an app using JNI to catch the Input Device and set the mode of refreshing.
The prototype proved that this idea works, as i worked out it already, but not very perfect, still in experiment
I am just in some problems of threading, as I am not a professional programmer
This is wt i have now:
http://www.youtube.com/watch?v=GkFyvRR6In8
NEW!! : http://www.youtube.com/watch?v=cucG03rg3tg
I know that my method is a bit dirty,
but at least it works XD
I hope that someone would like to help
Upload those code soon
By the way, why can't i change content of init.rc ?
It removes my changes after reboot..... How to solve?
wheilitjohnny said:
By the way, why can't i change content of init.rc ?
It removes my changes after reboot..... How to solve?
Click to expand...
Click to collapse
You need to modify uRamdisk to change init.rc.
Would you like to tell me how to unpack the uRamdisk? I use both Windows and Ubuntu, any methods on these two platform is ok. Thanks!
Try the script from this post http://forum.xda-developers.com/showpost.php?p=24135886&postcount=72
This is simply amazing. Since you already have it working, polishing it shouldn't take too long (I think, I'm still a beginner programmer).
I don't think /dev/input is a good place to park that.
There are any number of things that could show up there and affect order.
Why not put it in its own directory?
Maybe I'm missing something, but if we use your method you still expect applications to have to be modified to read/write from event3 to control display mode?
As it is now, you only need a single function call to switch display modes. Yes, there is a little bit of housework to do before that, but what could be simpler than a single function?
I think no place else is more suitable than /dev/input.
As /dev/input is the linux kernel's input system.
In the driver, I would only use the input report system but not use the I/O system.
Maybe even setup a input/event searching function to solve the problem later.
The case now is that, the touch screen originally just provide event2,
but if we need to extract move and fingerup information on upper level, it may waste some time.
In order to make the whole algorithm easier and faster, I added 1 more event in the zForce driver,
to only output FingerMove and FingerUp state.
As the reporting system is starting from the kernel, this hack would need to change uImage + uRamdisk + Add an App. The project is quite huge.
My final target is to make the application remembering your choice on what mode u need for the focusing application.
AlwaysOn / OnlyWhenDragging / AlwaysOff, so on.
Of coz the click-to-call function still work.
Isn't it a better workflow and more intuitive, isn't it the thing that we would expect?
I already have an dev/input/event3 on my system and sometimes event4, 5, 6.
That's why I don't think that whatever it is you are doing belongs there.
Is the point to allow coders for user applications to interface with your driver?
Is this supposed to work without modifying user applications?
What information would be going in/out of event3?
Clearly I am missing something here.
Actually not necessary to be event3, the system will auto-ly create a new eventx, just in normal case, without any extra USB devices, a nook should only have up to event2. So, I use event3 as an example here.
We can later make the program auto-ly search back which is the needed eventx.
Yes, u r right, we no need to modify any other applications and this is exactly the point y i am creating this!
Anyone know how to call a FullScreen Refresh in a service?
always on?
Look really great. Since blinking after scrolling is incomfortable is it possible to have also "always on " mode using your new ideas?
My final target is to make the application remembering your choice on what mode u need for the focusing application.
AlwaysOn / OnlyWhenDragging / AlwaysOff, so on.
Of coz the click-to-call function still work.
Also an Over-Ride mode, for more flexible using.
But the most basic part need to be handled well now, as it is not very perfect now.
I still don't figure out how to call the e-ink driver to refresh the screen =-=
wheilitjohnny said:
I still don't figure out how to call the e-ink driver to refresh the screen =-=
Click to expand...
Click to collapse
Have you tried
Code:
echo 1 > /sys/class/graphics/fb0/epd_refresh
?
wheilitjohnny said:
Yes, u r right, we no need to modify any other applications and this is exactly the point y i am creating this!
Click to expand...
Click to collapse
Are you saying that your idea does not require modifying user applications?
If it doesn't, then there is no need to have a public interface.
It will be only your code talking to your code.
What is the point of this /dev/input/event3? You say that it will be writable. What's going in and out?
Some apps will be using gestures, some dragging. How are you going to keep track of that all?
I have one application that works perfectly fine now, one activity uses swipe gestures to page up/down while another activity uses drag with a user choice of A2 and display while dragging or else only panning at ACTION_UP.
All this requires less than 10 lines of code.
With multitouch, many applications don't even need A2. Even normal panning in Opera Mobile works much better now that Opera doesn't try to display while panning.
Maybe my english is too bad, cannot express the idea well.
I know, we can make such an application with noRefreshDrag working on its own well.
But how about other applications, it is impossible for us to change all applications.
So, my idea is making it system based.
My prototype is very good now, after several adjustment.
Not limited to only 1 application, but the whole system.
The approach is like this:
1. zForce driver provide extra information to InputEvent
2. A JNI catch the InputEvent
3. A service get the data and set the update mode
We only need to write 1 application to handle the setting of this chain.
This is what i mean, hope that u get what i mean now.
mali100 said:
Have you tried
Code:
echo 1 > /sys/class/graphics/fb0/epd_refresh
?
Click to expand...
Click to collapse
Let me try it now!
wow, it works great
wheilitjohnny said:
zForce driver provide extra information to InputEvent
Click to expand...
Click to collapse
I guess that this is the part that I don't understand.
What is this extra information?
Renate NST said:
I guess that this is the part that I don't understand.
What is this extra information?
Click to expand...
Click to collapse
It created an extra Event, l called it Event3 before.
Driver reports only move and finger_up to Event3.
Just providing a channel to pass an information from driver to user-space.
You may ask why not directly using the existing Event, need to create another one.
That is because, the original one only have touch and position information, parsing them back to move information need a bit of work. As the hardware provided the move information, then don't waste it.
Code:
public boolean dispatchTouchEvent(MotionEvent event)
{
switch(event.getAction())
{
case MotionEvent.ACTION_DOWN:
break;
case MotionEvent.ACTION_MOVE:
break;
case MotionEvent.ACTION_UP:
break;
}
return(true);
}
}
Isn't that everything that you could ask for?

[Q] Do I need to write drivers?

I have fair number of years of programming behind me. But I haven't tried anything for Android, as I dislike Java.
But I want to try. I want to make something that works at low level, say, like a firewall. It acts as a filter between two communicating parties/devices.
To write anything like that, can someone suggest which is the best approach - code in Java (if it can perform such a feast) or code driver in C?
Thanks much!
Regards,
Nayan
Sent from my Micromax A117 using xda app-developers app
The interesting thing in such low level projects is the entry point: So for a firewall you only have to acces iptables because android has linux kernel. So no C-part, no drivers, only plain java. See AFWall, it's an open source firewall.
EmptinessFiller said:
The interesting thing in such low level projects is the entry point: So for a firewall you only have to acces iptables because android has linux kernel. So no C-part, no drivers, only plain java. See AFWall, it's an open source firewall.
Click to expand...
Click to collapse
Excellent! I would certainly study AFWall. Thanks for the reference.
But actually, my quest doesn't stop here. I am exploring Android, and Google's restriction of "UI to be built only via Java". (I am not interested in scripting and widgets for now, unless they are absolutely needed.)
I want to know the answers for same question (driver or app) for the following:
* Network Filter [EmptinessFiller, you already answered this as Java]
* Disk (SD cards) (for many various purposes) - file system should not block the intention, hopefully.
* USB filter
* SMS filter
I am still thinking of other categories. Will write more later.
Please suggest and refer. Thanks again!
General answer: Your app is always built in java. (It's UI components, it's LifeCycle (Activity, Service, Broadcastreceiver))
You may include native code, but that does not have more possibilities. It's only a little bit quicker.
Forgotten: If you have root, you may want to change some binaries, because you can't change things in an app. There you need native code of course.
EmptinessFiller said:
You may include native code, but that does not have more possibilities. It's only a little bit quicker.
Click to expand...
Click to collapse
Shame, isn't it? Too much power in Java's hand
EmptinessFiller said:
Forgotten: If you have root, you may want to change some binaries, because you can't change things in an app. There you need native code of course.
Click to expand...
Click to collapse
My point exactly! Low level stuff is best written in native code.
But right now, I am learning how to.
cnayan said:
Shame, isn't it? Too much power in Java's hand
My point exactly! Low level stuff is best written in native code.
But right now, I am learning how to.
Click to expand...
Click to collapse
Have a look at the Android NDK and this guide about the development of root apps.
nikwen said:
Have a look at the Android NDK and this guide about the development of root apps.
Click to expand...
Click to collapse
Thanks for the link. Good stuff, but won't help in my targets... unless an example is seen.

[HELP] Android unlock mechanism

Hi,
I'm new in Android environment, but I have some experience with Java programming. I want to try some mobile apps, so i started to writing my first game. Everything is ok, but I don't know how to create mechanism like in "maze" Android unlock screen (can't put any link with photo ). I have list of points on screen and I want to give user ability to draw a path between these points. I've heard that there is special listener for this, but I can't find that.
Thanks for your help and sorry for my English
chris_black
chris_black said:
Hi,
I'm new in Android environment, but I have some experience with Java programming. I want to try some mobile apps, so i started to writing my first game. Everything is ok, but I don't know how to create mechanism like in "maze" Android unlock screen (can't put any link with photo ). I have list of points on screen and I want to give user ability to draw a path between these points. I've heard that there is special listener for this, but I can't find that.
Thanks for your help and sorry for my English
chris_black
Click to expand...
Click to collapse
Don't know it at the top of my head either, but checkout the source of this lockpattern library, I'm sure you can find out how they did it

nook touchndevelopmemt toolchain Qs

Hi All,
I'm a software developer, reasonably comfortable with compiling apps in Linux, though still got more to learn on inner workings of the full system.
I've been thinking about following the Linux from Scratch book for a while - and also about converting my Nook e-reader into a useful device for developing on when out im the sun.
I guess there are some significant challenges here - device trees and commercial secrets, perhaps some crypto keys used for signing update images to boot (I'm familiar with these problems, but not solutions or good workarounds).
What I'd really like is a good understanding of:
- what tool chain I need to setup
- What has been tried already and what the problems were
- any further help/datasheets that can get me going
I'd have posted this in the 'android development' area as the closest forum for what l'm trying to do, but apparently I'm not allowed until I've got my post count up - so I'm being forced to post in 'general'. If someone agrees and can move it, that would be great.
P.s. I have searched the xda site, but I'm not finding what I'm looking for. I'm sure it must be here somewhere, so any pointers/links on where it is would be appreciated.
SimonSimpson said:
Hi All,
I'm a software developer, reasonably comfortable with compiling apps in Linux, though still got more to learn on inner workings of the full system.
I've been thinking about following the Linux from Scratch book for a while - and also about converting my Nook e-reader into a useful device for developing on when out im the sun.
I guess there are some significant challenges here - device trees and commercial secrets, perhaps some crypto keys used for signing update images to boot (I'm familiar with these problems, but not solutions or good workarounds).
What I'd really like is a good understanding of:
- what tool chain I need to setup
- What has been tried already and what the problems were
- any further help/datasheets that can get me going
I'd have posted this in the 'android development' area as the closest forum for what l'm trying to do, but apparently I'm not allowed until I've got my post count up - so I'm being forced to post in 'general'. If someone agrees and can move it, that would be great.
P.s. I have searched the xda site, but I'm not finding what I'm looking for. I'm sure it must be here somewhere, so any pointers/links on where it is would be appreciated.
Click to expand...
Click to collapse
I have tried to get info on such things three times over 2 years for different devices, no one every seems to point me in the right direction, the most i have been able to find out is how to make compile cm and a little bit of how to customize roms, not to be a downer but i think the process is often so different for ever device and difficulties usually happen that the only people that build roms are people that have either have experience I n some form from their job, just edit existing source for cm(updating to a new version, customizing roms ect...) or have screwed with the stuff for years till the point that they just figured out alot of problems themselves. Wish a could find a good guide myself to atleast get the basic dependencies required for a device to boot together, if i could get something to boot the rest of the issues could be worked out with trial and error, boot noone on xda, Android authority, Reddit or cm's own forums goes into enough depth to make that possible.
Hi jaykoerner,
Thanks for your reply - good to know I'm not alone with my echo!
I've discovered some useful links if anyone wants to begin getting to grips with all this...
1. XDA Devs has a wiki (not sure how to find from the forum links...?)
http://forum.xda-developers.com/wiki/BN_Nook_Simple_Touch
2. There's a (atleast one) customized kernel (and probably a dev-tool chain) available on GitHub:
https://github.com/javifo/NST/tree/master/kernel -- including kernel compilation instructions
https://github.com/javifo/NST -- root of the repository.
3. Parallel to Raspberry Pi kernel compilation (so you may want to learn from that as it probably has more articles)
https://www.raspberrypi.org/documentation/linux/kernel/building.md
I'll post more when I next do something with the information (Still want to understand more on the android HAL)
Hope that helps someone!
SS.
SimonSimpson said:
Hi jaykoerner,
Thanks for your reply - good to know I'm not alone with my echo!
I've discovered some useful links if anyone wants to begin getting to grips with all this...
1. XDA Devs has a wiki (not sure how to find from the forum links...?)
http://forum.xda-developers.com/wiki/BN_Nook_Simple_Touch
2. There's a (atleast one) customized kernel (and probably a dev-tool chain) available on GitHub:
https://github.com/javifo/NST/tree/master/kernel -- including kernel compilation instructions
https://github.com/javifo/NST -- root of the repository.
3. Parallel to Raspberry Pi kernel compilation (so you may want to learn from that as it probably has more articles)
https://www.raspberrypi.org/documentation/linux/kernel/building.md
I'll post more when I next do something with the information (Still want to understand more on the android HAL)
Hope that helps someone!
SS.
Click to expand...
Click to collapse
My initial thought was that toolchain should match the underlay Linux kernel of Eclair (2.6.x.y) for us to be sure it could be run on NST. This info that I still have to search through is certainly helpful. Thanks!
SimonSimpson said:
I guess there are some significant challenges here - device trees and commercial secrets, perhaps some crypto keys used for signing update images to boot...
Click to expand...
Click to collapse
Neither the NST or the newer glows use device trees.
In the Glows this is all handled by the custom ntxconfig which allows simple configuration.
For building Android apps, you use the straight Android SDK, possibly also the Android NDK (for native code).
You'd also use the NDK for building command line utilities.
I've never built a kernel from scratch, but I have binary modified/patched them.
There is the simpler bit of patching system image ramdisks which can be conviently handled by my imgutil.exe in the signature.
If you want to do audio, you really are better off with the Glow4 (7.8") which actually supports it.

Categories

Resources