Hang on Dictionary close

Supporting 2.7 and 3.2+
Nds

Hang on Dictionary close

Postby Nds » Mon Jan 04, 2010 4:25 am

Hi all,

I write a program for manage some phidgets.

All work fine, but when i try to close the program (trough a input change state or a value change on a key)

The exit procedure hang on the dictionary close (often but not everytime)

This is the code i call on exit:

Code: Select all

      CPhidgetDictionary_close(dict);
      CPhidgetDictionary_delete(dict);

      set_output(SBC,0,0,0,0,0,0,0,0);
      set_output(sk_ifkit,0,0,0,0,0,0,0,0);

      CPhidget_close((CPhidgetHandle)SBC);
      CPhidget_delete((CPhidgetHandle)SBC);
      CPhidget_close((CPhidgetHandle)sk_ifkit);
      CPhidget_delete((CPhidgetHandle)sk_ifkit);
      CPhidget_close((CPhidgetHandle)sk_rele);
      CPhidget_delete((CPhidgetHandle)sk_rele);


I have put a flag in the code that when the exit funciton is called no more input are accepted.

What's the correct procedure for close all the phidgets/dictionary?

The dictionary in use is onboard of the sbc, and at the moment don't exist other client than the sbc itself

Regards
Nds

P.s.

I try to make a dictionary client with python and the same appens with the row:

Code: Select all

try:
    keyListener.stop()
    dictionary.closeDictionary()
except PhidgetException as e:
    print("Phidget Exception %i: %s" % (e.code, e.details))
    print("Exiting....")
    exit(1)


The pythons scripts run on a:

Distributor ID: Ubuntu
Description: Ubuntu 9.10
Release: 9.10
Codename: karmic

From a windows machine all work fine, another strange behaviour is than from windows machine appear the heartbeat key from linux this don't appear.

Nds

Re: Hang on Dictionary close

Postby Nds » Mon Jan 04, 2010 11:09 am

Hi,

I see that the post is moved under python, but the frist half of the message si about c code inside the sbc.

Thank for the help :)

Regards
Nds

AdamS

Re: Hang on Dictionary close

Postby AdamS » Mon Jan 04, 2010 12:22 pm

Ahh yes, I see that now. Didn't read it carefully enough.

I believe we have found that this is a known issue in the library and investigation is underway into the cause.

Nds

Re: Hang on Dictionary close

Postby Nds » Mon Jan 04, 2010 2:25 pm

I thought it might depend on libraries,
I can do something to help with debugging?

AdamS

Re: Hang on Dictionary close

Postby AdamS » Tue Jan 05, 2010 12:34 pm

I have to get in touch with our head programmer to see what the status is on his investigation into this. I will let you know.

Nds

Re: Hang on Dictionary close

Postby Nds » Tue Jan 05, 2010 1:23 pm

At the moment my sbc is brick And i can't try anithing :/, i write another post about:
viewtopic.php?f=39&t=3366

While i resolv this problem i think to make a linux host for run the dictionary and control the other two phidgets, probrably i rewrite the code in python.

About the code i have some question, try to enumrate..

#how to manage multiple CPhidgetInterfaceKitHandle
I thought to make an array of handlers and call the open trough the dictionary and specify the size with argv.

#how to manage an event trough multiple phidgets
At the moment is switch from one phidget to another with the serial and some global variable, but i though to move the check from the serial to the array of handlers

#timing
I have insered some sleep() but where, when and how long need to be?
in some point a second is a very long time :/

The system is composed from one 1070, one 1018 and one 1014
The code for this test run with 4 Sensor
a joystick ~ 2 Sensors
a lm35
and a photoresistor

There are 4 switch and all the 16 digital output are used on the 1070 and 1018.
1014 only 2 output (3 and 4)

I hope you understand what i have writed, i need to improve my english :)

Thanks

Nds

P.s. I have removed the code, too long for post it here :)
Last edited by Nds on Thu Jan 07, 2010 4:06 am, edited 1 time in total.

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

Re: Hang on Dictionary close

Postby Patrick » Tue Jan 05, 2010 1:43 pm

If you use event based programming, you should never need to use Sleeps.

rather then using waitForAttachment, you could do your initialization in the attach handler (setting ratiometric, changeTrigger, etc.). You could also set your initial dictionary key in the dictionary serverConnect handler.

-Patrick

Nds

Re: Hang on Dictionary close

Postby Nds » Tue Jan 05, 2010 1:49 pm

Oh right :)

Thanks a lot,

The problem is the logic behid the event based programming, i need some practise.

But there are some documentation about?

Basically where the most used function can be called?

Nds


Return to “Python”

Who is online

Users browsing this forum: No registered users and 3 guests