Jump to content

As of July 17, 2015, the LabJack forums here at forums.labjack.com are shut down. New registrations, topics, and replies are disabled. All forums are in a read-only state for archive purposes.

Please visit our current forums at labjack.com/forums to view and make new posts. To post on the current forums, use your labjack.com login account. Your old LabJack forums login credentials have been retired. There are no longer separate logins for labjack.com and LabJack forums.


Photo

Is there a proper way to close a U3-HV?

U3-HV python

  • Please log in to reply
5 replies to this topic

#1 communiss

communiss
  • Members
  • 5 posts

Posted 28 March 2014 - 07:54 AM

I just started using the U3-HV using the python wrappers and I noticed that after successfully running some code, if I try to run it again, then I get an exception stating 

Couldn't open device. Please check that the device you are trying to open is connected.

For other devices, I have had to issue a "shut down" command or a command to close the communications stream to the device, but I don't see any such command in the U3 documentation. Any help would be greatly appreciated

 

 

PS:

 

I have only been playing with the U3 for two days, and I have to say it is a joy to use. The documentation is pretty clear and I am happy to finally get away from NI! I'll probably be buying a U6 or two in a few days.

 



#2 LabJack Support

LabJack Support
  • Admin
  • 8677 posts

Posted 28 March 2014 - 10:18 AM

Typically you would just close the handle to the device, which is analogous to "shuting down" or "un-claiming". In the UDLibrary this is accomplished by calling Close().  The LabJackPython wrapper for the U3-HV device should also have similar functionality.  According to the examples, it'll look like "d.close()"

 

>>> import u3

>>> d = u3.U3() 
>>> d.close()  #Linux and Mac OS X close

 

You might also find the ResetLabJack() function useful. LabJackPython equivalent is "d.reset()"

http://labjack.com/s...16-resetlabjack



#3 communiss

communiss
  • Members
  • 5 posts

Posted 28 March 2014 - 11:36 AM

Thanks, that did the trick!  I have no idea why I didn't see it in the documentation.



#4 LabJack Support

LabJack Support
  • Admin
  • 8677 posts

Posted 28 March 2014 - 12:18 PM

To add to our previous post, on Linux and Mac OS X you use the "close" method ("d.close()") in the U3 class to close the device handle.

 

On Windows you cannot close individual device handles with our driver (UD) and the close method does nothing. Instead use the Close() function from the LabJackPython module which closes all device handles. For example:

import u3
import LabJackPython

d = u3.U3()  #Open first found U3
LabJackPython.Close()  #Windows close (all devices)

Also, only one application/process can claim access to a U3 at a time. Closing the device handle in the application unclaims the U3 so that other applications/processes can find and use it.



#5 ferryard

ferryard
  • Members
  • 3 posts

Posted 11 November 2014 - 09:29 PM

Typically you would just close the handle to the device, which is analogous to "shuting down" or "un-claiming". In the UDLibrary this is accomplished by calling Close().  The LabJackPython wrapper for the U3-HV device should also have similar functionality.  According to the examples, it'll look like "d.close()"

 

>>> import u3

>>> d = u3.U3() 
>>> d.close()  #Linux and Mac OS X close

 

You might also find the ResetLabJack() function useful. LabJackPython equivalent is "d.reset()"

http://labjack.com/s...16-resetlabjack

how to close the labjack in Windows? The library say that it can be done simply by calling UD function close, but I can not find that function anywhere



#6 LabJack Support

LabJack Support
  • Admin
  • 8677 posts

Posted 12 November 2014 - 12:40 PM

Look at my response to your forum topic about this.

 

On Windows you need to use the LabJackPython.Close() call which is in the LabJackPython module (LabJackPython.py) and is a wrapper call that uses this Windows UD driver function:

 

void _stdcall Close();

 

Also, my previous post in this topic also explains closing devices in Windows.





Also tagged with one or more of these keywords: U3-HV, python

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users