-
Notifications
You must be signed in to change notification settings - Fork 431
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Linux accel #51
Linux accel #51
Conversation
|
||
def _get_acceleration(self): | ||
try: | ||
pos = glob.glob("/sys/devices/platform/*/position")[0] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
About #49 (comment): No, I don't see a similar mechanism on OS X. There is another method described here: https://github.com/robinedwards/Mac-MotionSensor/blob/master/unimotion.c but I haven't tested it yet.
@trivedigaurav Could you please try this module: |
This is the experimental branch for mac os x's accelerometer implementation, you need to install the pyapplesms module first. |
Nope, I am afraid this doesn't work on my system:
|
Well you don't have a motion sensor apparently... Are you trying it on a desktop mac? Do you have a MacBook? |
I tried on a MacBook Pro 15-inch, Early 2011 on OS X 10.9.1. |
I don't know, maybe it doesn't have the sudden motion sensor... edit example.py, remove the exception catcher and see if the complete exception givers more information... |
I found the issue here. Apparently there have been some differences in the way you make the IOCTL call on 64-bit OS X is a bit different. After integrating the patch specified here: http://code.google.com/p/websaver/issues/detail?id=3, I was able to get the accelerometer working on my macbook. |
One caveat that I can see is that pyapplesms is under LGPL, so I am not sure how we'd be affected by it. It may be a good idea to check that before we use the library. |
@Davideddu I think we should raise an exception on enable if no accelerometer is present. |
I think so too, but I don't know if it's the case as the documentation doesn't say when and what exception is raised... |
I think a good way to do this would be to check all the necessary stuff in On Mon, May 19, 2014 at 10:09 PM, Davide Depau [email protected]:
|
Yeah that would work. Tomorrow I'm planning on using the computer, I'll figure out something... |
@Davideddu Also note that your PR has some unintended file changes as well from your win_email branch. You should fix those issues as well. |
@trivedigaurav I don't think removing again the win email patches will do any good. I'd either have to rebase it (obviously I mistakenly branched linux_accel from win_email instead of master) which I'm not gonna do because the I already pushed those commits, or delete the files and re-commit, which is probably going to make problems when merging, or amend the commit, same as rebase. About the exception, what do you think of an EnvironmentError(errno.ENODEV) ? It seems to best describe the problem, because it's not an OS related error, but hardware. In other words OSError would be the first choice, but as Linux is the coolest OS in the world and of course it supports accelerometers we're not gonna call it that way :) :D |
@Davideddu I have created a cleaned up version of your request (#68), so that it can be easily merged. |
Perfect, thank you, @trivedigaurav! Sorry I'm at an intermediate git level, that would have been too complicated for me! |
As @trivedigaurav made the new pull request this is better closed. |
Please check the comments in line 23. I didn't know which behavior was better, the choice is up to you.
Apparently there's no need to use evdev or stuff: according to IBM sysfs is reliable. You just need a glob to look for an accelerometer.
I'm not sure though about the range of the acceleration: on my PC it's from 1000 to -1000 (on android it's 10 to -10), but I don't know if it's related to the hardware used. I wanted to make it consisted so I simply divided it by 100, but if sysfs is not consistent we need to fix that and figure something out.
BTW I tested it and it works, at least with my accelerometer.
This is IBM's script I was talking about, where they use sysfs: http://www.ibm.com/developerworks/apps/download/index.jsp?contentid=150021&filename=knockAge-0.1.zip&method=http&locale=
(I forgot to checkout master before creating the new branch, I guess that if you merge this pr it will also merge the commits from the windows_email branch...)