Phidgets.Spatial.nativeSpatialDataEvent

Supporting Visual Studio on Windows
TheLex

Phidgets.Spatial.nativeSpatialDataEvent

Postby TheLex » Fri May 06, 2011 9:04 am

Hi,

I've got a problem with the Spatial-Wireframe and Spatial-CompassCalibrator samples in the CSharp_2.1.8.20110329 package.

The Spatial-full sample is working perfectly, and both samples compile OK, but when I run them, I get this exception:

System.NullReferenceException was unhandled
Message="De objectverwijzing is niet op een exemplaar van een object ingesteld."
Source="Phidget21.NET"
StackTrace:
bij Phidgets.Spatial.nativeSpatialDataEvent(IntPtr phidA, IntPtr userPtr, IntPtr data, Int32 count)
InnerException:

The text with Message is Dutch for 'null-reference exception'.

This happens immediately after the Phid_attach event is processed.

I've tried changing the initialization code to make it the same as in the 'full' sample (i.e. by copying and using the openCmdLine function), but this does not make a difference.

My OS is Windows 7 Home Premium 64-bit.

I have Googled, but cannot find anything about this error.. Anybody know what's happening / what can be done to fix it?

Thanks in advance,
Lex

User avatar
Patrick
Lead Developer
Posts: 3078
Joined: Mon Jun 20, 2005 8:46 am
Location: Canada
Contact:

Re: Phidgets.Spatial.nativeSpatialDataEvent

Postby Patrick » Fri May 06, 2011 11:26 am

Are you using a 1056 or a 1049?

-Patrick

TheLex

Re: Phidgets.Spatial.nativeSpatialDataEvent

Postby TheLex » Fri May 06, 2011 11:40 am

The 1056 - PhidgetSpatial 3/3/3

User avatar
Patrick
Lead Developer
Posts: 3078
Joined: Mon Jun 20, 2005 8:46 am
Location: Canada
Contact:

Re: Phidgets.Spatial.nativeSpatialDataEvent

Postby Patrick » Thu May 12, 2011 9:06 am

Are you able to set a breakpoint at the start of the attach event, and then single step until the exception happens? It would be useful to know that function call is causing it.

Thanks,
-Patrick

TheLex

Re: Phidgets.Spatial.nativeSpatialDataEvent

Postby TheLex » Fri May 13, 2011 4:40 am

Sure, no problem. I've set breakpoints at
- Form1_Load on "phid = new Spatial();"
- phid_Attach on "phid.DataRate = phid.DataRateMax;"
- drawThreadFunc on "Math3D.RotatePoints(p.rotMatrix, p.vertexBuffer, p.originalVertices);"
- phid_SpatialData on "Pipeline.fillpen = Color.White;"

Surprisingly, the crash now seems to happen in drawThreadFunc on "if (positionRadio.Checked)"

However, if I comment-out the entire try/catch block and add "Thread.Sleep(10);" in the while-loop, the crash still occurs.

After some more single-stepping, I find that it almost always happens after the phid_Attach function ends (and returns control to the calling function). Maybe you can check to code that calls the Attach event-handler?


I just uncommented the contents of the while-loop in drawThreadFunc, and now the crash happens when I F10 over the RotatePoints function. However, when I look at the threads list, the 'active' arrow is not on the thread that is running drawThreadFunc, but on an unnamed thread that is not reporting a location.
That would explain why it happens on different locations in the sample-code: the time of the error in the other thread (which I cannot see) just happens to coincide with some function or other in the main thread. (which I can see).

My guess would therefore be that the error is not in the sample itself, but in the code that calls functions in the sample, and which is in a different thread than the main process, and also not in the drawing thread (since then we would have seen the location of the exception).

What's good to know is that the breakpoint on phid_SpatialData has not been triggered when it happens, so it appears that it happens really early in the process of receiving data from the sensor..

Hope this helps!

User avatar
Patrick
Lead Developer
Posts: 3078
Joined: Mon Jun 20, 2005 8:46 am
Location: Canada
Contact:

Re: Phidgets.Spatial.nativeSpatialDataEvent

Postby Patrick » Fri May 13, 2011 9:18 am

Ok, that's helpful, hopefully I can reproduce the crash.

Thanks,
-Patrick

Nitax

Re: Phidgets.Spatial.nativeSpatialDataEvent

Postby Nitax » Sun May 15, 2011 3:21 pm

Hi,

I am having an incredibly similar problem and I didn't notice this post until after I created my own thread (see here for details: viewtopic.php?f=22&t=4655)

I believe I may also shed some additional light on the problem but I am unsure why my solution works...


Return to “C#.NET”

Who is online

Users browsing this forum: No registered users and 2 guests