multiple jvm accessing sensor

1 view
Skip to first unread message

Saeid Nourian

unread,
Feb 23, 2012, 2:09:50 PM2/23/12
to org-concord-sensor
I'm trying to run multiple sensors to run simultaneously in netlogo
but it appears that running my code a second time causes
AbstractSensorDevice.currentConfig to be null:

Exception in thread "main" java.lang.NullPointerException
at
org.concord.sensor.vernier.labquest.LabQuestSensorDevice.start(LabQuestSensorDevice.java:
210)

The problem seem to be due to

BGIOLibrary.openDeviceListSnapshot(Pointer handle,int deviceType,
IntByReference numDevices, IntByReference deviceListSignature);

the above returns numDevices value of "1" when ran from a first jvm,
but when starting a second jvm it returns "0" for numDevices.

I call device.close() before starting the new jvm but that doesn't
help.

any ideas?

Scott Cytacki

unread,
Feb 24, 2012, 10:40:14 AM2/24/12
to org-conco...@googlegroups.com
As a test, does it work if you disconnect and reconnect the usb after closing it on the first jvm, and before starting it on the second?

I also saw in this test class:
/labquest-jna/src/test/java/org/concord/sensor/labquest/jna/LabQuestJNATest.java
That it is calling a cleanup method.  You could modify the close method in the sensor device to call this cleanup, but then it might not re-open the library correctly so you might need to change some other code.  Another thing to check if you do this, is the speed.  If the whole library is closed each time it might take a while to re-open it.  Currently when the sensor is stopped the device is closed, so if doing a full library re-open is too slow that could make it annoying for users.

Scott


--
You received this message because you are subscribed to the Google
Groups "org-concord-sensor" group.
To post to this group, send email to org-conco...@googlegroups.com
To unsubscribe from this group, send email to
org-concord-sen...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/org-concord-sensor?hl=en?hl=en
Google Code project for org-concord-sensor: http://code.google.com/p/org-concord-sensor/

Saeid Nourian

unread,
Feb 29, 2012, 12:06:24 PM2/29/12
to org-concord-sensor
Hi Scott, I followed your suggestion about calling cleanup in close
method and the result is absolutely perfect. It works like a charm and
the speed is not affected much either.

If there are no objections I will update svn to include the call to
cleanup from close method.

Saeid

Scott Cytacki

unread,
Feb 29, 2012, 4:00:54 PM2/29/12
to org-conco...@googlegroups.com
On Wed, Feb 29, 2012 at 12:06 PM, Saeid Nourian <snou...@concord.org> wrote:
Hi Scott, I followed your suggestion about calling cleanup in close
method and the result is absolutely perfect. It works like a charm and
the speed is not affected much either.

If there are no objections I will update svn to include the call to
cleanup from close method.

Sure add that call.  Before commiting it to svn please run the junit test for the labquest.  
/sensor-vernier/src/test/java/org/concord/sensor/vernier/labquest/LabQuestSensorDeviceTest.java
When looking at Stephens workspace we found that the src/test/java folder was not set as an "eclipse source folder" so might need to do that too.

That junit test will ask you to plug in different types of sensors.  I probably have all of them at my desk.  I'm at home now, and I'm not sure if I'll be coming in tomorrow or not.  If you have a temperature sensor you can run most of the tests.  If all the temp sensor tests pass that is good enough to check it in, but we should get you the full suite of sensors so you can check that your changes don't break anything. I don't think I've ever run the test on windows so that might bring up some other complications.

Finally, Stephen has got the github version of the sensor projects working on his eclipse, so he might work with you to switch over to that:

Scott

Scott
Reply all
Reply to author
Forward
0 new messages