Read out "Sudden Motion Sensor" in Macbook Pro

2 vues (au cours des 30 derniers jours)
Hans
Hans le 6 Juil 2013
Has anybody out there ever tried to access
the "Sudden Motion Sensor" present in any
Macbook via Matlab? I searched the whole
web but couldn't find an obvious solution.

Réponse acceptée

Ken Atwell
Ken Atwell le 6 Juil 2013
I'm not aware of anyone having done this. Apple apparently does not provide a Cocoa API to it, leaving you with informal, "tinkers" interfaces. A Stack Overflow article has some suggestions -- you would need either write some MEX glue code to interface Objective-C to MATLAB, or you may be able to use loadlibrary.
Another option would be to use this library, written Java. MATLAB has an interface to Java, so in theory this may be the easiest option.
In all cases, it looks like the options out there may not have been updated in the last handful of years, so they may or may not work with modern hardware (I'm guessing here). Also note that newish SSD drives do not have this hardware in question.
  2 commentaires
Hans
Hans le 7 Juil 2013
Thanks for the fast and informative answer! Great, thank you!
I already started to try to implement what you denoted as easiest option, namely using the java library from http://www.shiffman.net/p5/sms/ .
However, somehow it does not yet work, probably due to my inabilities... Despite of having used
javaaddpath .../sms/library/sms.jar
calling sms.Unimotion gives an error
>> sms.Unimotion.getSMSArray()
??? Undefined variable "sms" or class
"sms.Unimotion.getSMSArray".
Any Ideas?
Ken Atwell
Ken Atwell le 7 Juil 2013
This library was compiled in 2006, so my first guess is an 32/64 bit issue. Run this in the Terminal window:
cd path/to/file
file libUnimotionLib.jnilib
The file libUnimotionLib.jnilib was compiled for PowerPC and 32-bit Intel. All MATLAB releases on the Mac in recent years are 64-bit apps. This C library will need to be recompiled for 64-bit. Off the top of my head, I don't know how to compile native C code into a JNI library, sorry.

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Write C Functions Callable from MATLAB (MEX Files) dans Help Center et File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by