Page 1 of 1
Phidget Manager causes access violation on delete
Posted: Thu Jul 02, 2020 8:50 am
by sgeiger
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.
Re: Phidget Manager causes access violation on delete
Posted: Thu Jul 02, 2020 9:54 am
by mparadis
Do you get the same error if you call PhidgetManager_close() before delete?
Re: Phidget Manager causes access violation on delete
Posted: Fri Jul 03, 2020 12:17 pm
by Patrick
I can't reproduce.
What OS are you on?
Can you provide a code snippet which causes the crash?
Thanks,
-Patrick
Re: Phidget Manager causes access violation on delete
Posted: Sun Jul 05, 2020 5:59 am
by sgeiger
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
}
}
Re: Phidget Manager causes access violation on delete
Posted: Sun Jul 05, 2020 6:00 am
by sgeiger
Forgot to write:
Win10, Visual Studio 2017
Re: Phidget Manager causes access violation on delete
Posted: Thu Jul 09, 2020 12:07 am
by sgeiger
OK, Solved.
This was probably TouchDesigner's fault...
Had some timing problems. solved with a small execution delay after deleting the manager.
Re: Phidget Manager causes access violation on delete
Posted: Thu Jul 09, 2020 3:01 pm
by Patrick
thanks