02-18-2012 07:11 PM
Hello,
I've tried to access the gyroscope for an AIR Native Extension, using the NDK 2.0 Beta 3, Flash Builder 4.6 and Tablet OS 2.0.0.7111
I managed to do a simple C library I can call from AIR (so that I'm sure all the settings are correct) but as soon as I add a reference to the sensor.h the library no longer loads. I get the following error in AIR:
ArgumentError: Error #3500: The extension context does not have a method with the name init.
at flash.external::ExtensionContext/_call()
at flash.external::ExtensionContext/call()
at com.adobe.nativeExtensions::Gyroscope$/get isSupported()[/Users/airqe/Users/sbhave/Gyroscope/
...
My hypothesis is that I'm using a library wich contains the sensor functions which cannot be found, hence it can't load my library. But I can perfectly be another issue.
Anyone has managed to make this work? Any help would be welcome.
Thanks!
Solved! Go to Solution.
02-22-2012 06:32 PM
If I am understanding what you are doing correctly, you're working with code from here:
http://www.adobe.com/devnet/air/native-extensions-
That seems to include extensions for iOS and perhaps Android, but I see no mention of PlayBook.
I would recommend taking a look at this code and setting it up in an ANE:
https://bdsc.webapps.blackberry.com/native/beta/do
02-22-2012 07:00 PM
My goal was to extend the Adobe ANE for the gyroscope to the playbook, on top of the already provided implementations for iOS and Android.
My problem doesn't seem to be at code level, as it's quite simple, but rather at library dependency. As soon as I had sensor method calls in my native C code, the library won't load (and the code isn't even executed). When I comment those lines, the library gets loaded correctly and I can call the ANE methods.
Any idea?
Thanks,
Benjamin
02-23-2012 11:47 AM
02-23-2012 01:29 PM
Unfortunately no, AIR only exposes the accelerometer data, and I'm looking for the gyroscope sensor.
I managed to get the log file on the device:
In air-log, I get:
err: extension: failed to load /accounts/1000/appdata/net.thingsfactory.sandbox.d
In log:
err: config: Failed to open file (): No such file or directory (tid:1)
unknown symbol: sensor_set_rate
unknown symbol: sensor_info
unknown symbol: sensor_info_get_delay_mininum
unknown symbol: sensor_info_destroy
I searched this forum and found this answer:
Apparently, there are limitations in ANE and I could use the libraries I want. Plus, I need to use bps to get the sensor events, and the thread above suggests it's not possible.
Are those limitations still true with BB OS 2.0, AIR 3.1 and the Native SDK 2.0?
Thanks!
Benjamin
02-23-2012 01:53 PM
Where are these functions defined? You if they defined somewhere in library on the device, you need
to link your ANE .so to the this library, so it be dynamically linked at runtime and will load these symbols.
02-23-2012 03:15 PM
I just added bps in the libraries (-l) settings of the GCC linker and it works.
Thanks for the explanation!
02-24-2012 08:12 AM
Hi,
I'm having similar problems getting sensors to work correctly through an ANE using the NDK 2.0. I've succesfully managed to compile and run my test app and ANE on my Playbook and can see the stdout traces I'm making during the ANE calls. So all is good, including calls to set up the sensor rates, etc.
My problems are with accessing the data from the sensors. Currently, all the examples I've seen for accessing the sensors have been fully native apps (e.g. https://bdsc.webapps.blackberry.com/native/beta/do
while {!shutdown) {
.... process the events forever until the app closes
}
Unfortunately, applying the same principle in an ANE doesn't work. When the ANE call is made, the ANE just sits there waiting and processing events and never returns to AIR.
In the iOS Gyroscope example, a handler is created to manage the despatching of sensor information, allowing the 'start' function call to end nicely and enable the AIR app to continue processing the despatched events. Is there a mechanism available on the PlayBook to create a handler/manager/thread to despatch sensor information separately, so again the AIR app can continue to consume the ANE despatched sensor events.
This problem may be part of what's described in the thread above (http://supportforums.blackberry.com/t5/Native-SDK-
Any help on this would be greatly appreciated.
Cheers
Greg209
02-24-2012 10:28 AM
Can you launch a thread when you call a "start sensor readings" function in your ANE? The pthreads library is widely documented.
From that point on, you should be able to run the event loop asynchronously and push events to the AIR app by dispatching an AIR event.
Alternately your "get readings" function could simply return the last reading cached by your event monitoring thread.
Cheers,
Sean
02-24-2012 02:45 PM
That sounds exactly like what I'm trying to achieve.
Thanks for pointing me in the right direction - I'll take a look into pthreads when I get chance, but sounds promising.
Cheers
Greg209