Read out "Sudden Motion Sensor" in Macbook Pro

2 次查看(过去 30 天)
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.

采纳的回答

Ken Atwell
Ken Atwell 2013-7-6
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 个评论
Hans
Hans 2013-7-7
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 2013-7-7
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.

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 C Shared Library Integration 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by