Phidget Manager causes access violation on delete

C, C++, and Visual C++
sgeiger
Phidgetsian
Posts: 8
Joined: Thu Jul 02, 2020 7:41 am
Contact:

Phidget Manager causes access violation on delete

Postby sgeiger » Thu Jul 02, 2020 8:50 am

I'm trying to use the manager for allowing flexibility in boards connected. When the manager is deleted (PhidgetManager_delete), it causes an access violation, BUT only if it was opened (If I create it but don't call PhidgetManager_open, it doesn't create the violation on deletion). Is it possible there is a problem with the phidget22 manager in c++?
(It does not matter if I connect a board or not - the violation depends only on opening the manager and then deleting it)
Thanks.

User avatar
mparadis
Site Admin
Posts: 733
Joined: Fri Oct 28, 2011 12:17 pm
Contact:

Re: Phidget Manager causes access violation on delete

Postby mparadis » Thu Jul 02, 2020 9:54 am

Do you get the same error if you call PhidgetManager_close() before delete?

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

Re: Phidget Manager causes access violation on delete

Postby Patrick » Fri Jul 03, 2020 12:17 pm

I can't reproduce.

What OS are you on?

Can you provide a code snippet which causes the crash?

Thanks,
-Patrick

sgeiger
Phidgetsian
Posts: 8
Joined: Thu Jul 02, 2020 7:41 am
Contact:

Re: Phidget Manager causes access violation on delete

Postby sgeiger » Sun Jul 05, 2020 5:59 am

PhidgetManager_close() does no difference (and according to documentation not needed).
I am writing a library for TouchDesigner...
Had one for the previous version of both Touch and Phidgets (21), and the manager worked then. The problem might be on the Touch side, but the fact that opening the manager creates the problem raises suspicious...
It's only the beginning. Relevant code is currently:

Code: Select all

TouchPhidgets22::TouchPhidgets22(const OP_NodeInfo* info) : myNodeInfo(info)
{
   myExecuteCount = 0;
   myOffset = 0.0;
   PhidgetReturnCode res;

   PhidgetManager_create(&man);

   res = PhidgetManager_setOnAttachHandler(man, mgrAttachHandler, NULL);
   if (res != EPHIDGET_OK) {
#ifdef DEBUG_TPH22
      std::cout << "Error setting onAttachHandler for Phidget manager: " << res << "\n";
#endif
   }

   res = PhidgetManager_setOnDetachHandler(man, mgrDetachHandler, NULL);
   if (res != EPHIDGET_OK) {
#ifdef DEBUG_TPH22
      std::cout << "Error setting onDetachHandler for Phidget manager: " << res << "\n";
#endif
   }
   
   res = PhidgetManager_open(man);
   if (res != EPHIDGET_OK) {
#ifdef DEBUG_TPH22
      std::cout << "Error opening Phidget manager: " + res;
      std::cout << "\n";
#endif
   }
   OutputDebugStringA("Manager Opened\n");
}

TouchPhidgets22::~TouchPhidgets22()
{
   PhidgetReturnCode res;
   res = PhidgetManager_delete(&man);
   if (res != EPHIDGET_OK) {
#ifdef DEBUG_TPH22
      std::cout << "Error deleting Phidget manager: " + res;
      std::cout << "\n";
#endif
   }
}
Last edited by sgeiger on Tue Jul 07, 2020 1:00 am, edited 1 time in total.

sgeiger
Phidgetsian
Posts: 8
Joined: Thu Jul 02, 2020 7:41 am
Contact:

Re: Phidget Manager causes access violation on delete

Postby sgeiger » Sun Jul 05, 2020 6:00 am

Forgot to write:
Win10, Visual Studio 2017

sgeiger
Phidgetsian
Posts: 8
Joined: Thu Jul 02, 2020 7:41 am
Contact:

Re: Phidget Manager causes access violation on delete

Postby sgeiger » Thu Jul 09, 2020 12:07 am

OK, Solved.
This was probably TouchDesigner's fault...
Had some timing problems. solved with a small execution delay after deleting the manager.

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

Re: Phidget Manager causes access violation on delete

Postby Patrick » Thu Jul 09, 2020 3:01 pm

thanks


Return to “C/C++”

Who is online

Users browsing this forum: No registered users and 2 guests